Compare commits
132 Commits
Author | SHA1 | Date | |
---|---|---|---|
f07f2bb95e | |||
0b2f6715e0 | |||
e473364d40 | |||
554b72b075 | |||
2c34ec8b39 | |||
e6b8e2de19 | |||
a99d270ef1 | |||
93ee42135c | |||
f3ca4a114a | |||
7515b824eb | |||
18b98b831a | |||
d99fc8bde9 | |||
f8d5f86814 | |||
9c1de08b4b | |||
7f26337e1b | |||
49f3fc8feb | |||
5613ad7fa6 | |||
5af43900c4 | |||
c5598f95ef | |||
13d0cf729c | |||
032e928dde | |||
14ab3682f2 | |||
c554e730a6 | |||
4d5a490e80 | |||
7708c89fe1 | |||
0a0be3e357 | |||
7b7c469fab | |||
d852186888 | |||
6cfda1ebf3 | |||
8e0062fdd5 | |||
844cc30551 | |||
64074e37fc | |||
cd9b028e9b | |||
81da871e38 | |||
90e78a2e31 | |||
5cec1fea73 | |||
52130d67e2 | |||
a73ad40eb1 | |||
6589818b0b | |||
555fa32ac2 | |||
50a84f2422 | |||
c724a3e85b | |||
b47530e254 | |||
b80fdf113e | |||
963edbffa3 | |||
f3687f724f | |||
a736ee9800 | |||
bea2047092 | |||
7d98ac8f38 | |||
32244bb450 | |||
b154631c77 | |||
466a24ac10 | |||
7db91a2fe6 | |||
46652dec6f | |||
50e591b80c | |||
6710a163a9 | |||
a39f43f79a | |||
964520a2f9 | |||
6e680085a4 | |||
286a843b67 | |||
df7c5ebafc | |||
9927323a9d | |||
66f3e66c8b | |||
c68b0c5090 | |||
53ac03507d | |||
0031b51bcf | |||
67a8c6e591 | |||
806390a068 | |||
508b18bc3b | |||
c2499ea507 | |||
c0c91aec94 | |||
a27008a295 | |||
7e11627618 | |||
968ce63a53 | |||
7c0eb3290f | |||
62403625ba | |||
9a34b03540 | |||
8bb63df7e3 | |||
65cd73845a | |||
8534bc254b | |||
2a2fd324a0 | |||
58e3de2559 | |||
c30736870d | |||
cfd48de885 | |||
462df2b648 | |||
f64da93cf9 | |||
a55db621ef | |||
c033bdfc3b | |||
2610e56ec1 | |||
08aa9e3fe4 | |||
411ae7ee07 | |||
41700c1eb1 | |||
8d7bac9793 | |||
0229eefa4d | |||
61f646743a | |||
e3babde7e8 | |||
c389e43e93 | |||
1511db4eea | |||
d713756034 | |||
17d224332d | |||
32dd5e769b | |||
12ace00a90 | |||
bbc09330c9 | |||
82ead7bd1a | |||
f8f9b150b8 | |||
494e8b7e26 | |||
c76d364071 | |||
760e0085f7 | |||
6890ca1f1f | |||
9ca000cf06 | |||
1c0f5129a9 | |||
69e17949f4 | |||
bcfd3495dd | |||
03a46a72c5 | |||
2465ce5f9b | |||
00ac83f205 | |||
67065b1ffb | |||
783c10479f | |||
d4eae1cd9e | |||
4e674f67c5 | |||
889a543780 | |||
fc5f3a9576 | |||
66644364b5 | |||
51febdae06 | |||
745ff299dc | |||
3606d60ba6 | |||
8970a79141 | |||
566a7ce148 | |||
362bef15e3 | |||
446c494863 | |||
dbe2f2f217 | |||
02ca92a431 |
@ -119,6 +119,6 @@ jobs:
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @gitzone/tsdoc
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
||||
|
36
package.json
36
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@design.estate/dees-catalog",
|
||||
"version": "1.0.178",
|
||||
"version": "1.0.244",
|
||||
"private": false,
|
||||
"description": "website for lossless.com",
|
||||
"main": "dist_ts_web/index.js",
|
||||
@ -15,27 +15,29 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@design.estate/dees-domtools": "^2.0.38",
|
||||
"@design.estate/dees-element": "^2.0.25",
|
||||
"@design.estate/dees-wcctools": "^1.0.78",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
||||
"@fortawesome/free-brands-svg-icons": "^6.4.2",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.4.2",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
||||
"@design.estate/dees-domtools": "^2.0.55",
|
||||
"@design.estate/dees-element": "^2.0.33",
|
||||
"@design.estate/dees-wcctools": "^1.0.85",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
||||
"@fortawesome/free-brands-svg-icons": "^6.5.1",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.5.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
||||
"@push.rocks/smarti18n": "^1.0.4",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartstring": "^4.0.8",
|
||||
"@tsclass/tsclass": "^4.0.42",
|
||||
"highlight.js": "11.8.0",
|
||||
"pdfjs-dist": "^2.16.105"
|
||||
"@push.rocks/smartstring": "^4.0.13",
|
||||
"@tsclass/tsclass": "^4.0.46",
|
||||
"highlight.js": "11.9.0",
|
||||
"ibantools": "^4.3.8",
|
||||
"pdfjs-dist": "^4.0.379"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@gitzone/tsbundle": "^2.0.8",
|
||||
"@gitzone/tstest": "^1.0.77",
|
||||
"@gitzone/tswatch": "^2.0.7",
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsbundle": "^2.0.14",
|
||||
"@git.zone/tstest": "^1.0.77",
|
||||
"@git.zone/tswatch": "^2.0.21",
|
||||
"@push.rocks/projectinfo": "^5.0.2",
|
||||
"@push.rocks/tapbundle": "^5.0.15",
|
||||
"@types/node": "^20.5.1"
|
||||
"@types/node": "^20.10.8"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
3050
pnpm-lock.yaml
generated
3050
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@design.estate/dees-catalog',
|
||||
version: '1.0.178',
|
||||
version: '1.0.244',
|
||||
description: 'website for lossless.com'
|
||||
}
|
||||
|
11
ts_web/elements/00colors.ts
Normal file
11
ts_web/elements/00colors.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export const dark = {
|
||||
blue: '#0050b9',
|
||||
blueActive: '#0069f2',
|
||||
text: '#ffffff',
|
||||
}
|
||||
|
||||
export const bright = {
|
||||
blue: '#0050b9',
|
||||
blueActive: '#0069f2',
|
||||
text: '#333333',
|
||||
}
|
15
ts_web/elements/dees-button.demo.ts
Normal file
15
ts_web/elements/dees-button.demo.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<dees-button>This is a slotted Text</dees-button>
|
||||
<p>
|
||||
<dees-button text="Highlighted: This text shows" type="highlighted">Highlighted</dees-button>
|
||||
</p>
|
||||
<p><dees-button type="discreet">This is discreete button</dees-button></p>
|
||||
<p><dees-button disabled>This is a disabled button</dees-button></p>
|
||||
<p><dees-button type="big">This is a slotted Text</dees-button></p>
|
||||
<p><dees-button status="normal">Normal Status</dees-button></p>
|
||||
<p><dees-button disabled status="pending">Pending Status</dees-button></p>
|
||||
<p><dees-button disabled status="success">Success Status</dees-button></p>
|
||||
<p><dees-button disabled status="error">Error Status</dees-button></p>
|
||||
`;
|
@ -1,3 +1,4 @@
|
||||
import { demoFunc } from './dees-button.demo.js';
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
@ -20,17 +21,7 @@ declare global {
|
||||
|
||||
@customElement('dees-button')
|
||||
export class DeesButton extends DeesElement {
|
||||
public static demo = () => html`
|
||||
<dees-button>This is a slotted Text</dees-button>
|
||||
<p><dees-button text="Highlighted: This text shows" type="highlighted">Highlighted</dees-button></p>
|
||||
<p><dees-button type="discreet">This is discreete button</dees-button></p>
|
||||
<p><dees-button disabled>This is a disabled button</dees-button></p>
|
||||
<p><dees-button type="big">This is a slotted Text</dees-button></p>
|
||||
<p><dees-button status="normal">Normal Status</dees-button></p>
|
||||
<p><dees-button disabled status="pending">Pending Status</dees-button></p>
|
||||
<p><dees-button disabled status="success">Success Status</dees-button></p>
|
||||
<p><dees-button disabled status="error">Error Status</dees-button></p>
|
||||
`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
@property({
|
||||
reflect: true,
|
||||
@ -74,6 +65,7 @@ export class DeesButton extends DeesElement {
|
||||
:host {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Roboto', 'monospace';
|
||||
}
|
||||
:host([hidden]) {
|
||||
display: none;
|
||||
@ -101,16 +93,15 @@ export class DeesButton extends DeesElement {
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
cursor: pointer;
|
||||
background: #039be5;
|
||||
background: #0050b9;
|
||||
color: #ffffff;
|
||||
border: 1px solid #039be5;
|
||||
border-top: 1px solid #039be5;
|
||||
border: 1px solid #0050b9;
|
||||
border-top: 1px solid #0050b9;
|
||||
}
|
||||
|
||||
.button:active {
|
||||
background: #0277bd;
|
||||
border-top: 1px solid #0277bd;
|
||||
background: #0069f2;
|
||||
border-top: 1px solid #0069f2;
|
||||
}
|
||||
|
||||
.button.disabled {
|
||||
@ -154,8 +145,8 @@ export class DeesButton extends DeesElement {
|
||||
}
|
||||
|
||||
.button.pending {
|
||||
border: 1px dashed ${cssManager.bdTheme('#0277bd', '#0277bd70')};
|
||||
background: ${cssManager.bdTheme('#0277bd', '#0277bd70')};
|
||||
border: 1px dashed ${cssManager.bdTheme('#0069f2', '#0069f270')};
|
||||
background: ${cssManager.bdTheme('#0069f2', '#0069f270')};
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
41
ts_web/elements/dees-chips.demo.ts
Normal file
41
ts_web/elements/dees-chips.demo.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<style>
|
||||
.demoContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
background: #222;
|
||||
}
|
||||
</style>
|
||||
<div class="demoContainer">
|
||||
<dees-chips
|
||||
selectionMode="none"
|
||||
.selectableChips=${[
|
||||
{ key: 'account1', value: 'Payment Account 1' },
|
||||
{ key: 'account2', value: 'PaymentAccount2' },
|
||||
{ key: 'account3', value: 'Payment Account 3' },
|
||||
]}
|
||||
></dees-chips>
|
||||
<dees-chips
|
||||
selectionMode="single"
|
||||
chipsAreRemovable
|
||||
.selectableChips=${[
|
||||
{ key: 'account1', value: 'Payment Account 1' },
|
||||
{ key: 'account2', value: 'PaymentAccount2' },
|
||||
{ key: 'account3', value: 'Payment Account 3' },
|
||||
]}
|
||||
></dees-chips>
|
||||
<dees-chips
|
||||
selectionMode="multiple"
|
||||
.selectableChips=${[
|
||||
{ key: 'account1', value: 'Payment Account 1' },
|
||||
{ key: 'account2', value: 'PaymentAccount2' },
|
||||
{ key: 'account3', value: 'Payment Account 3' },
|
||||
]}
|
||||
></dees-chips>
|
||||
</div>
|
||||
`;
|
@ -11,6 +11,7 @@ import {
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { demoFunc } from './dees-chips.demo.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -18,30 +19,32 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
type Tag = { key: string; value: string };
|
||||
|
||||
@customElement('dees-chips')
|
||||
export class DeesChips extends DeesElement {
|
||||
public static demo = () => html`
|
||||
<dees-chips .selectableChips=${['Payment Account 1', 'PaymentAccount2', 'Payment Account 3']}></dees-chips>
|
||||
<dees-chips selectionMode="multiple" .selectableChips=${['Payment Account 1', 'PaymentAccount2', 'Payment Account 3']}></dees-chips>
|
||||
|
||||
`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
@property()
|
||||
public selectionMode: 'single' | 'multiple' = 'single';
|
||||
public selectionMode: 'none' | 'single' | 'multiple' = 'single';
|
||||
|
||||
@property({
|
||||
type: Array
|
||||
type: Boolean,
|
||||
})
|
||||
public selectableChips: string[] = [];
|
||||
public chipsAreRemovable: boolean = false;
|
||||
|
||||
@property({
|
||||
type: Array,
|
||||
})
|
||||
public selectableChips: Tag[] = [];
|
||||
|
||||
@property()
|
||||
public selectedChip: string = null;
|
||||
public selectedChip: Tag = null;
|
||||
|
||||
@property({
|
||||
type: Array
|
||||
type: Array,
|
||||
})
|
||||
public selectedChips: string[] = [];
|
||||
|
||||
public selectedChips: Tag[] = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -50,47 +53,87 @@ export class DeesChips extends DeesElement {
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.mainbox {
|
||||
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.chip {
|
||||
background: #494949;
|
||||
display: inline-block;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||
background: #333333;
|
||||
display: inline-flex;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
padding: 0px 8px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
border-radius: 40px;
|
||||
margin-right: 4px;
|
||||
margin-bottom: 8px;
|
||||
margin-bottom: 4px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.chip:hover {
|
||||
background: #666666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.chip.selected {
|
||||
background: #00A3FF;
|
||||
background: #00a3ff;
|
||||
}
|
||||
|
||||
.chipKey {
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
margin-left: -8px;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
dees-icon {
|
||||
padding: 0px 6px 0px 4px;
|
||||
margin-left: 4px;
|
||||
margin-right: -8px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
dees-icon:hover {
|
||||
background: #e4002b;
|
||||
}
|
||||
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
<div class="mainbox">
|
||||
${this.selectableChips.map(chipArg => html`
|
||||
<div @click=${() => this.selectChip(chipArg)} class="chip ${this.selectedChip === chipArg || this.selectedChips.includes(chipArg) ? 'selected' : ''}">
|
||||
${chipArg}
|
||||
</div>
|
||||
`)}
|
||||
${this.selectableChips.map(
|
||||
(chip) => html`
|
||||
<div
|
||||
@click=${() => this.selectChip(chip)}
|
||||
class="chip ${this.isSelected(chip) ? 'selected' : ''}"
|
||||
>
|
||||
${chip.key ? html`<div class="chipKey">${chip.key}</div>` : html``} ${chip.value}
|
||||
${this.chipsAreRemovable
|
||||
? html`
|
||||
<dees-icon
|
||||
@click=${(event: Event) => {
|
||||
event.stopPropagation(); // prevent the selectChip event from being triggered
|
||||
this.removeChip(chip);
|
||||
}}
|
||||
.iconFA=${'xmark'}
|
||||
></dees-icon>
|
||||
`
|
||||
: html``}
|
||||
</div>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@ -102,23 +145,51 @@ export class DeesChips extends DeesElement {
|
||||
}
|
||||
}
|
||||
|
||||
public async selectChip(chipArg: string) {
|
||||
private isSelected(chip: Tag): boolean {
|
||||
if (this.selectionMode === 'single') {
|
||||
if (this.selectedChip === chipArg) {
|
||||
return this.selectedChip?.key === chip.key;
|
||||
} else {
|
||||
return this.selectedChips.some((selected) => selected.key === chip.key);
|
||||
}
|
||||
}
|
||||
|
||||
public async selectChip(chip: Tag) {
|
||||
if (this.selectionMode === 'none') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.selectionMode === 'single') {
|
||||
if (this.isSelected(chip)) {
|
||||
this.selectedChip = null;
|
||||
this.selectedChips = [];
|
||||
} else {
|
||||
this.selectedChip = chipArg;
|
||||
this.selectedChips = [chipArg];
|
||||
this.selectedChip = chip;
|
||||
this.selectedChips = [chip];
|
||||
}
|
||||
} else if(this.selectionMode === 'multiple') {
|
||||
if (this.selectedChips.includes(chipArg)) {
|
||||
this.selectedChips = this.selectedChips.filter(chipArg2 => chipArg !== chipArg2)
|
||||
} else if (this.selectionMode === 'multiple') {
|
||||
if (this.isSelected(chip)) {
|
||||
this.selectedChips = this.selectedChips.filter((selected) => selected.key !== chip.key);
|
||||
} else {
|
||||
this.selectedChips.push(chipArg);
|
||||
this.selectedChips = [...this.selectedChips, chip];
|
||||
}
|
||||
this.requestUpdate();
|
||||
}
|
||||
console.log(this.selectedChips);
|
||||
}
|
||||
|
||||
public removeChip(chipToRemove: Tag): void {
|
||||
// Remove the chip from selectableChips
|
||||
this.selectableChips = this.selectableChips.filter((chip) => chip.key !== chipToRemove.key);
|
||||
|
||||
// Remove the chip from selectedChips if present
|
||||
this.selectedChips = this.selectedChips.filter((chip) => chip.key !== chipToRemove.key);
|
||||
|
||||
// If the removed chip was the selectedChip, set selectedChip to null
|
||||
if (this.selectedChip && this.selectedChip.key === chipToRemove.key) {
|
||||
this.selectedChip = null;
|
||||
}
|
||||
|
||||
// Trigger an update to re-render the component
|
||||
this.requestUpdate();
|
||||
}
|
||||
}
|
||||
|
57
ts_web/elements/dees-contextmenu.demo.ts
Normal file
57
ts_web/elements/dees-contextmenu.demo.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
import * as plugins from './00plugins.js';
|
||||
|
||||
import { DeesContextmenu } from './dees-contextmenu.js';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<style>
|
||||
.withMargin {
|
||||
display: block;
|
||||
margin: 20px;
|
||||
}
|
||||
</style>
|
||||
<dees-button @contextmenu=${(eventArg) => {
|
||||
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
||||
{
|
||||
name: 'copy',
|
||||
iconName: 'copySolid',
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
iconName: 'penToSquare',
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},{
|
||||
name: 'paste',
|
||||
iconName: 'pasteSolid',
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
]);
|
||||
}}>Right-Click for contextmenu</dees-button>
|
||||
<dees-contextmenu class="withMargin"></dees-contextmenu>
|
||||
<dees-contextmenu
|
||||
class="withMargin"
|
||||
.menuItems=${[
|
||||
{
|
||||
name: 'copy',
|
||||
iconName: 'copySolid',
|
||||
action: async () => {},
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
iconName: 'penToSquare',
|
||||
action: async () => {},
|
||||
},{
|
||||
name: 'paste',
|
||||
iconName: 'pasteSolid',
|
||||
action: async () => {},
|
||||
},
|
||||
] as plugins.tsclass.website.IMenuItem[]}
|
||||
></dees-contextmenu>
|
||||
`;
|
@ -1,4 +1,5 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import { demoFunc } from './dees-contextmenu.demo.js';
|
||||
import * as plugins from './00plugins.js';
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
@ -23,85 +24,80 @@ declare global {
|
||||
@customElement('dees-contextmenu')
|
||||
export class DeesContextmenu extends DeesElement {
|
||||
// DEMO
|
||||
public static demo = () => html`
|
||||
<style>
|
||||
.withMargin {
|
||||
display: block;
|
||||
margin: 20px;
|
||||
}
|
||||
</style>
|
||||
<dees-button @contextmenu=${(eventArg) => {
|
||||
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
||||
{
|
||||
name: 'copy',
|
||||
iconName: 'copySolid',
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
iconName: 'penToSquare',
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},{
|
||||
name: 'paste',
|
||||
iconName: 'pasteSolid',
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
]);
|
||||
}}>Hello</dees-button>
|
||||
<dees-contextmenu class="withMargin"></dees-contextmenu>
|
||||
<dees-contextmenu
|
||||
class="withMargin"
|
||||
.menuItems=${[
|
||||
{
|
||||
name: 'copy',
|
||||
iconName: 'copySolid',
|
||||
action: async () => {},
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
iconName: 'penToSquare',
|
||||
action: async () => {},
|
||||
},{
|
||||
name: 'paste',
|
||||
iconName: 'pasteSolid',
|
||||
action: async () => {},
|
||||
},
|
||||
] as plugins.tsclass.website.IMenuItem[]}
|
||||
></dees-contextmenu>
|
||||
`;
|
||||
public static demo = demoFunc
|
||||
|
||||
// STATIC
|
||||
// This will store all the accumulated menu items
|
||||
public static contextMenuDeactivated = false;
|
||||
public static accumulatedMenuItems: plugins.tsclass.website.IMenuItem[] = [];
|
||||
|
||||
// Add a global event listener for the right-click context menu
|
||||
public static initializeGlobalListener() {
|
||||
document.addEventListener('contextmenu', (event: MouseEvent) => {
|
||||
if (this.contextMenuDeactivated) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
// Get the target element of the right-click
|
||||
let target: EventTarget | null = event.target;
|
||||
|
||||
// Clear previously accumulated items
|
||||
DeesContextmenu.accumulatedMenuItems = [];
|
||||
|
||||
// Traverse up the DOM tree to accumulate menu items
|
||||
while (target) {
|
||||
if ((target as any).getContextMenuItems) {
|
||||
DeesContextmenu.accumulatedMenuItems.push(...(target as any).getContextMenuItems());
|
||||
}
|
||||
target = (target as Node).parentNode;
|
||||
}
|
||||
|
||||
// Open the context menu with the accumulated items
|
||||
DeesContextmenu.openContextMenuWithOptions(event, DeesContextmenu.accumulatedMenuItems);
|
||||
});
|
||||
}
|
||||
|
||||
// allows opening of a contextmenu with options
|
||||
public static async openContextMenuWithOptions(eventArg: MouseEvent, menuItemsArg: plugins.tsclass.website.IMenuItem[]) {
|
||||
if (this.contextMenuDeactivated) {
|
||||
return;
|
||||
}
|
||||
eventArg.preventDefault();
|
||||
eventArg.stopPropagation();
|
||||
const contextMenu = new DeesContextmenu();
|
||||
contextMenu.style.position = 'absolute';
|
||||
contextMenu.style.position = 'fixed';
|
||||
contextMenu.style.zIndex = '2000';
|
||||
contextMenu.style.top = `${eventArg.clientY.toString()}px`;
|
||||
contextMenu.style.left = `${eventArg.clientX.toString()}px`;
|
||||
contextMenu.style.opacity = '0';
|
||||
contextMenu.style.transform = 'scale(0.95,0.95)';
|
||||
contextMenu.style.transformOrigin = 'top left';
|
||||
contextMenu.menuItems = menuItemsArg;
|
||||
contextMenu.windowLayer = await DeesWindowLayer.createAndShow();
|
||||
contextMenu.windowLayer.addEventListener('click', async () => {
|
||||
await contextMenu.destroy();
|
||||
})
|
||||
document.body.append(contextMenu);
|
||||
await domtools.plugins.smartdelay.delayFor(0);
|
||||
contextMenu.style.opacity = '1';
|
||||
contextMenu.style.transform = 'scale(1,1)';
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
@property({
|
||||
type: Array,
|
||||
})
|
||||
public menuItems: plugins.tsclass.website.IMenuItem[] = [];
|
||||
windowLayer: DeesWindowLayer;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* STATIC STYLES
|
||||
*/
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
@ -114,11 +110,11 @@ export class DeesContextmenu extends DeesElement {
|
||||
color: ${cssManager.bdTheme('#222', '#ccc')};
|
||||
font-size: 14px;
|
||||
width: 200px;
|
||||
border: 1px solid #444;
|
||||
min-height: 40px;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -134,12 +130,10 @@ export class DeesContextmenu extends DeesElement {
|
||||
}
|
||||
|
||||
.mainbox .menuitem:hover {
|
||||
cursor: pointer;
|
||||
background: #ffffff10;
|
||||
background: ${cssManager.bdTheme('#00000010', '#ffffff10')};
|
||||
}
|
||||
|
||||
.mainbox .menuitem:active {
|
||||
cursor: pointer;
|
||||
background: #ffffff05;
|
||||
}
|
||||
`,
|
||||
@ -156,15 +150,21 @@ export class DeesContextmenu extends DeesElement {
|
||||
</div>
|
||||
`;
|
||||
})}
|
||||
${this.menuItems.length === 0 ? html`
|
||||
<div class="menuitem" @click=${() => {
|
||||
DeesContextmenu.contextMenuDeactivated = true;
|
||||
this.destroy();
|
||||
}}>
|
||||
<dees-icon .iconFA=${'xmark'}></dees-icon
|
||||
>Deactivate Contextmenu globally.
|
||||
</div>
|
||||
` : html``}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
public async firstUpdated() {
|
||||
if (!this.menuItems || this.menuItems.length === 0) {
|
||||
const mainbox = this.shadowRoot.querySelector('.mainbox');
|
||||
mainbox.textContent = 'no menu items present';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async handleClick(menuItem: plugins.tsclass.website.IMenuItem) {
|
||||
@ -173,9 +173,14 @@ export class DeesContextmenu extends DeesElement {
|
||||
}
|
||||
|
||||
public async destroy() {
|
||||
if (this.windowLayer) {
|
||||
this.windowLayer.destroy();
|
||||
}
|
||||
this.style.opacity = '0';
|
||||
this.style.transform = 'scale(0.95,0,95)';
|
||||
await domtools.plugins.smartdelay.delayFor(100);
|
||||
this.parentElement.removeChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
DeesContextmenu.initializeGlobalListener();
|
||||
|
18
ts_web/elements/dees-dataview-codebox.demo.ts
Normal file
18
ts_web/elements/dees-dataview-codebox.demo.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html` <style>
|
||||
.demoWrapper {
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
background: none;
|
||||
}
|
||||
</style>
|
||||
<div class="demoWrapper">
|
||||
<dees-dataview-codebox proglang="typescript">
|
||||
import * as text from './hello'; const hiThere = 'nice'; const myFunction = async () => {
|
||||
console.log('nice one'); }
|
||||
</dees-dataview-codebox>
|
||||
</div>`
|
@ -1,3 +1,4 @@
|
||||
import { demoFunc } from './dees-dataview-codebox.demo.js';
|
||||
import {
|
||||
DeesElement,
|
||||
html,
|
||||
@ -5,6 +6,7 @@ import {
|
||||
type TemplateResult,
|
||||
property,
|
||||
state,
|
||||
cssManager,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import hlight from 'highlight.js';
|
||||
@ -12,6 +14,7 @@ import hlight from 'highlight.js';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { DeesContextmenu } from './dees-contextmenu.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -21,10 +24,7 @@ declare global {
|
||||
|
||||
@customElement('dees-dataview-codebox')
|
||||
export class DeesDataviewCodebox extends DeesElement {
|
||||
public static demo = () => html`<dees-dataview-codebox proglang="typescript">
|
||||
import * as text from './hello'; const hiThere = 'nice'; const myFunction = async () => {
|
||||
console.log('nice one'); }
|
||||
</dees-dataview-codebox>`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
@property()
|
||||
public progLang: string = 'typescript';
|
||||
@ -48,23 +48,60 @@ export class DeesDataviewCodebox extends DeesElement {
|
||||
display: block;
|
||||
text-align: left;
|
||||
font-size: 16px;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
}
|
||||
.mainbox {
|
||||
position: relative;
|
||||
color: ${this.goBright ? '#333333' : '#ffffff'};
|
||||
border-top: 1px solid ${this.goBright ? '#ffffff' : '#333333'};
|
||||
box-shadow: 0px 0px 5px ${this.goBright ? 'rgba(0,0,0,0.1)' : 'rgba(0,0,0,0.5)'};
|
||||
background: ${this.goBright ? '#ffffff' : '#191919'};
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.appbar {
|
||||
position: relative;
|
||||
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||
background: ${cssManager.bdTheme('#ffffff', '#161616')};
|
||||
border-bottom: 1px solid ${cssManager.bdTheme('#eeeeeb', '#222222')};
|
||||
height: 24px;
|
||||
display: flex;
|
||||
font-size: 12px;
|
||||
line-height: 24px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.appbar .fileName {
|
||||
line-height: inherit;
|
||||
position: relative;
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bottomBar {
|
||||
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||
background: ${cssManager.bdTheme('#ffffff', '#161616')};
|
||||
border-top: 1px solid ${cssManager.bdTheme('#eeeeeb', '#222222')};
|
||||
height: 24px;
|
||||
font-size: 12px;
|
||||
line-height: 24px;
|
||||
text-align: right;
|
||||
padding-right: 100px;
|
||||
}
|
||||
|
||||
.languageLabel {
|
||||
color: #fff;
|
||||
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||
font-size: 12px;
|
||||
line-height: 24px;
|
||||
z-index: 10;
|
||||
background: #6596ff;
|
||||
background: #6596ff20;
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
right: 32px;
|
||||
padding: 4px;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
padding: 0px 16px 0px 8px;
|
||||
}
|
||||
|
||||
.hljs-keyword {
|
||||
@ -74,18 +111,14 @@ export class DeesDataviewCodebox extends DeesElement {
|
||||
.codegrid {
|
||||
display: grid;
|
||||
grid-template-columns: 50px auto;
|
||||
background: ${this.goBright ? '#ffffff' : '#191919'};
|
||||
border-top: 1px solid ${this.goBright ? '#ffffff' : '#333333'};
|
||||
box-shadow: 0px 0px 5px ${this.goBright ? 'rgba(0,0,0,0.1)' : 'rgba(0,0,0,0.5)'};
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lineNumbers {
|
||||
background: ${this.goBright ? '#fafafa' : '#151515'};
|
||||
color: ${this.goBright ? '#acacac' : '#666666'};
|
||||
padding: 30px 16px 0px 0px;
|
||||
text-align: right;
|
||||
border-right: 1px solid ${this.goBright ? '#eaeaea' : '#222222'};
|
||||
}
|
||||
|
||||
.lineCounter:last-child {
|
||||
@ -121,31 +154,52 @@ export class DeesDataviewCodebox extends DeesElement {
|
||||
}
|
||||
|
||||
.hljs-function {
|
||||
color: ${this.goBright ? '#2765DF': '#6596ff' };
|
||||
color: ${this.goBright ? '#2765DF' : '#6596ff'};
|
||||
}
|
||||
|
||||
.hljs-params {
|
||||
color: ${this.goBright ? '#3DB420' : '#65d5ff' };
|
||||
color: ${this.goBright ? '#3DB420' : '#65d5ff'};
|
||||
}
|
||||
|
||||
.hljs-comment {
|
||||
color: ${this.goBright ? '#EF9300' : '#ffd765' };
|
||||
color: ${this.goBright ? '#EF9300' : '#ffd765'};
|
||||
}
|
||||
</style>
|
||||
<div class="mainbox">
|
||||
<div class="languageLabel">${this.progLang}</div>
|
||||
<div
|
||||
class="mainbox"
|
||||
@contextmenu="${(eventArg) => {
|
||||
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
||||
{
|
||||
name: 'About',
|
||||
iconName: 'circleInfo',
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
]);
|
||||
}}"
|
||||
>
|
||||
<div class="appbar">
|
||||
<dees-windowcontrols type="mac" position="left"></dees-windowcontrols>
|
||||
<div class="fileName">index.ts</div>
|
||||
<dees-windowcontrols type="mac" position="right"></dees-windowcontrols>
|
||||
</div>
|
||||
<div class="codegrid">
|
||||
<div class="lineNumbers">
|
||||
${(() => {
|
||||
let lineCounter = 0;
|
||||
return this.codeToDisplay.split('\n').map(lineArg => {
|
||||
return this.codeToDisplay.split('\n').map((lineArg) => {
|
||||
lineCounter++;
|
||||
return html`<div class="lineCounter">${lineCounter}</div>`;
|
||||
})
|
||||
});
|
||||
})()}
|
||||
</div>
|
||||
<pre><code></code></pre>
|
||||
</div>
|
||||
<div class="bottomBar">
|
||||
Spaces: 2
|
||||
<div class="languageLabel">${this.progLang}</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@ -167,12 +221,17 @@ export class DeesDataviewCodebox extends DeesElement {
|
||||
this.codeToDisplayStore = smartstring.indent.normalize(this.codeToDisplay).trimStart();
|
||||
}
|
||||
if (slottedCodeNodes[0] && slottedCodeNodes[0].wholeText && !this.codeToDisplay) {
|
||||
this.codeToDisplayStore = smartstring.indent.normalize(slottedCodeNodes[0].wholeText).trimStart();
|
||||
this.codeToDisplayStore = smartstring.indent
|
||||
.normalize(slottedCodeNodes[0].wholeText)
|
||||
.trimStart();
|
||||
this.codeToDisplay = this.codeToDisplayStore;
|
||||
}
|
||||
await domtools.plugins.smartdelay.delayFor(0);
|
||||
const localCodeNode = this.shadowRoot.querySelector('code');
|
||||
const html = hlight.highlight(this.codeToDisplayStore, {language: this.progLang, ignoreIllegals: true});
|
||||
const html = hlight.highlight(this.codeToDisplayStore, {
|
||||
language: this.progLang,
|
||||
ignoreIllegals: true,
|
||||
});
|
||||
localCodeNode.innerHTML = html.value;
|
||||
}
|
||||
}
|
||||
|
39
ts_web/elements/dees-dataview-statusobject.demo.ts
Normal file
39
ts_web/elements/dees-dataview-statusobject.demo.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export const demoFunc = () => html`<dees-dataview-statusobject
|
||||
.statusObject=${{
|
||||
id: '1',
|
||||
name: 'Demo Item',
|
||||
combinedStatus: 'partly_ok',
|
||||
combinedStatusText: 'partly_ok',
|
||||
details: [
|
||||
{
|
||||
name: 'Detail 1',
|
||||
value: 'Value 1',
|
||||
status: 'ok',
|
||||
statusText: 'OK',
|
||||
},
|
||||
{
|
||||
name: 'Detail 2',
|
||||
value: 'Value 2',
|
||||
status: 'partly_ok',
|
||||
statusText: 'partly_ok',
|
||||
},
|
||||
{
|
||||
name: 'Detail 3',
|
||||
value: 'Value 3',
|
||||
status: 'not_ok',
|
||||
statusText: 'not_ok',
|
||||
},
|
||||
{
|
||||
name: 'Detail 4',
|
||||
value:
|
||||
'Value 4 jhdkfjhalskdfjhfdjskalsdkfjhfdjskalskdjfhjdkslaksjdhfjdkslaskdfjhfjdkslaskdjfhjdskalskdjhfdjskalskdjfhdjskl',
|
||||
status: 'ok',
|
||||
statusText: 'OK',
|
||||
},
|
||||
],
|
||||
} as tsclass.code.IStatusObject}
|
||||
>
|
||||
</dees-dataview-statusobject>`;
|
@ -1,3 +1,4 @@
|
||||
import { demoFunc } from './dees-dataview-statusobject.demo.js';
|
||||
import {
|
||||
DeesElement,
|
||||
html,
|
||||
@ -20,41 +21,7 @@ declare global {
|
||||
|
||||
@customElement('dees-dataview-statusobject')
|
||||
export class DeesDataviewStatusobject extends DeesElement {
|
||||
public static demo = () => html`<dees-dataview-statusobject
|
||||
.statusObject=${{
|
||||
id: '1',
|
||||
name: 'Demo Item',
|
||||
combinedStatus: 'partly_ok',
|
||||
combinedStatusText: 'partly_ok',
|
||||
details: [
|
||||
{
|
||||
name: 'Detail 1',
|
||||
value: 'Value 1',
|
||||
status: 'ok',
|
||||
statusText: 'OK',
|
||||
},
|
||||
{
|
||||
name: 'Detail 2',
|
||||
value: 'Value 2',
|
||||
status: 'partly_ok',
|
||||
statusText: 'partly_ok',
|
||||
},
|
||||
{
|
||||
name: 'Detail 3',
|
||||
value: 'Value 3',
|
||||
status: 'not_ok',
|
||||
statusText: 'not_ok',
|
||||
},
|
||||
{
|
||||
name: 'Detail 4',
|
||||
value: 'Value 4 jhdkfjhalskdfjhfdjskalsdkfjhfdjskalskdjfhjdkslaksjdhfjdkslaskdfjhfjdkslaskdjfhjdskalskdjhfdjskalskdjfhdjskl',
|
||||
status: 'ok',
|
||||
statusText: 'OK',
|
||||
},
|
||||
],
|
||||
}}
|
||||
>
|
||||
</dees-dataview-statusobject>`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
@property({ type: Object }) statusObject: tsclass.code.IStatusObject;
|
||||
|
||||
@ -62,7 +29,7 @@ export class DeesDataviewStatusobject extends DeesElement {
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
.mainbox {
|
||||
border-radius: 3px;
|
||||
border-radius: 8px;
|
||||
background: ${cssManager.bdTheme('#fff', '#1b1b1b')};
|
||||
box-shadow: 0px 1px 3px #00000030;
|
||||
min-height: 48px;
|
||||
@ -94,8 +61,7 @@ export class DeesDataviewStatusobject extends DeesElement {
|
||||
}
|
||||
|
||||
.copyMain {
|
||||
cursor: pointer;
|
||||
font-size: 8px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
border: 1px solid ${cssManager.bdTheme('#999', '#444')};
|
||||
@ -103,6 +69,7 @@ export class DeesDataviewStatusobject extends DeesElement {
|
||||
padding: 4px;
|
||||
border-radius: 3px;
|
||||
margin-right: 16px;
|
||||
color: #ffffff80
|
||||
}
|
||||
|
||||
.statusdot.ok {
|
||||
@ -122,7 +89,7 @@ export class DeesDataviewStatusobject extends DeesElement {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: 40px auto;
|
||||
border-top: 1px dotted ${cssManager.bdTheme('#999', '#444')};
|
||||
border-top: 1px dotted ${cssManager.bdTheme('#999', '#282828')};
|
||||
}
|
||||
|
||||
.detail .detailsText {
|
||||
@ -134,10 +101,11 @@ export class DeesDataviewStatusobject extends DeesElement {
|
||||
|
||||
.detail .detailsText .label {
|
||||
font-size: 12px;
|
||||
color: #ffffff80
|
||||
}
|
||||
|
||||
.detail .detailsText .value {
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
font-family: 'Intel One Mono';
|
||||
}
|
||||
`,
|
||||
|
56
ts_web/elements/dees-form.demo.ts
Normal file
56
ts_web/elements/dees-form.demo.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import { html, domtools } from '@design.estate/dees-element';
|
||||
import type { DeesForm } from './dees-form.js';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<style>
|
||||
.demoContainer {
|
||||
max-width: 400px;
|
||||
margin: auto;
|
||||
padding: 16px;
|
||||
background: #111;
|
||||
}
|
||||
</style>
|
||||
<div class="demoContainer">
|
||||
<dees-form
|
||||
style="display: block; margin:auto; max-width: 500px; padding: 20px"
|
||||
@formData=${async (eventArg) => {
|
||||
const form: DeesForm = eventArg.currentTarget;
|
||||
form.setStatus('pending', 'authenticating...');
|
||||
await domtools.plugins.smartdelay.delayFor(1000);
|
||||
form.setStatus('success', 'authenticated!');
|
||||
}}
|
||||
>
|
||||
<dees-input-dropdown
|
||||
.label=${'title'}
|
||||
.options=${[
|
||||
{ option: 'option 1', key: 'option1' },
|
||||
{ option: 'option 2', key: 'option2' },
|
||||
{ option: 'option 3', key: 'option3' },
|
||||
]}
|
||||
></dees-input-dropdown>
|
||||
<dees-input-multiselect
|
||||
.label=${'title'}
|
||||
.options=${[
|
||||
{ option: 'option 1', key: 'option1' },
|
||||
{ option: 'option 2', key: 'option2' },
|
||||
{ option: 'option 3', key: 'option3' },
|
||||
]}></dees-input-multiselect>
|
||||
<dees-input-typelist></dees-input-typelist>
|
||||
<dees-input-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
||||
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
||||
<dees-input-text
|
||||
.required="${true}"
|
||||
key="hello3"
|
||||
label="a password"
|
||||
isPasswordBool
|
||||
></dees-input-text>
|
||||
<dees-input-checkbox
|
||||
.required="${true}"
|
||||
key="hello3"
|
||||
label="another text"
|
||||
></dees-input-checkbox>
|
||||
<dees-input-iban></dees-input-iban>
|
||||
<dees-form-submit>Submit</dees-form-submit>
|
||||
</dees-form>
|
||||
</div>
|
||||
`;
|
@ -1,4 +1,10 @@
|
||||
import { customElement, html, type TemplateResult, DeesElement, type CSSResult, } from '@design.estate/dees-element';
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
type TemplateResult,
|
||||
DeesElement,
|
||||
type CSSResult,
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
import { DeesInputCheckbox } from './dees-input-checkbox.js';
|
||||
@ -6,16 +12,27 @@ import { DeesInputText } from './dees-input-text.js';
|
||||
import { DeesInputQuantitySelector } from './dees-input-quantityselector.js';
|
||||
import { DeesInputRadio } from './dees-input-radio.js';
|
||||
import { DeesFormSubmit } from './dees-form-submit.js';
|
||||
import { DeesTable } from './dees-table.js';
|
||||
import { demoFunc } from './dees-form.demo.js';
|
||||
import { DeesInputIban } from './dees-input-iban.js';
|
||||
|
||||
// Unified set for form input types
|
||||
const FORM_INPUT_TYPES = [
|
||||
DeesInputCheckbox,
|
||||
DeesInputIban,
|
||||
DeesInputText,
|
||||
DeesInputQuantitySelector,
|
||||
DeesInputRadio
|
||||
DeesInputRadio,
|
||||
DeesTable,
|
||||
];
|
||||
|
||||
export type TFormInputElement = DeesInputCheckbox | DeesInputText | DeesInputQuantitySelector | DeesInputRadio;
|
||||
export type TFormInputElement =
|
||||
| DeesInputCheckbox
|
||||
| DeesInputIban
|
||||
| DeesInputText
|
||||
| DeesInputQuantitySelector
|
||||
| DeesInputRadio
|
||||
| DeesTable<any>;
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -25,26 +42,10 @@ declare global {
|
||||
|
||||
@customElement('dees-form')
|
||||
export class DeesForm extends DeesElement {
|
||||
|
||||
public static demo = () => html`
|
||||
<dees-form
|
||||
style="display: block; margin:auto; max-width: 500px; padding: 20px"
|
||||
@formData=${async (eventArg) => {
|
||||
const form: DeesForm = eventArg.currentTarget;
|
||||
form.setStatus('pending', 'authenticating...');
|
||||
await domtools.plugins.smartdelay.delayFor(1000);
|
||||
form.setStatus('success', 'authenticated!');
|
||||
}}
|
||||
>
|
||||
<dees-input-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
||||
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
||||
<dees-input-checkbox .required="${true}" key="hello3" label="another text"></dees-input-checkbox>
|
||||
<dees-form-submit>Submit</dees-form-submit>
|
||||
</dees-form>
|
||||
`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
public name: string = 'myform';
|
||||
public changeSubject = new domtools.rxjs.Subject();
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||
public readyDeferred = domtools.plugins.smartpromise.defer();
|
||||
|
||||
public render(): TemplateResult {
|
||||
@ -75,14 +76,14 @@ export class DeesForm extends DeesElement {
|
||||
}
|
||||
|
||||
public getFormElements(): Array<TFormInputElement> {
|
||||
return (Array.from(this.children)).filter(child =>
|
||||
return Array.from(this.children).filter((child) =>
|
||||
FORM_INPUT_TYPES.includes(child.constructor as any)
|
||||
) as unknown as TFormInputElement[];
|
||||
}
|
||||
|
||||
public getSubmitButton(): DeesFormSubmit | undefined {
|
||||
return Array.from(this.children).find(child =>
|
||||
child instanceof DeesFormSubmit
|
||||
return Array.from(this.children).find(
|
||||
(child) => child instanceof DeesFormSubmit
|
||||
) as DeesFormSubmit;
|
||||
}
|
||||
|
||||
@ -102,7 +103,7 @@ export class DeesForm extends DeesElement {
|
||||
|
||||
public async collectFormData() {
|
||||
const children = this.getFormElements();
|
||||
const valueObject: { [key: string]: string | number | boolean } = {};
|
||||
const valueObject: { [key: string]: string | number | boolean | any[] } = {};
|
||||
for (const child of children) {
|
||||
if (!child.key) {
|
||||
console.log(`form element with label "${child.label}" has no key. skipping.`);
|
||||
@ -166,6 +167,19 @@ export class DeesForm extends DeesElement {
|
||||
submitButton.text = textStateArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets the form
|
||||
*/
|
||||
reset() {
|
||||
const inputChildren = this.getFormElements();
|
||||
const submitButton = this.getSubmitButton();
|
||||
|
||||
for (const inputChild of inputChildren) {
|
||||
inputChild.value = null;
|
||||
}
|
||||
this.setStatus('normal', 'Submit');
|
||||
}
|
||||
|
||||
public async addBehaviours() {
|
||||
// Use event delegation
|
||||
this.addEventListener('keydown', (event: KeyboardEvent) => {
|
||||
|
5
ts_web/elements/dees-hint.demo.ts
Normal file
5
ts_web/elements/dees-hint.demo.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<dees-hint></dees-hint>
|
||||
`;
|
38
ts_web/elements/dees-hint.ts
Normal file
38
ts_web/elements/dees-hint.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import {
|
||||
DeesElement,
|
||||
css,
|
||||
cssManager,
|
||||
customElement,
|
||||
html,
|
||||
property,
|
||||
type CSSResult,
|
||||
type TemplateResult,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { demoFunc } from './dees-hint.demo.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'dees-hint': DeesHint;
|
||||
}
|
||||
}
|
||||
|
||||
@customElement('dees-hint')
|
||||
export class DeesHint extends DeesElement {
|
||||
public static demo = demoFunc;
|
||||
|
||||
@property({ type: String })
|
||||
public type: 'info' | 'warn' | 'error' | 'critical' = 'info';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
domtools.elementBasic.setup();
|
||||
}
|
||||
|
||||
public static styles = [cssManager.defaultStyles, css``];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html` <div class="mainbox"></div> `;
|
||||
}
|
||||
}
|
55
ts_web/elements/dees-icon.demo.ts
Normal file
55
ts_web/elements/dees-icon.demo.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
import { faIcons } from './dees-icon.js';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<style>
|
||||
.demoContainer {
|
||||
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
background: #111111;
|
||||
padding: 10px; font-size: 30px;
|
||||
}
|
||||
dees-icon {
|
||||
transition: color 0.02s;
|
||||
color: #ffffff;
|
||||
}
|
||||
dees-icon:hover {
|
||||
color: #e4002b;
|
||||
}
|
||||
|
||||
.iconContainer {
|
||||
display: block;
|
||||
padding: 16px 16px 0px 16px;
|
||||
border: 1px solid #333333;
|
||||
margin-right: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.iconName {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
color: #ccc;
|
||||
background: #333333;
|
||||
padding: 4px 8px;
|
||||
padding-bottom: 4px;
|
||||
margin-left: -16px;
|
||||
margin-right: -16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="demoContainer">
|
||||
${Object.keys(faIcons).map(
|
||||
(iconName) => html`
|
||||
<div class="iconContainer">
|
||||
<dees-icon .iconFA=${iconName as any}></dees-icon>
|
||||
<div class="iconName">${iconName}</div>
|
||||
</div>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
|
||||
`;
|
@ -29,6 +29,7 @@ import {
|
||||
faMessage as faMessageRegular,
|
||||
faPaste as faPasteRegular,
|
||||
faSun as faSunRegular,
|
||||
faTrashCan as faTrashCanRegular,
|
||||
} from '@fortawesome/free-regular-svg-icons';
|
||||
import {
|
||||
faArrowRight as faArrowRightSolid,
|
||||
@ -42,74 +43,80 @@ import {
|
||||
faCircleInfo as faCircleInfoSolid,
|
||||
faCircleCheck as faCircleCheckSolid,
|
||||
faCircleXmark as faCircleXmarkSolid,
|
||||
faClockRotateLeft as faClockRotateLeftSolid,
|
||||
faCopy as faCopySolid,
|
||||
faDesktop as faDesktopSolid,
|
||||
faEye as faEyeSolid,
|
||||
faEyeSlash as faEyeSlashSolid,
|
||||
faFileInvoice as faFileInvoiceSolid,
|
||||
faFileInvoiceDollar as faFileInvoiceDollarSolid,
|
||||
faGear as faGearSolid,
|
||||
faGrip as faGripSolid,
|
||||
faMessage as faMessageSolid,
|
||||
faMoneyCheckDollar as faMoneyCheckDollarSolid,
|
||||
faMugHot as faMugHotSolid,
|
||||
faMinus as faMinusSolid,
|
||||
faPaste as faPasteSolid,
|
||||
faPenToSquare as faPenToSquareSolid,
|
||||
faPlus as faPlusSolid,
|
||||
faReceipt as faReceiptSolid,
|
||||
faRss as faRssSolid,
|
||||
faUsers as faUsersSolid,
|
||||
faShare as faShareSolid,
|
||||
faSun as faSunSolid,
|
||||
faTrash as faTrashSolid,
|
||||
faTrashCan as faTrashCanSolid,
|
||||
faWallet as faWalletSolid,
|
||||
faXmark as faXmarkSolid,
|
||||
} from '@fortawesome/free-solid-svg-icons';
|
||||
import { demoFunc } from './dees-icon.demo.js';
|
||||
|
||||
export const faIcons = {
|
||||
// normal
|
||||
arrowRight: faArrowRightSolid,
|
||||
arrowUpRightFromSquare: faArrowUpRightFromSquareSolid,
|
||||
arrowUpRightFromSquareSolid: faArrowUpRightFromSquareSolid,
|
||||
bell: faBellSolid,
|
||||
bellSolid: faBellSolid,
|
||||
bug: faBugSolid,
|
||||
bugSolid: faBugSolid,
|
||||
building: faBuildingSolid,
|
||||
buildingSolid: faBuildingSolid,
|
||||
caretLeft: faCaretLeftSolid,
|
||||
caretLeftSolid: faCaretLeftSolid,
|
||||
caretRight: faCaretRightSolid,
|
||||
caretRightSolid: faCaretRightSolid,
|
||||
check: faCheckSolid,
|
||||
checkSolid: faCheckSolid,
|
||||
circleInfo: faCircleInfoSolid,
|
||||
circleInfoSolid: faCircleInfoSolid,
|
||||
circleCheck: faCircleCheckRegular,
|
||||
circleCheckSolid: faCircleCheckSolid,
|
||||
circleXmark: faCircleXmarkRegular,
|
||||
circleXmarkSolid: faCircleXmarkSolid,
|
||||
clockRotateLeft: faClockRotateLeftSolid,
|
||||
copy: faCopyRegular,
|
||||
copySolid: faCopySolid,
|
||||
desktop: faDesktopSolid,
|
||||
desktopSolid: faDesktopSolid,
|
||||
eye: faEyeSolid,
|
||||
eyeSolid: faEyeSolid,
|
||||
eyeSlash: faEyeSlashSolid,
|
||||
eyeSlashSolid: faEyeSlashSolid,
|
||||
fileInvoice: faFileInvoiceSolid,
|
||||
fileInvoiceDoller: faFileInvoiceDollarSolid,
|
||||
gear: faGearSolid,
|
||||
grip: faGripSolid,
|
||||
gripSolid: faGripSolid,
|
||||
message: faMessageRegular,
|
||||
messageSolid: faMessageSolid,
|
||||
moneyCheckDollar: faMoneyCheckDollarSolid,
|
||||
mugHot: faMugHotSolid,
|
||||
faMugHotSolid: faMugHotSolid,
|
||||
minus: faMinusSolid,
|
||||
minusSolid: faMinusSolid,
|
||||
paste: faPasteRegular,
|
||||
pasteSolid: faPasteSolid,
|
||||
penToSquare: faPenToSquareSolid,
|
||||
penToSquareSolid: faPenToSquareSolid,
|
||||
plus: faPlusSolid,
|
||||
receipt: faReceiptSolid,
|
||||
rss: faRssSolid,
|
||||
rssSolid: faRssSolid,
|
||||
share: faShareSolid,
|
||||
shareSolid: faShareSolid,
|
||||
sun: faSunRegular,
|
||||
sunSolid: faSunSolid,
|
||||
trash: faTrashSolid,
|
||||
trashSolid: faTrashSolid,
|
||||
trashCan: faTrashCanRegular,
|
||||
trashCanSolid: faTrashCanSolid,
|
||||
users: faUsersSolid,
|
||||
wallet: faWalletSolid,
|
||||
xmark: faXmarkSolid,
|
||||
xmarkSolid: faXmarkSolid,
|
||||
// brands
|
||||
facebook: faFacebook,
|
||||
google: faGoogle,
|
||||
@ -119,9 +126,10 @@ export const faIcons = {
|
||||
slack: faSlackHash,
|
||||
tiktok: faTiktok,
|
||||
twitter: faTwitter,
|
||||
users: faUsersSolid,
|
||||
};
|
||||
|
||||
export type TIconKey = keyof typeof faIcons;
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'dees-icon': DeesIcon;
|
||||
@ -130,24 +138,7 @@ declare global {
|
||||
|
||||
@customElement('dees-icon')
|
||||
export class DeesIcon extends DeesElement {
|
||||
public static demo = () => html`
|
||||
<dees-icon iconName="visibility"></dees-icon>
|
||||
<div style="background: #fff; padding: 10px; font-size: 30px">
|
||||
<style>
|
||||
dees-icon {
|
||||
transition: color 0.05s;
|
||||
}
|
||||
dees-icon:hover {
|
||||
color: #e4002b;
|
||||
}
|
||||
</style>
|
||||
<dees-icon .iconFA=${'messageSolid'}></dees-icon>
|
||||
<dees-icon .iconFA=${'sun'}></dees-icon>
|
||||
<dees-icon .iconFA=${'sunSolid'}></dees-icon>
|
||||
<dees-icon .iconFA=${'facebook'}></dees-icon>
|
||||
<dees-icon .iconFA=${'arrowUpRightFromSquare'}></dees-icon>
|
||||
</div>
|
||||
`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
@property({
|
||||
type: String
|
||||
|
@ -22,7 +22,7 @@ export class DeesInputCheckbox extends DeesElement {
|
||||
public static demo = () => html`<dees-input-checkbox></dees-input-checkbox>`;
|
||||
|
||||
// INSTANCE
|
||||
public changeSubject = new domtools.rxjs.Subject();
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
@ -62,7 +62,10 @@ export class DeesInputCheckbox extends DeesElement {
|
||||
display: block;
|
||||
position: relative;
|
||||
margin: 20px 0px;
|
||||
cursor: pointer;
|
||||
cursor: default;
|
||||
}
|
||||
:host(:hover) {
|
||||
filter: ${cssManager.bdTheme('brightness(0.95)', 'brightness(1.1)')};
|
||||
}
|
||||
|
||||
.maincontainer {
|
||||
@ -100,8 +103,8 @@ export class DeesInputCheckbox extends DeesElement {
|
||||
}
|
||||
|
||||
.checkbox.selected {
|
||||
background: #039BE5;
|
||||
border: 1px solid #039BE5;
|
||||
background: #0050b9;
|
||||
border: 1px solid #0050b9;
|
||||
}
|
||||
|
||||
.checkbox.disabled {
|
||||
|
27
ts_web/elements/dees-input-dropdown.demo.ts
Normal file
27
ts_web/elements/dees-input-dropdown.demo.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<dees-input-dropdown
|
||||
.options=${[
|
||||
{option: 'option 1', key: 'option1'},
|
||||
{option: 'option 2', key: 'option2'},
|
||||
{option: 'option 3', key: 'option3'}
|
||||
]}
|
||||
></dees-input-dropdown>
|
||||
<dees-input-dropdown
|
||||
.enableSearch=${false}
|
||||
.options=${[
|
||||
{option: 'option 1', key: 'option1'},
|
||||
{option: 'option 2', key: 'option2'},
|
||||
{option: 'option 3', key: 'option3'}
|
||||
]}
|
||||
></dees-input-dropdown>
|
||||
<div style="height: 300px"></div>
|
||||
<dees-input-dropdown
|
||||
.options=${[
|
||||
{option: 'option 1', key: 'option1'},
|
||||
{option: 'option 2', key: 'option2'},
|
||||
{option: 'option 3', key: 'option3'}
|
||||
]}
|
||||
></dees-input-dropdown>
|
||||
`
|
@ -1,5 +1,17 @@
|
||||
import { customElement, DeesElement, type TemplateResult, property, html, css, cssManager, type CSSResult, } from '@design.estate/dees-element';
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
type TemplateResult,
|
||||
property,
|
||||
state,
|
||||
html,
|
||||
css,
|
||||
cssManager,
|
||||
type CSSResult,
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { demoFunc } from './dees-input-dropdown.demo.js';
|
||||
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -9,18 +21,10 @@ declare global {
|
||||
|
||||
@customElement('dees-input-dropdown')
|
||||
export class DeesInputDropdown extends DeesElement {
|
||||
public static demo = () => html`
|
||||
<dees-input-dropdown
|
||||
.options=${[
|
||||
{option: 'option 1', key: 'option1'},
|
||||
{option: 'option 2', key: 'option2'},
|
||||
{option: 'option 3', key: 'option3'}
|
||||
]}
|
||||
></dees-input-dropdown>
|
||||
`
|
||||
public static demo = demoFunc;
|
||||
|
||||
// INSTANCE
|
||||
public changeSubject = new domtools.rxjs.Subject();
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
@ -32,145 +36,336 @@ export class DeesInputDropdown extends DeesElement {
|
||||
public key: string;
|
||||
|
||||
@property()
|
||||
public options: {option: string, key: string, payload?: any}[] = [];
|
||||
public options: { option: string; key: string; payload?: any }[] = [];
|
||||
|
||||
@property()
|
||||
public selectedOption: {option: string, key: string, payload?: any} = {
|
||||
key: null,
|
||||
option: null,
|
||||
payload: null
|
||||
};
|
||||
public selectedOption: { option: string; key: string; payload?: any } = null;
|
||||
|
||||
@property({
|
||||
type: Boolean
|
||||
type: Boolean,
|
||||
})
|
||||
public required: boolean = false;
|
||||
|
||||
@property({
|
||||
type: Boolean
|
||||
type: Boolean,
|
||||
})
|
||||
public enableSearch: boolean = true;
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
})
|
||||
public disabled: boolean = false;
|
||||
|
||||
@state()
|
||||
public opensToTop: boolean = false;
|
||||
|
||||
@state()
|
||||
private filteredOptions: { option: string; key: string; payload?: any }[] = [];
|
||||
|
||||
@state()
|
||||
private highlightedIndex: number = 0;
|
||||
|
||||
@state()
|
||||
public isOpened = false;
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host {
|
||||
position: relative;
|
||||
display: block;
|
||||
height: 40px;
|
||||
color: ${cssManager.bdTheme('#222', '#fff')};
|
||||
}
|
||||
:host {
|
||||
font-family: Roboto;
|
||||
position: relative;
|
||||
display: block;
|
||||
color: ${cssManager.bdTheme('#222', '#fff')};
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.maincontainer {
|
||||
display: block;
|
||||
}
|
||||
.maincontainer {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.label {
|
||||
font-size: 14px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.selectedBox {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
max-width: 420px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding: 0px 8px;
|
||||
z-index: 0px;
|
||||
background: ${cssManager.bdTheme('#ffffff', '#333333')};
|
||||
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
||||
border-radius: 3px;
|
||||
border-top: 1px solid #CCCCCC00;
|
||||
border-bottom: 1px solid #66666600;
|
||||
}
|
||||
.selectedBox {
|
||||
user-select: none;
|
||||
position: relative;
|
||||
max-width: 420px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding: 0px 8px;
|
||||
background: ${cssManager.bdTheme('#fafafa', '#222222')};
|
||||
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
||||
border-radius: 3px;
|
||||
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #333')};
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.selectedBox.show {
|
||||
border-top: 1px solid ${cssManager.bdTheme('#ffffff', '#666666')};
|
||||
border-bottom: 1px solid ${cssManager.bdTheme('#fafafa', '#222222')};
|
||||
}
|
||||
.selectedBox:hover {
|
||||
filter: ${cssManager.bdTheme('brightness(0.95)', 'brightness(1.1)')};
|
||||
}
|
||||
|
||||
.selectionBox {
|
||||
will-change:transform;
|
||||
pointer-events: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
opacity: 0;
|
||||
position: relative;
|
||||
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
||||
max-width: 420px;
|
||||
box-shadow: 0px 0px 5px rgba(0,0,0,0.2);
|
||||
min-height: 40px;
|
||||
margin-top: -40px;
|
||||
z-index: 100;
|
||||
border-radius: 3px;
|
||||
padding: 4px;
|
||||
transform: scale(0.99,0.99);
|
||||
}
|
||||
.accentBottom {
|
||||
filter: none !important;
|
||||
}
|
||||
|
||||
.selectionBox.show {
|
||||
pointer-events: all;
|
||||
opacity: 1;
|
||||
transform: scale(1,1);
|
||||
}
|
||||
.accentTop {
|
||||
filter: none !important;
|
||||
}
|
||||
|
||||
.option {
|
||||
transition: all 0.1s;
|
||||
line-height: 40px;
|
||||
padding: 0px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.selectionBox {
|
||||
will-change: transform;
|
||||
pointer-events: none;
|
||||
transition: all 0.2s ease;
|
||||
opacity: 0;
|
||||
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
||||
max-width: 420px;
|
||||
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
|
||||
min-height: 40px;
|
||||
border-radius: 8px;
|
||||
padding: 4px 8px;
|
||||
position: absolute;
|
||||
user-select: none;
|
||||
}
|
||||
.selectionBox.top {
|
||||
transform: translate(0px, 4px);
|
||||
}
|
||||
.selectionBox.bottom {
|
||||
transform: translate(0px, -4px);
|
||||
}
|
||||
|
||||
.option:hover {
|
||||
color: #fff;
|
||||
padding-left: 8px;
|
||||
background: #0277bd;
|
||||
}
|
||||
`
|
||||
]
|
||||
.selectionBox.show {
|
||||
pointer-events: all;
|
||||
transform: scale(1, 1) translate(0px, 0px);
|
||||
opacity: 1;
|
||||
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.option {
|
||||
transition: all 0.1s;
|
||||
line-height: 32px;
|
||||
padding: 0px 4px;
|
||||
border-radius: 3px;
|
||||
margin: 4px 0px;
|
||||
}
|
||||
|
||||
.option.highlighted {
|
||||
border-left: 2px solid #0069f2;
|
||||
padding-left: 6px;
|
||||
background: #ffffff20;
|
||||
}
|
||||
|
||||
.option:hover {
|
||||
color: #fff;
|
||||
padding-left: 8px;
|
||||
background: #0069f2;
|
||||
}
|
||||
|
||||
.search.top {
|
||||
padding-top: 4px;
|
||||
}
|
||||
.search.bottom {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.search input {
|
||||
display: block;
|
||||
background: none;
|
||||
border: none;
|
||||
height: 24px;
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.search.top input {
|
||||
border-bottom: 1px dotted #333;
|
||||
}
|
||||
.search.bottom input {
|
||||
border-top: 1px dotted #333;
|
||||
}
|
||||
|
||||
.search input:focus {
|
||||
outline: none;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
${domtools.elementBasic.styles}
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<div class="maincontainer">
|
||||
<div class="selectedBox show" @click="${event => {this.toggleSelectionBox();}}">
|
||||
${this.selectedOption?.option}
|
||||
</div>
|
||||
<div class="maincontainer" @keydown="${this.isOpened ? this.handleKeyDown : undefined}">
|
||||
${this.label ? html`<div class="label">${this.label}</div>` : html``}
|
||||
<div class="selectionBox">
|
||||
${this.options.map(option => {
|
||||
${this.enableSearch && !this.opensToTop
|
||||
? html`
|
||||
<div class="search top">
|
||||
<input type="text" placeholder="Search" @input="${this.handleSearch}" />
|
||||
</div>
|
||||
`
|
||||
: null}
|
||||
${this.filteredOptions.map((option, index) => {
|
||||
const isHighlighted = this.highlightedIndex === index;
|
||||
return html`
|
||||
<div class="option" @click=${() => {this.updateSelection(option);}}>${option.option}</div>
|
||||
`
|
||||
<div
|
||||
class="option ${isHighlighted ? 'highlighted' : ''}"
|
||||
@click=${() => {
|
||||
this.updateSelection(option);
|
||||
}}
|
||||
>
|
||||
${option.option}
|
||||
</div>
|
||||
`;
|
||||
})}
|
||||
${this.enableSearch && this.opensToTop
|
||||
? html`
|
||||
<div class="search bottom">
|
||||
<input type="text" placeholder="Search" @input="${this.handleSearch}" />
|
||||
</div>
|
||||
`
|
||||
: null}
|
||||
</div>
|
||||
<div
|
||||
class="selectedBox"
|
||||
@click="${(event) => {
|
||||
if (!this.isElevated) {
|
||||
this.toggleSelectionBox();
|
||||
} else {
|
||||
this.updateSelection(this.selectedOption);
|
||||
}
|
||||
}}"
|
||||
>
|
||||
${this.selectedOption?.option || 'Select...'}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
firstUpdated() {
|
||||
this.selectedOption = this.options[0] || null;
|
||||
this.selectedOption = this.selectedOption || null;
|
||||
this.filteredOptions = this.options; // Initialize filteredOptions
|
||||
}
|
||||
|
||||
public async updateSelection(selectedOption) {
|
||||
this.selectedOption = selectedOption;
|
||||
|
||||
this.dispatchEvent(new CustomEvent('selectedOption', {
|
||||
detail: selectedOption,
|
||||
bubbles: true
|
||||
}));
|
||||
this.toggleSelectionBox();
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('selectedOption', {
|
||||
detail: selectedOption,
|
||||
bubbles: true,
|
||||
})
|
||||
);
|
||||
if (this.isElevated) {
|
||||
this.toggleSelectionBox();
|
||||
}
|
||||
this.changeSubject.next(this);
|
||||
}
|
||||
|
||||
public toggleSelectionBox() {
|
||||
this.shadowRoot.querySelector('.selectedBox').classList.toggle('show');
|
||||
this.shadowRoot.querySelector('.selectionBox').classList.toggle('show');
|
||||
private isElevated: boolean = false;
|
||||
private windowOverlay: DeesWindowLayer;
|
||||
public async toggleSelectionBox() {
|
||||
this.isOpened = !this.isOpened;
|
||||
const domtoolsInstance = await this.domtoolsPromise;
|
||||
const selectedBox: HTMLElement = this.shadowRoot.querySelector('.selectedBox');
|
||||
const selectionBox: HTMLElement = this.shadowRoot.querySelector('.selectionBox');
|
||||
if (!this.isElevated) {
|
||||
this.windowOverlay = await DeesWindowLayer.createAndShow({
|
||||
blur: false,
|
||||
});
|
||||
const elevatedDropdown = new DeesInputDropdown();
|
||||
elevatedDropdown.isElevated = true;
|
||||
elevatedDropdown.label = this.label;
|
||||
elevatedDropdown.enableSearch = this.enableSearch;
|
||||
elevatedDropdown.required = this.required;
|
||||
elevatedDropdown.disabled = this.disabled;
|
||||
elevatedDropdown.style.position = 'fixed';
|
||||
elevatedDropdown.style.top = this.getBoundingClientRect().top + 'px';
|
||||
elevatedDropdown.style.left = this.getBoundingClientRect().left + 'px';
|
||||
elevatedDropdown.style.width = this.clientWidth + 'px';
|
||||
elevatedDropdown.options = this.options;
|
||||
elevatedDropdown.selectedOption = this.selectedOption;
|
||||
elevatedDropdown.highlightedIndex = elevatedDropdown.selectedOption ? elevatedDropdown.options.indexOf(
|
||||
elevatedDropdown.options.find((option) => option.key === this.selectedOption.key)
|
||||
) : -1;
|
||||
console.log(elevatedDropdown.options);
|
||||
console.log(elevatedDropdown.selectedOption);
|
||||
console.log(elevatedDropdown.highlightedIndex);
|
||||
this.windowOverlay.appendChild(elevatedDropdown);
|
||||
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
||||
elevatedDropdown.toggleSelectionBox();
|
||||
const destroyOverlay = async () => {
|
||||
(elevatedDropdown.shadowRoot.querySelector('.selectionBox') as HTMLElement).style.opacity =
|
||||
'0';
|
||||
elevatedDropdown.removeEventListener('selectedOption', handleSelection);
|
||||
this.windowOverlay.removeEventListener('clicked', destroyOverlay);
|
||||
this.windowOverlay.destroy();
|
||||
};
|
||||
const handleSelection = async (event) => {
|
||||
await this.updateSelection(elevatedDropdown.selectedOption);
|
||||
destroyOverlay();
|
||||
};
|
||||
elevatedDropdown.addEventListener('selectedOption', handleSelection);
|
||||
this.windowOverlay.addEventListener('clicked', destroyOverlay);
|
||||
} else {
|
||||
if (!selectionBox.classList.contains('show')) {
|
||||
selectionBox.style.width = selectedBox.clientWidth + 'px';
|
||||
const spaceData = selectedBox.getBoundingClientRect();
|
||||
if (300 > window.innerHeight - spaceData.bottom) {
|
||||
this.opensToTop = true;
|
||||
selectedBox.classList.add('accentTop');
|
||||
selectionBox.classList.add('top');
|
||||
selectionBox.style.bottom = selectedBox.clientHeight + 2 + 'px';
|
||||
} else {
|
||||
selectedBox.classList.add('accentBottom');
|
||||
selectionBox.classList.add('bottom');
|
||||
this.opensToTop = false;
|
||||
const labelOffset = this.label ? 24 : 0;
|
||||
selectionBox.style.top = selectedBox.clientHeight + labelOffset + 'px';
|
||||
}
|
||||
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
||||
const searchInput = selectionBox.querySelector('input');
|
||||
searchInput?.focus();
|
||||
selectionBox.classList.add('show');
|
||||
} else {
|
||||
selectedBox.style.pointerEvents = 'none';
|
||||
selectionBox.classList.remove('show');
|
||||
// selectedBox.style.opacity = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private handleSearch(event: Event): void {
|
||||
const searchTerm = (event.target as HTMLInputElement).value.toLowerCase();
|
||||
this.filteredOptions = this.options.filter((option) =>
|
||||
option.option.toLowerCase().includes(searchTerm)
|
||||
);
|
||||
this.highlightedIndex = 0; // Reset highlighted index
|
||||
}
|
||||
|
||||
private handleKeyDown(event: KeyboardEvent): void {
|
||||
if (!this.isOpened) {
|
||||
console.log('discarded key event. Check why this function is called.');
|
||||
return;
|
||||
}
|
||||
const key = event.key;
|
||||
const maxIndex = this.filteredOptions.length - 1;
|
||||
|
||||
if (key === 'ArrowDown') {
|
||||
this.highlightedIndex = this.highlightedIndex + 1 > maxIndex ? 0 : this.highlightedIndex + 1;
|
||||
event.preventDefault();
|
||||
} else if (key === 'ArrowUp') {
|
||||
this.highlightedIndex = this.highlightedIndex - 1 < 0 ? maxIndex : this.highlightedIndex - 1;
|
||||
event.preventDefault();
|
||||
} else if (key === 'Enter') {
|
||||
this.updateSelection(this.filteredOptions[this.highlightedIndex]);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,9 @@ import {
|
||||
unsafeCSS,
|
||||
cssManager,
|
||||
type CSSResult,
|
||||
domtools,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'dees-input-fileupload': DeesInputFileupload;
|
||||
@ -23,7 +22,7 @@ export class DeesInputFileupload extends DeesElement {
|
||||
public static demo = () => html`<dees-input-fileupload .label=${'Attachments'}></dees-input-fileupload>`;
|
||||
|
||||
// INSTANCE
|
||||
public changeSubject = new domtools.rxjs.Subject();
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
@ -89,7 +88,6 @@ export class DeesInputFileupload extends DeesElement {
|
||||
|
||||
.uploadButton {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
padding: 8px;
|
||||
max-width: 600px;
|
||||
background: ${cssManager.bdTheme('#fafafa', '#333333')};
|
||||
@ -124,7 +122,7 @@ export class DeesInputFileupload extends DeesElement {
|
||||
border-bottom: 1px dashed #444;
|
||||
color: ${cssManager.bdTheme('#666', '#ccc')};
|
||||
padding: 8px;
|
||||
font-family: 'Mona Sans', 'Inter', sans-serif;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.uploadButton:hover .uploadCandidate {
|
||||
|
3
ts_web/elements/dees-input-iban.demo.ts
Normal file
3
ts_web/elements/dees-input-iban.demo.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`<dees-input-iban .label=${'IBAN'}></dees-input-iban>`;
|
98
ts_web/elements/dees-input-iban.ts
Normal file
98
ts_web/elements/dees-input-iban.ts
Normal file
@ -0,0 +1,98 @@
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
type TemplateResult,
|
||||
state,
|
||||
html,
|
||||
domtools,
|
||||
property,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import * as ibantools from 'ibantools';
|
||||
import { demoFunc } from './dees-input-iban.demo.js';
|
||||
|
||||
@customElement('dees-input-iban')
|
||||
export class DeesInputIban extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = demoFunc;
|
||||
|
||||
// INSTANCE
|
||||
@state()
|
||||
enteredString: string = '';
|
||||
|
||||
@state()
|
||||
enteredIbanIsValid: boolean = false;
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
})
|
||||
public disabled = false;
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
})
|
||||
public required = false;
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
public label = '';
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
public key = '';
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
public value = '';
|
||||
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject<DeesInputIban>();
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
<style>
|
||||
input[type='text'] {
|
||||
line-height: 20px;
|
||||
padding: 5px;
|
||||
width: 250px;
|
||||
}
|
||||
</style>
|
||||
<dees-input-text
|
||||
.label=${'IBAN'}
|
||||
.value=${this.value}
|
||||
@input=${(eventArg: InputEvent) => {
|
||||
this.validateIban(eventArg);
|
||||
}}
|
||||
></dees-input-text>
|
||||
`;
|
||||
}
|
||||
|
||||
public async firstUpdated() {
|
||||
const deesInputText = this.shadowRoot.querySelector('dees-input-text');
|
||||
deesInputText.disabled = this.disabled;
|
||||
deesInputText.required = this.required;
|
||||
deesInputText.changeSubject.subscribe(valueArg => {
|
||||
this.value = valueArg.value;
|
||||
this.changeSubject.next(this);
|
||||
})
|
||||
}
|
||||
|
||||
public async validateIban(eventArg: InputEvent): Promise<void> {
|
||||
const inputElement: HTMLInputElement = eventArg.target as HTMLInputElement;
|
||||
let enteredString = inputElement?.value;
|
||||
enteredString = enteredString || '';
|
||||
if (this.enteredString !== enteredString) {
|
||||
this.enteredString = ibantools.friendlyFormatIBAN(enteredString) || '';
|
||||
if (inputElement) {
|
||||
inputElement.value = this.enteredString;
|
||||
this.value = this.enteredString;
|
||||
this.changeSubject.next(this);
|
||||
}
|
||||
}
|
||||
this.enteredIbanIsValid = ibantools.isValidIBAN(this.enteredString.replace(/ /g, ''));
|
||||
const deesInputText = this.shadowRoot.querySelector('dees-input-text');
|
||||
deesInputText.validationText = `IBAN is valid: ${this.enteredIbanIsValid}`;
|
||||
}
|
||||
}
|
14
ts_web/elements/dees-input-multitoggle.demo.ts
Normal file
14
ts_web/elements/dees-input-multitoggle.demo.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<dees-input-multitoggle
|
||||
.options=${['option 1', 'option 2', 'a longer option with multiple words']}
|
||||
.selectedOption=${'option 2'}
|
||||
></dees-input-multitoggle>
|
||||
<dees-input-multitoggle
|
||||
.type=${'boolean'}
|
||||
.booleanTrueName=${'enabled'}
|
||||
.booleanFalseName=${'disabled'}
|
||||
.selectedOption=${'true'}
|
||||
></dees-input-multitoggle>
|
||||
`;
|
121
ts_web/elements/dees-input-multitoggle.ts
Normal file
121
ts_web/elements/dees-input-multitoggle.ts
Normal file
@ -0,0 +1,121 @@
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
type TemplateResult,
|
||||
state,
|
||||
html,
|
||||
domtools,
|
||||
property,
|
||||
css,
|
||||
cssManager,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
const { demoFunc } = await import('./dees-input-multitoggle.demo.js');
|
||||
|
||||
@customElement('dees-input-multitoggle')
|
||||
export class DeesInputMultitoggle extends DeesElement {
|
||||
public static demo = demoFunc;
|
||||
|
||||
@property()
|
||||
type: 'boolean' | 'multi' | 'single' = 'multi';
|
||||
|
||||
@property()
|
||||
booleanTrueName: string = 'true';
|
||||
|
||||
@property()
|
||||
booleanFalseName: string = 'false';
|
||||
|
||||
@property({
|
||||
type: Array,
|
||||
})
|
||||
options: string[] = [];
|
||||
|
||||
@property()
|
||||
selectedOption: string = '';
|
||||
|
||||
@property()
|
||||
boolValue: boolean = false;
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
:host {
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
user-select: none;
|
||||
}
|
||||
.selections {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
background: #333;
|
||||
width: min-content;
|
||||
border-radius: 20px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.option {
|
||||
color: #CCC;
|
||||
position: relative;
|
||||
padding: 0px 16px;
|
||||
line-height: 40px;
|
||||
cursor: default;
|
||||
width: min-content; /* Make the width as per the content */
|
||||
white-space: nowrap; /* Prevent text wrapping */
|
||||
transition: all 0.1s;
|
||||
}
|
||||
|
||||
.option:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.indicator {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
height: 32px;
|
||||
left: 4px;
|
||||
top: 4px;
|
||||
border-radius: 16px;
|
||||
background: #0050b9;
|
||||
min-width: 36px;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
<div class="label">MultiSelect</div>
|
||||
<div class="mainbox">
|
||||
<div class="selections">
|
||||
<div class="indicator"></div>
|
||||
${this.options.map((option) => html` <div class="option" @click=${() => this.handleSelection(option)}>${option}</div> `)}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
public async firstUpdated() {
|
||||
if (this.type === 'boolean') {
|
||||
this.options = [this.booleanTrueName || 'true', this.booleanFalseName || 'false'];
|
||||
}
|
||||
this.setIndicator();
|
||||
}
|
||||
|
||||
public async handleSelection(optionArg: string) {
|
||||
this.selectedOption = optionArg;
|
||||
this.setIndicator();
|
||||
}
|
||||
|
||||
public async setIndicator() {
|
||||
const indicator: HTMLDivElement = this.shadowRoot.querySelector('.indicator');
|
||||
const option: HTMLDivElement = this.shadowRoot.querySelector(`.option:nth-child(${this.options.indexOf(this.selectedOption) + 2})`);
|
||||
if (indicator && option) {
|
||||
indicator.style.width = `${option.clientWidth - 8}px`;
|
||||
indicator.style.left = `${option.offsetLeft + 4}px`;
|
||||
indicator.style.opacity = '1';
|
||||
}
|
||||
setTimeout(() => {
|
||||
indicator.style.transition = 'all 0.1s';
|
||||
}, 100);
|
||||
}
|
||||
}
|
3
ts_web/elements/dees-input-phone.demo.ts
Normal file
3
ts_web/elements/dees-input-phone.demo.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`<dees-input-phone .label=${'Phone Number'}></dees-input-phone>`;
|
29
ts_web/elements/dees-input-phone.ts
Normal file
29
ts_web/elements/dees-input-phone.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
type TemplateResult,
|
||||
property,
|
||||
html,
|
||||
css,
|
||||
unsafeCSS,
|
||||
cssManager,
|
||||
type CSSResult,
|
||||
} from '@design.estate/dees-element';
|
||||
import { demoFunc } from './dees-input-phone.demo.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'dees-input-phone': DeesInputPhone;
|
||||
}
|
||||
}
|
||||
|
||||
@customElement('dees-input-phone')
|
||||
export class DeesInputPhone extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = demoFunc;
|
||||
|
||||
// INSTANCE
|
||||
public render() {
|
||||
return html`<div>Phone Input</div>`;
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ export class DeesInputQuantitySelector extends DeesElement {
|
||||
public static demo = () => html`<dees-input-quantityselector></dees-input-quantityselector>`;
|
||||
|
||||
// INSTANCE
|
||||
public changeSubject = new domtools.rxjs.Subject();
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||
|
||||
@property()
|
||||
public label: string = 'Label';
|
||||
@ -85,7 +85,6 @@ export class DeesInputQuantitySelector extends DeesElement {
|
||||
}
|
||||
|
||||
.selector:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.quantity {
|
||||
|
@ -12,7 +12,7 @@ export class DeesInputRadio extends DeesElement {
|
||||
public static demo = () => html`<dees-input-radio></dees-input-radio>`;
|
||||
|
||||
// INSTANCE
|
||||
public changeSubject = new domtools.rxjs.Subject();
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
@ -51,7 +51,6 @@ export class DeesInputRadio extends DeesElement {
|
||||
display: block;
|
||||
position: relative;
|
||||
margin: 20px 0px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.maincontainer {
|
||||
@ -91,8 +90,8 @@ export class DeesInputRadio extends DeesElement {
|
||||
}
|
||||
|
||||
.checkbox.selected {
|
||||
background: #039BE5;
|
||||
border: 1px solid #039BE5;
|
||||
background: #0050b9;
|
||||
border: 1px solid #0050b9;
|
||||
}
|
||||
|
||||
.maincontainer:hover .checkbox.selected {
|
||||
|
0
ts_web/elements/dees-input-searchselect.ts
Normal file
0
ts_web/elements/dees-input-searchselect.ts
Normal file
0
ts_web/elements/dees-input-tags.ts
Normal file
0
ts_web/elements/dees-input-tags.ts
Normal file
@ -1,4 +1,13 @@
|
||||
import {customElement, DeesElement, type TemplateResult, property, html, cssManager, type CSSResult,} from '@design.estate/dees-element';
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
type TemplateResult,
|
||||
property,
|
||||
html,
|
||||
cssManager,
|
||||
css,
|
||||
type CSSResult,
|
||||
} from '@design.estate/dees-element';
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
declare global {
|
||||
@ -15,11 +24,10 @@ export class DeesInputText extends DeesElement {
|
||||
`;
|
||||
|
||||
// INSTANCE
|
||||
public changeSubject = new domtools.rxjs.Subject<DeesInputText>();
|
||||
public valueChangeSubject = new domtools.rxjs.Subject<string>();
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject<DeesInputText>();
|
||||
|
||||
@property({
|
||||
type: String
|
||||
type: String,
|
||||
})
|
||||
public label: string;
|
||||
|
||||
@ -36,12 +44,12 @@ export class DeesInputText extends DeesElement {
|
||||
public value: string = '';
|
||||
|
||||
@property({
|
||||
type: Boolean
|
||||
type: Boolean,
|
||||
})
|
||||
public required: boolean = false;
|
||||
|
||||
@property({
|
||||
type: Boolean
|
||||
type: Boolean,
|
||||
})
|
||||
public disabled: boolean = false;
|
||||
|
||||
@ -57,93 +65,165 @@ export class DeesInputText extends DeesElement {
|
||||
})
|
||||
public showPasswordBool = false;
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
reflect: true,
|
||||
})
|
||||
public validationState: 'valid' | 'warn' | 'invalid';
|
||||
|
||||
@property({
|
||||
reflect: true,
|
||||
})
|
||||
public validationText: string = '';
|
||||
|
||||
@property({})
|
||||
validationFunction: (value: string) => boolean;
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host {
|
||||
position: relative;
|
||||
display: grid;
|
||||
margin: 8px 0px;
|
||||
margin-bottom: 24px;
|
||||
z-index: auto;
|
||||
}
|
||||
|
||||
.maincontainer {
|
||||
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
input {
|
||||
margin-top: 5px;
|
||||
background: ${cssManager.bdTheme('#fafafa', '#222')};
|
||||
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #333')};
|
||||
border-right: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||
border-left: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 2px;
|
||||
width: 100%;
|
||||
line-height: 36px;
|
||||
transition: all 0.2s;
|
||||
outline: none;
|
||||
font-size: 16px;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
background: ${cssManager.bdTheme('#ffffff00', '#11111100')};
|
||||
border: 1px dashed ${cssManager.bdTheme('#666666', '#666666')};
|
||||
color: #9b9b9e;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-bottom: 1px solid #e4002b;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
input:hover {
|
||||
filter: ${cssManager.bdTheme('brightness(0.95)', 'brightness(1.1)')};
|
||||
}
|
||||
|
||||
.showPassword {
|
||||
position: absolute;
|
||||
bottom: 7px;
|
||||
right: 10px;
|
||||
border: 1px dashed #444;
|
||||
border-radius: 7px;
|
||||
padding: 4px 0px;
|
||||
width: 40px;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.showPassword:hover {
|
||||
background: ${cssManager.bdTheme('#00000010', '#ffffff10')};
|
||||
}
|
||||
|
||||
.validationContainer {
|
||||
text-align: center;
|
||||
padding: 6px 2px 2px 2px;
|
||||
margin-top: -4px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background: #e4002b;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
border-radius: 3px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html `
|
||||
return html`
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:host {
|
||||
position: relative;
|
||||
display: grid;
|
||||
margin: 10px 0px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.maincontainer {
|
||||
color: ${this.goBright ? '#333' : '#ccc'};
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
input {
|
||||
margin-top: 5px;
|
||||
background: ${this.goBright ? '#fafafa' : '#222'};
|
||||
border-top: ${this.goBright ? '1px solid #CCC' : '1px solid #444'};
|
||||
border-bottom: ${this.goBright ? '1px solid #CCC' : '1px solid #333'};
|
||||
border-right: ${this.goBright ? '1px solid #CCC' : 'none'};
|
||||
border-left: ${this.goBright ? '1px solid #CCC' : 'none'};
|
||||
padding-left:10px;
|
||||
padding-right: 10px;
|
||||
border-radius: 2px;
|
||||
width: 100%;
|
||||
line-height: 48px;
|
||||
transition: all 0.2s;
|
||||
outline: none;
|
||||
font-size: 16px;
|
||||
font-family: ${this.isPasswordBool ? 'monospace': 'Inter'};
|
||||
letter-spacing: ${this.isPasswordBool ? '1px': 'normal'};
|
||||
font-family: ${this.isPasswordBool ? 'monospace' : 'Roboto'};
|
||||
letter-spacing: ${this.isPasswordBool ? '1px' : 'normal'};
|
||||
color: ${this.goBright ? '#333' : '#ccc'};
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
background: ${cssManager.bdTheme('#ffffff00', '#11111100')};
|
||||
border: 1px dashed ${cssManager.bdTheme('#666666', '#666666')};
|
||||
color: #9b9b9e;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-bottom: 1px solid #e4002b;
|
||||
}
|
||||
|
||||
.showPassword {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
right: 10px;
|
||||
border: 1px dashed #444;
|
||||
border-radius: 7px;
|
||||
padding: 8px 0px;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.showPassword:hover {
|
||||
cursor: pointer;
|
||||
background: #333;
|
||||
}
|
||||
${this.validationText ? css`
|
||||
.validationContainer {
|
||||
height: 22px;
|
||||
opacity: 1;
|
||||
}
|
||||
` : css`
|
||||
.validationContainer {
|
||||
height: 4px;
|
||||
padding: 2px !important;
|
||||
opacity: 0;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
<div class="maincontainer">
|
||||
${this.label ? html`<div class="label">${this.label}</div>` : html``}
|
||||
<input type="${this.isPasswordBool && !this.showPasswordBool ? 'password' : 'text'}" value=${this.value} @input="${this.updateValue}" .disabled=${this.disabled} />
|
||||
${this.isPasswordBool ? html`
|
||||
<div class="showPassword" @click=${this.togglePasswordView}>
|
||||
<dees-icon .iconFA=${this.showPasswordBool ? 'eye' : 'eyeSlash'}></dees-icon>
|
||||
</div>
|
||||
` : html``}
|
||||
<input
|
||||
type="${this.isPasswordBool && !this.showPasswordBool ? 'password' : 'text'}"
|
||||
.value=${this.value}
|
||||
@input="${this.updateValue}"
|
||||
.disabled=${this.disabled}
|
||||
/>
|
||||
<div class="validationContainer">
|
||||
${this.validationText}
|
||||
</div>
|
||||
${this.isPasswordBool
|
||||
? html`
|
||||
<div class="showPassword" @click=${this.togglePasswordView}>
|
||||
<dees-icon .iconFA=${this.showPasswordBool ? 'eye' : 'eyeSlash'}></dees-icon>
|
||||
</div>
|
||||
`
|
||||
: html``}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
firstUpdated() {
|
||||
const input = this.shadowRoot.querySelector('input');
|
||||
input.addEventListener('input', (eventArg: InputEvent) => {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public async updateValue(eventArg: Event) {
|
||||
const target: any = eventArg.target;
|
||||
this.value = target.value;
|
||||
this.changeSubject.next(this);
|
||||
this.valueChangeSubject.next(this.value);
|
||||
}
|
||||
|
||||
public async freeze() {
|
||||
@ -154,10 +234,10 @@ export class DeesInputText extends DeesElement {
|
||||
this.disabled = false;
|
||||
}
|
||||
|
||||
public async togglePasswordView () {
|
||||
public async togglePasswordView() {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
this.showPasswordBool = !this.showPasswordBool;
|
||||
console.log(`this.showPasswordBool is: ${this.showPasswordBool}`)
|
||||
console.log(`this.showPasswordBool is: ${this.showPasswordBool}`);
|
||||
}
|
||||
|
||||
public async focus() {
|
||||
|
15
ts_web/elements/dees-input-typelist.demo.ts
Normal file
15
ts_web/elements/dees-input-typelist.demo.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<style>
|
||||
.demoContainer {
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
padding: 40px;
|
||||
background: #000;
|
||||
}
|
||||
</style>
|
||||
<div class="demoContainer">
|
||||
<dees-input-typelist></dees-input-typelist>
|
||||
</div>
|
||||
`;
|
88
ts_web/elements/dees-input-typelist.ts
Normal file
88
ts_web/elements/dees-input-typelist.ts
Normal file
@ -0,0 +1,88 @@
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
type TemplateResult,
|
||||
state,
|
||||
html,
|
||||
domtools,
|
||||
property,
|
||||
css,
|
||||
cssManager,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
const { demoFunc } = await import('./dees-input-typelist.demo.js');
|
||||
|
||||
@customElement('dees-input-typelist')
|
||||
export class DeesInputTypelist extends DeesElement {
|
||||
public static demo = demoFunc;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
:host {
|
||||
color: ${cssManager.bdTheme('#333', '#fff')}
|
||||
}
|
||||
.label {
|
||||
font-size: 14px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.mainbox {
|
||||
border-radius: 3px;
|
||||
background: #222;
|
||||
overflow: hidden;
|
||||
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #333')};
|
||||
border-right: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||
border-left: ${cssManager.bdTheme('1px solid #CCC', 'none')};
|
||||
}
|
||||
|
||||
.tags {
|
||||
padding: 16px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.notags {
|
||||
text-align: center;
|
||||
opacity: 0.5;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
input {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
background: #181818;
|
||||
width: 100%;
|
||||
outline: none;
|
||||
border: none;
|
||||
color: inherit;
|
||||
padding: 0px 16px;
|
||||
overflow: hidden;
|
||||
line-height: 32px;
|
||||
height: 0px;
|
||||
transition: height 0.2s;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
height: 32px;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
<div class="label">Type List</div>
|
||||
<div class="mainbox">
|
||||
<div class="tags" @click=${() => {
|
||||
this.shadowRoot.querySelector('input').focus();
|
||||
}}>
|
||||
<div class="notags">No tags yet</div>
|
||||
</div>
|
||||
<input type="text" placeholder="Type, press Enter to add it..." />
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as plugins from './00plugins.js';
|
||||
import {
|
||||
cssManager,
|
||||
css,
|
||||
@ -15,26 +15,21 @@ import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||
export class DeesMobilenavigation extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = () => html`
|
||||
<dees-mobilenavigation
|
||||
.menuItems="${[
|
||||
<dees-button @click=${() => {
|
||||
DeesMobilenavigation.createAndShow([
|
||||
{
|
||||
name: 'hello1',
|
||||
action: async () => {},
|
||||
name: 'Test',
|
||||
action: async (deesMobileNav) => {
|
||||
alert('test');
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'hello2',
|
||||
action: async () => {},
|
||||
},
|
||||
{
|
||||
name: 'hello3',
|
||||
action: async () => {},
|
||||
},
|
||||
]}"
|
||||
></dees-mobilenavigation>
|
||||
]);
|
||||
}}></dees-button>
|
||||
`;
|
||||
|
||||
private static singletonRef: DeesMobilenavigation;
|
||||
public static async createAndInit(menuItemsArg: plugins.tsclass.website.IMenuItem[]) {
|
||||
public static async createAndShow(menuItemsArg: plugins.tsclass.website.IMenuItem<DeesMobilenavigation>[]) {
|
||||
if (!this.singletonRef) {
|
||||
this.singletonRef = new DeesMobilenavigation();
|
||||
document.body.append(this.singletonRef);
|
||||
@ -94,8 +89,8 @@ export class DeesMobilenavigation extends DeesElement {
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#000')};;
|
||||
border-left: 1px dashed #444;
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#000')};
|
||||
border-left: 1px solid ${cssManager.bdTheme('#eeeeeb', '#222')};
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@ -110,7 +105,6 @@ export class DeesMobilenavigation extends DeesElement {
|
||||
padding: 8px;
|
||||
margin-left: -8px;
|
||||
margin-right: -8px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.menuItem:hover {
|
||||
@ -121,7 +115,7 @@ export class DeesMobilenavigation extends DeesElement {
|
||||
text-align: left;
|
||||
font-size: 24px;
|
||||
padding: 8px 0px;
|
||||
font-family: 'Mona Sans', 'Inter', sans-serif;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
font-weight: 300;
|
||||
border-bottom: 1px dashed #444;
|
||||
margin-top: 16px;
|
||||
@ -140,7 +134,7 @@ export class DeesMobilenavigation extends DeesElement {
|
||||
class="menuItem"
|
||||
@click="${() => {
|
||||
this.hide();
|
||||
menuItem.action();
|
||||
menuItem.action(this);
|
||||
}}"
|
||||
>
|
||||
${menuItem.name}
|
||||
@ -161,6 +155,7 @@ export class DeesMobilenavigation extends DeesElement {
|
||||
const main = this.shadowRoot.querySelector('.main');
|
||||
if (!this.windowLayer) {
|
||||
this.windowLayer = new DeesWindowLayer();
|
||||
this.windowLayer.options.blur = true;
|
||||
this.windowLayer.addEventListener('click', () => {
|
||||
this.hide();
|
||||
});
|
||||
|
37
ts_web/elements/dees-modal.demo.ts
Normal file
37
ts_web/elements/dees-modal.demo.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
import { DeesModal } from './dees-modal.js';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<dees-button @click=${() => {
|
||||
DeesModal.createAndShow({
|
||||
heading: 'This is a heading',
|
||||
content: html`
|
||||
<dees-form>
|
||||
<dees-input-text
|
||||
.label=${'Username'}
|
||||
>
|
||||
</dees-input-text>
|
||||
<dees-input-text
|
||||
.label=${'Password'}
|
||||
>
|
||||
</dees-input-text>
|
||||
</dees-form>
|
||||
`,
|
||||
menuOptions: [{
|
||||
name: 'Cancel',
|
||||
iconName: null,
|
||||
action: async (deesModalArg) => {
|
||||
deesModalArg.destroy();
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
name: 'Ok',
|
||||
iconName: null,
|
||||
action: async (deesModalArg) => {
|
||||
deesModalArg.destroy();
|
||||
return null;
|
||||
}
|
||||
}],
|
||||
});
|
||||
}}>open modal</dees-button>
|
||||
`
|
196
ts_web/elements/dees-modal.ts
Normal file
196
ts_web/elements/dees-modal.ts
Normal file
@ -0,0 +1,196 @@
|
||||
import * as plugins from './00plugins.js';
|
||||
import { demoFunc } from './dees-modal.demo.js';
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
DeesElement,
|
||||
property,
|
||||
type TemplateResult,
|
||||
cssManager,
|
||||
css,
|
||||
type CSSResult,
|
||||
unsafeCSS,
|
||||
unsafeHTML,
|
||||
state,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'dees-modal': DeesModal;
|
||||
}
|
||||
}
|
||||
|
||||
@customElement('dees-modal')
|
||||
export class DeesModal extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = demoFunc;
|
||||
|
||||
public static async createAndShow(optionsArg: {
|
||||
heading: string;
|
||||
content: TemplateResult;
|
||||
menuOptions: plugins.tsclass.website.IMenuItem<DeesModal>[];
|
||||
}) {
|
||||
const body = document.body;
|
||||
const modal = new DeesModal();
|
||||
modal.heading = optionsArg.heading;
|
||||
modal.content = optionsArg.content;
|
||||
modal.menuOptions = optionsArg.menuOptions;
|
||||
modal.windowLayer = await DeesWindowLayer.createAndShow({
|
||||
blur: true,
|
||||
});
|
||||
modal.windowLayer.addEventListener('click', async () => {
|
||||
await modal.destroy();
|
||||
});
|
||||
body.append(modal.windowLayer);
|
||||
body.append(modal);
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
public heading = '';
|
||||
|
||||
@state({})
|
||||
public content: TemplateResult;
|
||||
|
||||
@state({})
|
||||
public menuOptions: plugins.tsclass.website.IMenuItem<DeesModal>[] = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
:host {
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
will-change: transform;
|
||||
}
|
||||
.modalContainer {
|
||||
display: flex;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2000;
|
||||
}
|
||||
.modal {
|
||||
will-change: transform;
|
||||
transform: translateY(0px) scale(0.95);
|
||||
opacity: 0;
|
||||
width: 480px;
|
||||
min-height: 120px;
|
||||
background: #111;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #222;
|
||||
transition: all 0.2s;
|
||||
overflow: hidden;
|
||||
box-shadow: 0px 2px 5px #00000080;
|
||||
}
|
||||
|
||||
.modal.show {
|
||||
opacity: 1;
|
||||
transform: translateY(0px) scale(1);
|
||||
}
|
||||
|
||||
.modal.show.predestroy {
|
||||
opacity: 0;
|
||||
transform: translateY(10px) scale(1);
|
||||
}
|
||||
|
||||
.modal .heading {
|
||||
height: 32px;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid #222;
|
||||
}
|
||||
|
||||
.modal .content {
|
||||
padding: 16px;
|
||||
}
|
||||
.modal .bottomButtons {
|
||||
display: grid;
|
||||
border-top: 1px solid #222;
|
||||
}
|
||||
|
||||
.modal .bottomButtons .bottomButton {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
border-right: 1px solid #222;
|
||||
}
|
||||
.modal .bottomButtons .bottomButton:hover {
|
||||
background: #222;
|
||||
}
|
||||
.modal .bottomButtons .bottomButton:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
<style>
|
||||
.modal .bottomButtons {
|
||||
grid-template-columns: ${cssManager.cssGridColumns(this.menuOptions.length, 0)};
|
||||
}
|
||||
</style>
|
||||
<div class="modalContainer" @click=${this.handleOutsideClick}>
|
||||
<div class="modal">
|
||||
<div class="heading">${this.heading}</div>
|
||||
<div class="content">${this.content}</div>
|
||||
<div class="bottomButtons">
|
||||
${this.menuOptions.map(
|
||||
(actionArg) => html`
|
||||
<div class="bottomButton" @click=${() => {
|
||||
actionArg.action(this);
|
||||
}}>${actionArg.name}</div>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
private windowLayer: DeesWindowLayer;
|
||||
public async firstUpdated(_changedProperties: Map<string | number | symbol, unknown>) {
|
||||
super.firstUpdated(_changedProperties);
|
||||
const domtools = await this.domtoolsPromise;
|
||||
await domtools.convenience.smartdelay.delayFor(30);
|
||||
const modal = this.shadowRoot.querySelector('.modal');
|
||||
modal.classList.add('show');
|
||||
}
|
||||
|
||||
public async handleOutsideClick(eventArg: MouseEvent) {
|
||||
eventArg.stopPropagation();
|
||||
const modalContainer = this.shadowRoot.querySelector('.modalContainer');
|
||||
if (eventArg.target === modalContainer) {
|
||||
await this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public async destroy() {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
const modal = this.shadowRoot.querySelector('.modal');
|
||||
modal.classList.add('predestroy');
|
||||
await domtools.convenience.smartdelay.delayFor(200);
|
||||
document.body.removeChild(this);
|
||||
await this.windowLayer.destroy();
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ import { DeesElement, property, html, customElement, domtools, type TemplateResu
|
||||
|
||||
import { Deferred } from '@push.rocks/smartpromise';
|
||||
|
||||
import type pdfjsTypes from 'pdfjs-dist';
|
||||
// import type pdfjsTypes from 'pdfjs-dist';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -32,7 +32,7 @@ export class DeesPdf extends DeesElement {
|
||||
return html`
|
||||
<style>
|
||||
:host {
|
||||
font-family: 'Mona Sans', 'Inter', sans-serif;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
max-width: 800px;
|
||||
@ -51,24 +51,15 @@ export class DeesPdf extends DeesElement {
|
||||
}
|
||||
|
||||
public static pdfJsReady: Promise<any>;
|
||||
public static pdfjsLib: typeof pdfjsTypes;
|
||||
public static pdfjsLib: any // typeof pdfjsTypes;
|
||||
public async connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (!DeesPdf.pdfJsReady) {
|
||||
const pdfJsReadyDeferred = domtools.plugins.smartpromise.defer();
|
||||
DeesPdf.pdfJsReady = pdfJsReadyDeferred.promise;
|
||||
const loadDeferred = domtools.plugins.smartpromise.defer();
|
||||
const script = document.createElement('script');
|
||||
script.addEventListener('load', () => {
|
||||
console.log('pdf.js loaded!');
|
||||
loadDeferred.resolve();
|
||||
});
|
||||
script.src = 'https:////mozilla.github.io/pdf.js/build/pdf.js';
|
||||
document.getElementsByTagName('head')[0].appendChild(script);
|
||||
// The workerSrc property shall be specified.
|
||||
await loadDeferred.promise;
|
||||
DeesPdf.pdfjsLib = window['pdfjs-dist/build/pdf'];
|
||||
DeesPdf.pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
|
||||
// @ts-ignore
|
||||
DeesPdf.pdfjsLib = await import('https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/+esm');
|
||||
DeesPdf.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/build/pdf.worker.mjs';
|
||||
pdfJsReadyDeferred.resolve();
|
||||
}
|
||||
await DeesPdf.pdfJsReady;
|
||||
|
11
ts_web/elements/dees-progressbar.demo.ts
Normal file
11
ts_web/elements/dees-progressbar.demo.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
import { DeesProgressbar } from './dees-progressbar.js';
|
||||
|
||||
export const demoFunc = () => {
|
||||
return html`
|
||||
<dees-progressbar
|
||||
.percentage=${50}
|
||||
></dees-progressbar>
|
||||
`;
|
||||
}
|
95
ts_web/elements/dees-progressbar.ts
Normal file
95
ts_web/elements/dees-progressbar.ts
Normal file
@ -0,0 +1,95 @@
|
||||
import * as plugins from './00plugins.js';
|
||||
import * as colors from './00colors.js';
|
||||
import { demoFunc } from './dees-progressbar.demo.js';
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
DeesElement,
|
||||
property,
|
||||
type TemplateResult,
|
||||
cssManager,
|
||||
css,
|
||||
type CSSResult,
|
||||
unsafeCSS,
|
||||
unsafeHTML,
|
||||
state,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
@customElement('dees-progressbar')
|
||||
export class DeesProgressbar extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = demoFunc;
|
||||
|
||||
// INSTANCE
|
||||
@property({
|
||||
type: Number,
|
||||
})
|
||||
public percentage = 0;
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
:host {
|
||||
color: ${cssManager.bdTheme(colors.bright.text, colors.dark.text)};
|
||||
}
|
||||
.progressBarContainer {
|
||||
padding: 8px;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.progressBar {
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#444')};
|
||||
height: 8px;
|
||||
width: 100%;
|
||||
border-radius: 4px;
|
||||
border-top: 0.5px solid ${cssManager.bdTheme('none', '#555')};
|
||||
}
|
||||
|
||||
.progressBarFill {
|
||||
background: ${cssManager.bdTheme(colors.dark.blueActive, colors.bright.blueActive)};
|
||||
height: 8px;
|
||||
margin-top: -0.5px;
|
||||
transition: 0.2s width;
|
||||
border-radius: 4px;
|
||||
width: 0px;
|
||||
border-top: 0.5 solid ${cssManager.bdTheme('none', '#398fff')};
|
||||
}
|
||||
|
||||
.progressText {
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
`
|
||||
];
|
||||
|
||||
public render() {
|
||||
return html`
|
||||
<div class="progressBarContainer">
|
||||
<div class="progressBar">
|
||||
<div class="progressBarFill"></div>
|
||||
<div class="progressText">
|
||||
${this.percentage}%
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
firstUpdated (_changedProperties: Map<string | number | symbol, unknown>): void {
|
||||
super.firstUpdated(_changedProperties);
|
||||
this.updateComplete.then(() => {
|
||||
this.updatePercentage();
|
||||
});
|
||||
}
|
||||
|
||||
public async updatePercentage() {
|
||||
const progressBarFill = this.shadowRoot.querySelector('.progressBarFill') as HTMLElement;
|
||||
progressBarFill.style.width = `${this.percentage}%`;
|
||||
}
|
||||
|
||||
updated(){
|
||||
this.updatePercentage();
|
||||
}
|
||||
}
|
5
ts_web/elements/dees-simple-appdash.demo.ts
Normal file
5
ts_web/elements/dees-simple-appdash.demo.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<dees-simple-appdash>Hello there</dees-simple-appdash>
|
||||
`;
|
74
ts_web/elements/dees-simple-appdash.ts
Normal file
74
ts_web/elements/dees-simple-appdash.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import { demoFunc } from './dees-simple-appdash.demo.js';
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
DeesElement,
|
||||
property,
|
||||
type TemplateResult,
|
||||
cssManager,
|
||||
css,
|
||||
unsafeCSS,
|
||||
type CSSResult,
|
||||
state,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'dees-simple-appdash': DeesSimpleAppDash;
|
||||
}
|
||||
}
|
||||
|
||||
@customElement('dees-simple-appdash')
|
||||
export class DeesSimpleAppDash extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = demoFunc;
|
||||
// INSTANCE
|
||||
|
||||
@property()
|
||||
public name = 'Dees Simple Login';
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
:host {
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
user-select: none;
|
||||
}
|
||||
.appbar {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 40px;
|
||||
width: 100%;
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#000')};
|
||||
border-bottom: 1px solid ${cssManager.bdTheme('#ccc', '#333')};
|
||||
font-size: 14px;
|
||||
line-height: 40px;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
padding: 0px 16px;
|
||||
}
|
||||
.appcontent {
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#000')};
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
<div class="appbar">
|
||||
configvault v1.2.3
|
||||
</div>
|
||||
<div class="appcontent">
|
||||
<slot></slot>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
public async firstUpdated(_changedProperties): Promise<void> {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
super.firstUpdated(_changedProperties);
|
||||
}
|
||||
}
|
3
ts_web/elements/dees-simple-login.demo.ts
Normal file
3
ts_web/elements/dees-simple-login.demo.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = () => html` <dees-simple-login name="someapp"> Hello there </dees-simple-login> `;
|
@ -1,3 +1,5 @@
|
||||
import { demoFunc } from './dees-simple-login.demo.js';
|
||||
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
@ -20,12 +22,11 @@ declare global {
|
||||
@customElement('dees-simple-login')
|
||||
export class DeesSimpleLogin extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = () => html` <dees-simple-login></dees-simple-login> `;
|
||||
|
||||
public static demo = demoFunc
|
||||
// INSTANCE
|
||||
|
||||
@property()
|
||||
public title = 'Dees Simple Login';
|
||||
public name = 'Dees Simple Login';
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
@ -35,9 +36,11 @@ export class DeesSimpleLogin extends DeesElement {
|
||||
user-select: none;
|
||||
}
|
||||
.loginContainer {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
justify-content: center; /* aligns horizontally */
|
||||
align-items: center; /* aligns vertically */
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.login {
|
||||
@ -45,13 +48,19 @@ export class DeesSimpleLogin extends DeesElement {
|
||||
min-height: 100px;
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#111')};
|
||||
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
||||
border-radius: 3px;
|
||||
border-radius: 8px;
|
||||
padding: 24px;
|
||||
transition: opacity 0.3s, transform 0.3s;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
}
|
||||
.slotContainer {
|
||||
opacity:0;
|
||||
transition: opacity 0.3s, transform 0.3s;
|
||||
pointer-events: none;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@ -60,14 +69,16 @@ export class DeesSimpleLogin extends DeesElement {
|
||||
<div class="loginContainer">
|
||||
<div class="login">
|
||||
<dees-form>
|
||||
<div class="header">Login to ${this.title}</div>
|
||||
<div class="header">Login to ${this.name}</div>
|
||||
<dees-input-text key="username" label="username" required></dees-input-text>
|
||||
<dees-input-text key="password" label="password" isPasswordBool required></dees-input-text>
|
||||
<dees-form-submit disabled>login</dees-form-submit>
|
||||
</dees-form>
|
||||
</div>
|
||||
</div>
|
||||
<slot></slot>
|
||||
<div class="slotContainer">
|
||||
<slot></slot>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
@ -81,6 +92,29 @@ export class DeesSimpleLogin extends DeesElement {
|
||||
const submit = this.shadowRoot.querySelector('dees-form-submit');
|
||||
form.addEventListener('formData', (event: CustomEvent) => {
|
||||
this.dispatchEvent(new CustomEvent('login', { detail: event.detail }));
|
||||
// this.switchToSlottedContent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* allows switching to slotted content
|
||||
*/
|
||||
public async switchToSlottedContent() {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
const loginDiv: HTMLDivElement = this.shadowRoot.querySelector('.login');
|
||||
const loginContainerDiv: HTMLDivElement = this.shadowRoot.querySelector('.loginContainer');
|
||||
const slotContainerDiv: HTMLDivElement = this.shadowRoot.querySelector('.slotContainer');
|
||||
loginDiv.style.opacity = '0';
|
||||
loginDiv.style.transform = 'translateY(20px)';
|
||||
loginContainerDiv.style.pointerEvents = 'none';
|
||||
slotContainerDiv.style.transform = 'translateY(20px)';
|
||||
await domtools.convenience.smartdelay.delayFor(300);
|
||||
slotContainerDiv.style.opacity = '1';
|
||||
slotContainerDiv.style.transform = 'translateY(0px)';
|
||||
await domtools.convenience.smartdelay.delayFor(300);
|
||||
slotContainerDiv.style.pointerEvents = 'all';
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ export class DeesSpeechbubble extends DeesElement {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
:host([hidden]) {
|
||||
|
@ -99,7 +99,7 @@ export class DeesStepper extends DeesElement {
|
||||
transition: all 0.7s ease-in-out;
|
||||
max-width: 500px;
|
||||
min-height: 300px;
|
||||
border-radius: 3px;
|
||||
border-radius: 8px;
|
||||
background: ${cssManager.bdTheme('#ffffff', '#181818')};
|
||||
border-top: 1px solid ${cssManager.bdTheme('#ffffff', '#181818')};
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
@ -127,6 +127,7 @@ export class DeesStepper extends DeesElement {
|
||||
}
|
||||
|
||||
.step .stepCounter {
|
||||
color: #999;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
@ -137,6 +138,8 @@ export class DeesStepper extends DeesElement {
|
||||
}
|
||||
|
||||
.step .goBack {
|
||||
color: #999;
|
||||
cursor: default;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
@ -144,7 +147,6 @@ export class DeesStepper extends DeesElement {
|
||||
font-size: 12px;
|
||||
border-bottom-right-radius: 3px;
|
||||
background: ${cssManager.bdTheme('#00000008', '#ffffff08')};
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.step .goBack:hover {
|
||||
@ -154,7 +156,7 @@ export class DeesStepper extends DeesElement {
|
||||
.step .title {
|
||||
text-align: center;
|
||||
padding-top: 50px;
|
||||
font-family: 'Mona Sans', 'Inter', sans-serif;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
font-size: 25px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
129
ts_web/elements/dees-table.demo.ts
Normal file
129
ts_web/elements/dees-table.demo.ts
Normal file
@ -0,0 +1,129 @@
|
||||
import { type ITableAction } from './dees-table.js';
|
||||
import * as plugins from './00plugins.js';
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
interface ITableDemoData {
|
||||
date: string;
|
||||
amount: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const demoFunc = () => html`
|
||||
<style>
|
||||
.demoWrapper {
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
background: #000000;
|
||||
}
|
||||
</style>
|
||||
<div class="demoWrapper">
|
||||
<dees-table
|
||||
heading1="Current Account Statement"
|
||||
heading2="Bunq - Payment Account 2 - April 2021"
|
||||
.editableFields="${['description']}"
|
||||
.data=${[
|
||||
{
|
||||
date: '2021-04-01',
|
||||
amount: '2464.65 €',
|
||||
description: 'Printing Paper (Office Supplies) - STAPLES BREMEN',
|
||||
},
|
||||
{
|
||||
date: '2021-04-02',
|
||||
amount: '165.65 €',
|
||||
description: 'Logitech Mouse (Hardware) - logi.com OnlineShop',
|
||||
},
|
||||
{
|
||||
date: '2021-04-03',
|
||||
amount: '2999,00 €',
|
||||
description: 'Macbook Pro 16inch (Hardware) - Apple.de OnlineShop',
|
||||
},
|
||||
{
|
||||
date: '2021-04-01',
|
||||
amount: '2464.65 €',
|
||||
description: 'Office-Supplies - STAPLES BREMEN',
|
||||
},
|
||||
{
|
||||
date: '2021-04-01',
|
||||
amount: '2464.65 €',
|
||||
description: 'Office-Supplies - STAPLES BREMEN',
|
||||
},
|
||||
]}
|
||||
dataName="transactions"
|
||||
.dataActions="${[
|
||||
{
|
||||
name: 'upload',
|
||||
iconName: 'bell',
|
||||
useTableBehaviour: 'upload',
|
||||
type: ['inRow'],
|
||||
actionFunc: async (optionsArg) => {
|
||||
alert(optionsArg.item.amount);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'visibility',
|
||||
iconName: 'copy',
|
||||
type: ['inRow'],
|
||||
useTableBehaviour: 'preview',
|
||||
actionFunc: async (itemArg: any) => {},
|
||||
},
|
||||
{
|
||||
name: 'create new',
|
||||
iconName: 'instagram',
|
||||
type: ['header'],
|
||||
useTableBehaviour: 'preview',
|
||||
actionFunc: async (itemArg: any) => {},
|
||||
},
|
||||
{
|
||||
name: 'to gallery',
|
||||
iconName: 'message',
|
||||
type: ['footer'],
|
||||
useTableBehaviour: 'preview',
|
||||
actionFunc: async (itemArg: any) => {},
|
||||
},
|
||||
{
|
||||
name: 'copy',
|
||||
iconName: 'copySolid',
|
||||
type: ['contextmenu', 'inRow'],
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'edit (from demo)',
|
||||
iconName: 'penToSquare',
|
||||
type: ['contextmenu'],
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'paste',
|
||||
iconName: 'pasteSolid',
|
||||
type: ['contextmenu'],
|
||||
action: async () => {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'preview',
|
||||
type: ['doubleClick', 'contextmenu'],
|
||||
iconName: 'eye',
|
||||
actionFunc: async (itemArg) => {
|
||||
alert(itemArg.item.amount);
|
||||
return null;
|
||||
},
|
||||
}
|
||||
] as (ITableAction<ITableDemoData>)[] as any}"
|
||||
.displayFunction=${(itemArg) => {
|
||||
return {
|
||||
...itemArg,
|
||||
onlyDisplayProp: 'onlyDisplay',
|
||||
};
|
||||
}}
|
||||
>This is a slotted Text</dees-table
|
||||
>
|
||||
</div>
|
||||
`;
|
@ -1,3 +1,5 @@
|
||||
import * as plugins from './00plugins.js';
|
||||
import { demoFunc } from './dees-table.demo.js';
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
@ -9,9 +11,13 @@ import {
|
||||
unsafeCSS,
|
||||
type CSSResult,
|
||||
state,
|
||||
resolveExec,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
import { DeesContextmenu } from './dees-contextmenu.js';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { type TIconKey } from './dees-icon.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -19,75 +25,52 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export interface IDataAction<T = any> {
|
||||
// interfaces
|
||||
export interface ITableAction<T = any> {
|
||||
name: string;
|
||||
iconName: string;
|
||||
iconName: TIconKey;
|
||||
/**
|
||||
* the table behaviour to use for this action
|
||||
* e.g. upload: allows to upload files to the table
|
||||
*/
|
||||
useTableBehaviour?: 'upload' | 'cancelUpload' | 'none';
|
||||
actionFunc: (itemArg: T) => Promise<any>;
|
||||
/**
|
||||
* the type of the action
|
||||
*/
|
||||
type: (
|
||||
| 'inRow'
|
||||
| 'contextmenu'
|
||||
| 'doubleClick'
|
||||
| 'footer'
|
||||
| 'header'
|
||||
| 'preview'
|
||||
| 'keyCombination'
|
||||
)[];
|
||||
/**
|
||||
* allows to check if the action is relevant for the given item
|
||||
* @param itemArg
|
||||
* @returns
|
||||
*/
|
||||
actionRelevancyCheckFunc?: (itemArg: T) => boolean;
|
||||
/**
|
||||
* the actual action function implementation
|
||||
* @param itemArg
|
||||
* @returns
|
||||
*/
|
||||
actionFunc: (actionDataArg: ITableActionDataArg<T>) => Promise<any>;
|
||||
}
|
||||
|
||||
export interface ITableActionDataArg<T> {
|
||||
item: T;
|
||||
table: DeesTable<T>;
|
||||
}
|
||||
|
||||
export type TDisplayFunction<T = any> = (itemArg: T) => object;
|
||||
|
||||
// the table implementation
|
||||
@customElement('dees-table')
|
||||
export class DeesTable<T> extends DeesElement {
|
||||
public static demo = () => html`
|
||||
<style>
|
||||
.demoWrapper {
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 60px;
|
||||
background: #000000;
|
||||
}
|
||||
</style>
|
||||
<div class="demoWrapper">
|
||||
<dees-table
|
||||
heading1="Current Account Statement"
|
||||
heading2="Bunq - Payment Account 2 - April 2021"
|
||||
.data=${[
|
||||
{
|
||||
date: '2021-04-01',
|
||||
amount: '2464.65 €',
|
||||
description: 'Printing Paper (Office Supplies) - STAPLES BREMEN',
|
||||
},
|
||||
{
|
||||
date: '2021-04-02',
|
||||
amount: '165.65 €',
|
||||
description: 'Logitech Mouse (Hardware) - logi.com OnlineShop',
|
||||
},
|
||||
{
|
||||
date: '2021-04-03',
|
||||
amount: '2999,00 €',
|
||||
description: 'Macbook Pro 16inch (Hardware) - Apple.de OnlineShop',
|
||||
},
|
||||
{
|
||||
date: '2021-04-01',
|
||||
amount: '2464.65 €',
|
||||
description: 'Office-Supplies - STAPLES BREMEN',
|
||||
},
|
||||
{
|
||||
date: '2021-04-01',
|
||||
amount: '2464.65 €',
|
||||
description: 'Office-Supplies - STAPLES BREMEN',
|
||||
},
|
||||
]}
|
||||
.dataActions="${[{
|
||||
name: 'upload',
|
||||
iconName: 'upload',
|
||||
useTableBehaviour: 'upload',
|
||||
actionFunc: async (itemArg: any) => {
|
||||
|
||||
},
|
||||
},{
|
||||
name: 'visibility',
|
||||
iconName: 'visibility',
|
||||
useTableBehaviour: 'preview',
|
||||
actionFunc: async (itemArg: any) => {
|
||||
|
||||
},
|
||||
}] as IDataAction[]}"
|
||||
>This is a slotted Text</dees-table>
|
||||
</div>
|
||||
`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
// INSTANCE
|
||||
@property({
|
||||
@ -105,10 +88,54 @@ export class DeesTable<T> extends DeesElement {
|
||||
})
|
||||
public data: T[] = [];
|
||||
|
||||
// dees-form compatibility -----------------------------------------
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
public key: string;
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
public label: string;
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
})
|
||||
public disabled: boolean = false;
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
})
|
||||
public required: boolean = false;
|
||||
|
||||
get value() {
|
||||
return this.data;
|
||||
}
|
||||
set value(valueArg) {}
|
||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject<DeesTable<T>>();
|
||||
// end dees-form compatibility -----------------------------------------
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
reflect: true,
|
||||
})
|
||||
public dataName: string;
|
||||
|
||||
@property({
|
||||
type: Array,
|
||||
})
|
||||
public dataActions: IDataAction[] = [];
|
||||
public dataActions: ITableAction<T>[] = [];
|
||||
|
||||
@property({
|
||||
attribute: false,
|
||||
})
|
||||
public displayFunction: TDisplayFunction = (itemArg: T) => itemArg as any;
|
||||
|
||||
@property({
|
||||
attribute: false,
|
||||
})
|
||||
public reverseDisplayFunction: (itemArg: any) => T = (itemArg: any) => itemArg as T;
|
||||
|
||||
@property({
|
||||
type: Object,
|
||||
@ -116,18 +143,15 @@ export class DeesTable<T> extends DeesElement {
|
||||
public selectedDataRow: T;
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
type: Array,
|
||||
})
|
||||
public type: 'normal' | 'highlighted' | 'discreet' | 'big' = 'normal';
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
public status: 'normal' | 'pending' | 'success' | 'error' = 'normal';
|
||||
public editableFields: string[] = [];
|
||||
|
||||
public files: File[] = [];
|
||||
public fileWeakMap = new WeakMap();
|
||||
|
||||
public dataChangeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
@ -137,9 +161,9 @@ export class DeesTable<T> extends DeesElement {
|
||||
css`
|
||||
.mainbox {
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
font-family: 'Mona Sans', 'Inter', sans-serif;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
padding: 16px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
@ -150,11 +174,48 @@ export class DeesTable<T> extends DeesElement {
|
||||
box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.headingContainer {
|
||||
}
|
||||
|
||||
.heading {
|
||||
}
|
||||
|
||||
.heading1 {
|
||||
font-weight: 600;
|
||||
}
|
||||
.heading2 {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.headingSeparation {
|
||||
margin-top: 7px;
|
||||
border-bottom: 1px solid ${cssManager.bdTheme('#bcbcbc', '#bcbcbc')};
|
||||
}
|
||||
|
||||
.headerActions {
|
||||
margin-left: auto;
|
||||
}
|
||||
.headerAction {
|
||||
display: flex;
|
||||
color: ${cssManager.bdTheme('#333', '#ccc')};
|
||||
}
|
||||
|
||||
.headerAction:hover {
|
||||
color: ${cssManager.bdTheme('#555', '#fff')};
|
||||
}
|
||||
|
||||
.headerAction dees-icon {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
table,
|
||||
.noDataSet {
|
||||
margin-top: 16px;
|
||||
@ -174,10 +235,10 @@ export class DeesTable<T> extends DeesElement {
|
||||
text-align: left;
|
||||
}
|
||||
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;
|
||||
@ -185,19 +246,34 @@ export class DeesTable<T> extends DeesElement {
|
||||
tr:first-child:hover .innerCellContainer {
|
||||
background: none;
|
||||
}
|
||||
tr.selected .innerCellContainer {
|
||||
tr.selected td {
|
||||
background: ${cssManager.bdTheme('#22222220', '#ffffff20')};
|
||||
}
|
||||
|
||||
tr.hasAttachment td {
|
||||
background: ${cssManager.bdTheme('#0098847c', '#0098847c')};
|
||||
}
|
||||
|
||||
th {
|
||||
text-transform: uppercase;
|
||||
text-transform: none;
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
font-weight: 500;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 3px 0px;
|
||||
position: relative;
|
||||
vertical-align: top;
|
||||
|
||||
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 {
|
||||
@ -211,11 +287,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: ${cssManager.bdTheme('#333', '#fff')};
|
||||
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;
|
||||
}
|
||||
|
||||
@ -225,17 +319,40 @@ export class DeesTable<T> extends DeesElement {
|
||||
}
|
||||
|
||||
.action:hover {
|
||||
background: ${cssManager.bdTheme('#CCC', '#111')};
|
||||
background: ${cssManager.bdTheme('#CCC', '#00000030')};
|
||||
}
|
||||
|
||||
.tableStatistics {
|
||||
padding: 4px 16px;
|
||||
font-size: 12px;
|
||||
.footer {
|
||||
font-family: 'Roboto', 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
color: ${cssManager.bdTheme('#111', '#ffffff90')};
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#00000050')};
|
||||
margin: 16px -16px -16px -16px;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.tableStatistics {
|
||||
padding: 8px 16px;
|
||||
}
|
||||
|
||||
.footerActions {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.footerActions .footerAction {
|
||||
padding: 8px 16px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.footerActions .footerAction:hover {
|
||||
background: ${cssManager.bdTheme('#CCC', '#111')};
|
||||
}
|
||||
|
||||
.footerActions dees-icon {
|
||||
display: flex;
|
||||
margin-right: 8px;
|
||||
}
|
||||
`,
|
||||
];
|
||||
@ -244,15 +361,49 @@ export class DeesTable<T> extends DeesElement {
|
||||
return html`
|
||||
<div class="mainbox">
|
||||
<!-- the heading part -->
|
||||
<div>${this.heading1}</div>
|
||||
<div>${this.heading2}</div>
|
||||
<div class="header">
|
||||
<div class="headingContainer">
|
||||
<div class="heading heading1">${this.label || this.heading1}</div>
|
||||
<div class="heading heading2">${this.heading2}</div>
|
||||
</div>
|
||||
<div class="headerActions">
|
||||
${resolveExec(async () => {
|
||||
const resultArray: TemplateResult[] = [];
|
||||
for (const action of this.dataActions) {
|
||||
if (!action.type.includes('header')) continue;
|
||||
resultArray.push(
|
||||
html`<div
|
||||
class="headerAction"
|
||||
@click=${() => {
|
||||
action.actionFunc({
|
||||
item: this.selectedDataRow,
|
||||
table: this,
|
||||
});
|
||||
}}
|
||||
>
|
||||
${action.iconName
|
||||
? html`<dees-icon .iconSize=${14} .iconFA=${action.iconName}></dees-icon>
|
||||
${action.name}`
|
||||
: action.name}
|
||||
</div>`
|
||||
);
|
||||
}
|
||||
return resultArray;
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div class="headingSeparation"></div>
|
||||
|
||||
<dees-input-text></dees-input-text>
|
||||
|
||||
<!-- the actual table -->
|
||||
<style></style>
|
||||
${this.data.length > 0
|
||||
? (() => {
|
||||
const headings: string[] = Object.keys(this.data[0]);
|
||||
// Only pick up the keys from the first transformed data object
|
||||
// as all data objects are assumed to have the same structure
|
||||
const firstTransformedItem = this.displayFunction(this.data[0]);
|
||||
const headings: string[] = Object.keys(firstTransformedItem);
|
||||
return html`
|
||||
<table>
|
||||
<tr>
|
||||
@ -273,32 +424,42 @@ export class DeesTable<T> extends DeesElement {
|
||||
}
|
||||
})()}
|
||||
</tr>
|
||||
${this.data.map(
|
||||
(itemArg) => html`
|
||||
${this.data.map((itemArg) => {
|
||||
const transformedItem = this.displayFunction(itemArg);
|
||||
const getTr = (elementArg: HTMLElement): HTMLElement => {
|
||||
if (elementArg.tagName === 'TR') {
|
||||
return elementArg;
|
||||
} else {
|
||||
return getTr(elementArg.parentElement);
|
||||
}
|
||||
};
|
||||
return html`
|
||||
<tr
|
||||
@click=${() => {
|
||||
this.selectedDataRow = itemArg;
|
||||
}}
|
||||
@dragenter=${async (eventArg: DragEvent) => {
|
||||
console.log((eventArg.target as HTMLElement).tagName)
|
||||
console.log('dragenter');
|
||||
eventArg.preventDefault();
|
||||
eventArg.stopPropagation();
|
||||
(eventArg.target as HTMLElement).parentElement.style.background = '#800000';
|
||||
const realTarget = getTr(eventArg.target as HTMLElement);
|
||||
console.log('dragenter');
|
||||
console.log(realTarget);
|
||||
setTimeout(() => {
|
||||
realTarget.classList.add('hasAttachment');
|
||||
}, 0);
|
||||
}}
|
||||
@dragleave=${async (eventArg: DragEvent) => {
|
||||
console.log((eventArg.target as HTMLElement).tagName)
|
||||
console.log('dragleave');
|
||||
eventArg.preventDefault();
|
||||
eventArg.stopPropagation();
|
||||
(eventArg.target as HTMLElement).parentElement.style.background = 'none';
|
||||
const realTarget = getTr(eventArg.target as HTMLElement);
|
||||
realTarget.classList.remove('hasAttachment');
|
||||
}}
|
||||
@dragover=${async (eventArg: DragEvent) => {
|
||||
eventArg.preventDefault();
|
||||
}}
|
||||
@drop=${async (eventArg: DragEvent) => {
|
||||
eventArg.preventDefault();
|
||||
const newFiles = []
|
||||
const newFiles = [];
|
||||
for (const file of Array.from(eventArg.dataTransfer.files)) {
|
||||
this.files.push(file);
|
||||
newFiles.push(file);
|
||||
@ -306,17 +467,52 @@ export class DeesTable<T> extends DeesElement {
|
||||
}
|
||||
const result: File[] = this.fileWeakMap.get(itemArg as object);
|
||||
if (!result) {
|
||||
this.fileWeakMap.set(itemArg as object, newFiles)
|
||||
this.fileWeakMap.set(itemArg as object, newFiles);
|
||||
} else {
|
||||
result.push(...newFiles);
|
||||
}
|
||||
}}
|
||||
@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({
|
||||
item: itemArg,
|
||||
table: this,
|
||||
});
|
||||
return null;
|
||||
},
|
||||
};
|
||||
return menuItem;
|
||||
})
|
||||
);
|
||||
}}
|
||||
class="${itemArg === this.selectedDataRow ? 'selected' : ''}"
|
||||
>
|
||||
${headings.map(
|
||||
(headingArg) => html`
|
||||
<td>
|
||||
<div class="innerCellContainer">${itemArg[headingArg]}</div>
|
||||
<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({
|
||||
item: itemArg,
|
||||
table: this,
|
||||
});
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="innerCellContainer">${transformedItem[headingArg]}</div>
|
||||
</td>
|
||||
`
|
||||
)}
|
||||
@ -325,36 +521,167 @@ export class DeesTable<T> extends DeesElement {
|
||||
return html`
|
||||
<td>
|
||||
<div class="innerCellContainer">
|
||||
${(() => {
|
||||
const actions: TemplateResult[] = [];
|
||||
for (const action of this.dataActions) {
|
||||
actions.push(html`<div class="action">${action.iconName ? html`
|
||||
<dees-icon .iconName=${'upload_file'}></dees-icon>
|
||||
` : action.name}</div>`)
|
||||
}
|
||||
return actions;
|
||||
})()}
|
||||
${this.getActionsForType('inRow').map(
|
||||
(actionArg) => html`<div
|
||||
class="action"
|
||||
@click=${() =>
|
||||
actionArg.actionFunc({
|
||||
item: itemArg,
|
||||
table: this,
|
||||
})}
|
||||
>
|
||||
${actionArg.iconName
|
||||
? html`
|
||||
<dees-icon .iconFA=${actionArg.iconName}></dees-icon>
|
||||
`
|
||||
: actionArg.name}
|
||||
</div>`
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
})()}
|
||||
</tr>
|
||||
`
|
||||
)}
|
||||
`;
|
||||
})}
|
||||
</table>
|
||||
`;
|
||||
})()
|
||||
: html` <div class="noDataSet">No data set!</div> `}
|
||||
<div class="tableStatistics">
|
||||
${this.data.length} data rows (total) |
|
||||
${this.selectedDataRow
|
||||
? html`Row ${this.data.indexOf(this.selectedDataRow) + 1} selected`
|
||||
: html`No row selected`}
|
||||
<div class="footer">
|
||||
<div class="tableStatistics">
|
||||
${this.data.length} ${this.dataName || 'data rows'} (total) |
|
||||
${this.selectedDataRow ? '# ' + `${this.data.indexOf(this.selectedDataRow) + 1}` : `No`}
|
||||
selected
|
||||
</div>
|
||||
<div class="footerActions">
|
||||
${resolveExec(async () => {
|
||||
const resultArray: TemplateResult[] = [];
|
||||
for (const action of this.dataActions) {
|
||||
if (!action.type.includes('footer')) continue;
|
||||
resultArray.push(
|
||||
html`<div
|
||||
class="footerAction"
|
||||
@click=${() => {
|
||||
action.actionFunc({
|
||||
item: this.selectedDataRow,
|
||||
table: this,
|
||||
});
|
||||
}}
|
||||
>
|
||||
${action.iconName
|
||||
? html`<dees-icon .iconSize=${14} .iconFA=${action.iconName}></dees-icon>
|
||||
${action.name}`
|
||||
: action.name}
|
||||
</div>`
|
||||
);
|
||||
}
|
||||
return resultArray;
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
public async firstUpdated() {}
|
||||
|
||||
public async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
|
||||
super.updated(changedProperties);
|
||||
this.determineColumnWidths();
|
||||
}
|
||||
|
||||
public async determineColumnWidths() {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
await domtools.convenience.smartdelay.delayFor(0);
|
||||
// Get the table element
|
||||
const table = this.shadowRoot.querySelector('table');
|
||||
if (!table) return;
|
||||
|
||||
// Get the first row's cells to measure the widths
|
||||
const cells = table.rows[0].cells;
|
||||
|
||||
const handleColumnByIndex = async (i: number, waitForRenderArg: boolean = false) => {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const cell = cells[i];
|
||||
|
||||
// Get computed width
|
||||
const width = window.getComputedStyle(cell).width;
|
||||
if (cell.textContent.includes('Actions')) {
|
||||
const neededWidth =
|
||||
this.dataActions.filter((actionArg) => actionArg.type.includes('inRow')).length * 35;
|
||||
cell.style.width = `${Math.max(neededWidth, 68)}px`;
|
||||
} else {
|
||||
cell.style.width = width;
|
||||
}
|
||||
if (waitForRenderArg) {
|
||||
requestAnimationFrame(() => {
|
||||
done.resolve();
|
||||
});
|
||||
await done.promise;
|
||||
}
|
||||
};
|
||||
|
||||
if (cells[cells.length - 1].textContent.includes('Actions')) {
|
||||
await handleColumnByIndex(cells.length - 1, true);
|
||||
}
|
||||
|
||||
for (let i = 0; i < cells.length; i++) {
|
||||
if (cells[i].textContent.includes('Actions')) {
|
||||
continue;
|
||||
}
|
||||
await handleColumnByIndex(i);
|
||||
}
|
||||
table.style.tableLayout = 'fixed';
|
||||
}
|
||||
|
||||
getActionsForType(typeArg: ITableAction['type'][0]) {
|
||||
const actions: ITableAction[] = [];
|
||||
for (const action of this.dataActions) {
|
||||
if (!action.type.includes(typeArg)) continue;
|
||||
actions.push(action);
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
async handleCellEditing(event: Event, itemArg: T, key: string) {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
const target = event.target as HTMLElement;
|
||||
const originalColor = target.style.color;
|
||||
target.style.color = 'transparent';
|
||||
const transformedItem = this.displayFunction(itemArg);
|
||||
const initialValue = (transformedItem[key] as unknown as string) || '';
|
||||
// Create an input element
|
||||
const input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.value = initialValue;
|
||||
|
||||
const blurInput = async (blurArg = true, saveArg = false) => {
|
||||
if (blurArg) {
|
||||
input.blur();
|
||||
}
|
||||
if (saveArg) {
|
||||
itemArg[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
|
||||
this.changeSubject.next(this);
|
||||
}
|
||||
input.remove();
|
||||
target.style.color = originalColor;
|
||||
this.requestUpdate();
|
||||
};
|
||||
|
||||
// When the input loses focus or the Enter key is pressed, update the data
|
||||
input.addEventListener('blur', () => {
|
||||
blurInput(false, false);
|
||||
});
|
||||
input.addEventListener('keydown', (e: KeyboardEvent) => {
|
||||
if (e.key === 'Enter') {
|
||||
blurInput(true, true); // This will trigger the blur event handler above
|
||||
}
|
||||
});
|
||||
|
||||
// Replace the cell's content with the input
|
||||
target.appendChild(input);
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
|
5
ts_web/elements/dees-toast.demo.ts
Normal file
5
ts_web/elements/dees-toast.demo.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
export const demoFunc = async () => {
|
||||
return html`<dees-toast></dees-toast>`;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import { customElement, DeesElement, type TemplateResult, html, type CSSResult, } from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { demoFunc } from './dees-toast.demo.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -10,6 +11,7 @@ declare global {
|
||||
|
||||
@customElement('dees-toast')
|
||||
export class DeesToast extends DeesElement {
|
||||
public static demo = demoFunc;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
10
ts_web/elements/dees-updater.demo.ts
Normal file
10
ts_web/elements/dees-updater.demo.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { html } from '@design.estate/dees-element';
|
||||
|
||||
import { DeesUpdater } from './dees-updater.js';
|
||||
|
||||
export const demoFunc = async () => {
|
||||
const updater = await DeesUpdater.createAndShow();
|
||||
setTimeout(async () => {
|
||||
await updater.destroy();
|
||||
}, 10000);
|
||||
}
|
@ -1,7 +1,13 @@
|
||||
import { customElement, DeesElement, type TemplateResult, html, property, type CSSResult, } from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
type TemplateResult,
|
||||
html,
|
||||
property,
|
||||
type CSSResult,
|
||||
domtools,
|
||||
} from '@design.estate/dees-element';
|
||||
import { demoFunc } from './dees-updater.demo.js';
|
||||
|
||||
import './dees-windowlayer';
|
||||
import { css, cssManager } from '@design.estate/dees-element';
|
||||
@ -14,7 +20,13 @@ declare global {
|
||||
|
||||
@customElement('dees-updater')
|
||||
export class DeesUpdater extends DeesElement {
|
||||
public static demo = () => html`<dees-updater></dees-updater>`;
|
||||
public static demo = demoFunc;
|
||||
|
||||
public static async createAndShow() {
|
||||
const updater = new DeesUpdater();
|
||||
document.body.appendChild(updater);
|
||||
return updater;
|
||||
}
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
@ -35,56 +47,64 @@ export class DeesUpdater extends DeesElement {
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
.modalContainer {
|
||||
will-change: transform;
|
||||
position: relative;
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#222')};
|
||||
margin: auto;
|
||||
max-width: 800px;
|
||||
border-radius: 3px;
|
||||
border-top: 1px solid ${cssManager.bdTheme('#eeeeeb', '#333')};
|
||||
}
|
||||
will-change: transform;
|
||||
position: relative;
|
||||
background: ${cssManager.bdTheme('#eeeeeb', '#222')};
|
||||
max-width: 800px;
|
||||
border-radius: 8px;
|
||||
border-top: 1px solid ${cssManager.bdTheme('#eeeeeb', '#333')};
|
||||
}
|
||||
|
||||
.headingContainer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 40px 40px;
|
||||
}
|
||||
.headingContainer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 40px 40px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: none;
|
||||
font-size: 20px;
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
margin-left: 20px;
|
||||
font-weight: normal;
|
||||
}
|
||||
h1 {
|
||||
margin: none;
|
||||
font-size: 20px;
|
||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||
margin-left: 20px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.buttonContainer {
|
||||
display: grid;
|
||||
grid-template-columns: 50% 50%;
|
||||
}
|
||||
`
|
||||
]
|
||||
.buttonContainer {
|
||||
display: grid;
|
||||
grid-template-columns: 50% 50%;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
<dees-windowlayer @clicked="${this.windowLayerClicked}">
|
||||
<dees-windowlayer
|
||||
@clicked="${this.windowLayerClicked}"
|
||||
.options=${{
|
||||
blur: true,
|
||||
}}
|
||||
>
|
||||
<div class="modalContainer">
|
||||
<div class="headingContainer">
|
||||
<dees-spinner .size=${60}></dees-spinner>
|
||||
<h1>Updating the application...</h1>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<dees-progressbar .progress=${0.5}></dees-progressbar>
|
||||
</div>
|
||||
<div class="buttonContainer">
|
||||
<dees-button>More info</dees-button>
|
||||
<dees-button>Changelog</dees-button>
|
||||
</div>
|
||||
</div>
|
||||
</dees-windowlayer>>
|
||||
</div> </dees-windowlayer
|
||||
>>
|
||||
`;
|
||||
}
|
||||
|
||||
private windowLayerClicked() {
|
||||
const windowLayer = this.shadowRoot.querySelector('dees-windowlayer');
|
||||
windowLayer.toggleVisibility();
|
||||
public async destroy() {
|
||||
this.parentElement.removeChild(this);
|
||||
}
|
||||
|
||||
private windowLayerClicked() {}
|
||||
}
|
||||
|
99
ts_web/elements/dees-windowcontrols.ts
Normal file
99
ts_web/elements/dees-windowcontrols.ts
Normal file
@ -0,0 +1,99 @@
|
||||
import {
|
||||
customElement,
|
||||
DeesElement,
|
||||
domtools,
|
||||
type TemplateResult,
|
||||
html,
|
||||
property,
|
||||
type CSSResult,
|
||||
state,
|
||||
css,
|
||||
cssManager,
|
||||
} from '@design.estate/dees-element';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'dees-windowcontrols': DeesWindowControls;
|
||||
}
|
||||
}
|
||||
|
||||
@customElement('dees-windowcontrols')
|
||||
export class DeesWindowControls extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = () => html`<dees-windowcontrols></dees-windowcontrols>`;
|
||||
|
||||
// Instance
|
||||
@property({
|
||||
reflect: true,
|
||||
})
|
||||
public type: 'mac' | 'linux' | 'windows' = 'mac';
|
||||
|
||||
@property({
|
||||
reflect: true,
|
||||
})
|
||||
public position: 'left' | 'right' = 'left';
|
||||
|
||||
public static styles = [
|
||||
cssManager.defaultStyles,
|
||||
css`
|
||||
:host {
|
||||
position: relative;
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
}
|
||||
|
||||
.windowControls {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.windowControls div {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
display: inline-block;
|
||||
border-radius: 50%;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
background: #222222;
|
||||
}
|
||||
|
||||
.windowControls div.close {
|
||||
background: #ff5f57;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.windowControls div.toDock {
|
||||
background: #ffbd2e;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.windowControls div.minMax {
|
||||
background: #27c93f;
|
||||
}
|
||||
|
||||
.windowControls div:hover {
|
||||
background: #333333;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
return html`
|
||||
${(this.type === 'mac' && this.position === 'left') ||
|
||||
((this.type === 'linux' || this.type === 'windows') && this.position === 'right')
|
||||
? html`
|
||||
<div class="windowControls">
|
||||
<div class="close"></div>
|
||||
<div class="toDock"></div>
|
||||
<div class="minMax"></div>
|
||||
</div>
|
||||
`
|
||||
: html``}
|
||||
`;
|
||||
}
|
||||
}
|
@ -1,6 +1,4 @@
|
||||
import { customElement, DeesElement, type TemplateResult, html, property, type CSSResult, } from '@design.estate/dees-element';
|
||||
|
||||
import * as domtools from '@design.estate/dees-domtools';
|
||||
import { customElement, DeesElement, domtools, type TemplateResult, html, property, type CSSResult, state, } from '@design.estate/dees-element';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@ -8,11 +6,33 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export interface IOptions_DeesWindowLayer {
|
||||
blur: boolean;
|
||||
}
|
||||
|
||||
@customElement('dees-windowlayer')
|
||||
export class DeesWindowLayer extends DeesElement {
|
||||
// STATIC
|
||||
public static demo = () => html`<dees-windowlayer></dees-windowlayer>`;
|
||||
|
||||
public static async createAndShow(optionsArg?: IOptions_DeesWindowLayer) {
|
||||
const domtoolsInstance = domtools.DomTools.getGlobalDomToolsSync();
|
||||
const windowLayer = new DeesWindowLayer();
|
||||
windowLayer.options = {
|
||||
...windowLayer.options,
|
||||
...optionsArg,
|
||||
}
|
||||
document.body.append(windowLayer);
|
||||
await domtoolsInstance.convenience.smartdelay.delayFor(0);
|
||||
windowLayer.show();
|
||||
return windowLayer;
|
||||
}
|
||||
|
||||
@state()
|
||||
public options: IOptions_DeesWindowLayer = {
|
||||
blur: false
|
||||
};
|
||||
|
||||
// INSTANCE
|
||||
@property({
|
||||
type: Boolean
|
||||
@ -29,7 +49,7 @@ export class DeesWindowLayer extends DeesElement {
|
||||
${domtools.elementBasic.styles}
|
||||
<style>
|
||||
.windowOverlay {
|
||||
transition: all 0.3s;
|
||||
transition: all 0.2s;
|
||||
will-change: transform;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
@ -40,18 +60,29 @@ export class DeesWindowLayer extends DeesElement {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: rgba(0, 0, 0, 0.0);
|
||||
backdrop-filter: brightness(1);
|
||||
backdrop-filter: brightness(1) ${this.options.blur ? 'blur(0px)' : ''};
|
||||
pointer-events: none;
|
||||
z-index: 200;
|
||||
}
|
||||
.slotContent {
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 201;
|
||||
}
|
||||
|
||||
.visible {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
backdrop-filter: brightness(0.3);
|
||||
backdrop-filter: brightness(0.9) ${this.options.blur ? 'blur(2px)' : ''};
|
||||
pointer-events: all;
|
||||
}
|
||||
</style>
|
||||
<div @click=${this.dispatchClicked} class="windowOverlay ${this.visible ? 'visible' : null}">
|
||||
<div class="windowOverlay ${this.visible ? 'visible' : null}">
|
||||
</div>
|
||||
<div @click=${this.dispatchClicked} class="slotContent">
|
||||
<slot></slot>
|
||||
</div>
|
||||
`;
|
||||
@ -82,4 +113,11 @@ export class DeesWindowLayer extends DeesElement {
|
||||
await domtools.convenience.smartdelay.delayFor(0);
|
||||
this.visible = false;
|
||||
}
|
||||
|
||||
public async destroy() {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
await this.hide();
|
||||
await domtools.convenience.smartdelay.delayFor(300);
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,23 @@ export * from './dees-dataview-codebox.js';
|
||||
export * from './dees-dataview-statusobject.js';
|
||||
export * from './dees-form-submit.js';
|
||||
export * from './dees-form.js';
|
||||
export * from './dees-hint.js';
|
||||
export * from './dees-icon.js';
|
||||
export * from './dees-input-checkbox.js';
|
||||
export * from './dees-input-dropdown.js';
|
||||
export * from './dees-input-fileupload.js';
|
||||
export * from './dees-input-iban.js';
|
||||
export * from './dees-input-typelist.js';
|
||||
export * from './dees-input-phone.js';
|
||||
export * from './dees-progressbar.js';
|
||||
export * from './dees-input-quantityselector.js';
|
||||
export * from './dees-input-radio.js';
|
||||
export * from './dees-input-text.js';
|
||||
export * from './dees-mobilenavigation.js';
|
||||
export * from './dees-modal.js';
|
||||
export * from './dees-input-multitoggle.js';
|
||||
export * from './dees-pdf.js';
|
||||
export * from './dees-simple-appdash.js';
|
||||
export * from './dees-simple-login.js';
|
||||
export * from './dees-speechbubble.js';
|
||||
export * from './dees-spinner.js';
|
||||
@ -22,4 +30,5 @@ export * from './dees-stepper.js';
|
||||
export * from './dees-table.js';
|
||||
export * from './dees-toast.js';
|
||||
export * from './dees-updater.js';
|
||||
export * from './dees-windowcontrols.js';
|
||||
export * from './dees-windowlayer.js';
|
||||
|
@ -3,9 +3,10 @@
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
|
Reference in New Issue
Block a user