Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
c5598f95ef | |||
13d0cf729c | |||
032e928dde | |||
14ab3682f2 | |||
c554e730a6 | |||
4d5a490e80 | |||
7708c89fe1 | |||
0a0be3e357 | |||
7b7c469fab | |||
d852186888 | |||
6cfda1ebf3 | |||
8e0062fdd5 | |||
844cc30551 | |||
64074e37fc |
@ -119,6 +119,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npmci node install stable
|
npmci node install stable
|
||||||
npmci npm install
|
npmci npm install
|
||||||
pnpm install -g @gitzone/tsdoc
|
pnpm install -g @git.zone/tsdoc
|
||||||
npmci command tsdoc
|
npmci command tsdoc
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
24
package.json
24
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@design.estate/dees-catalog",
|
"name": "@design.estate/dees-catalog",
|
||||||
"version": "1.0.228",
|
"version": "1.0.235",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "website for lossless.com",
|
"description": "website for lossless.com",
|
||||||
"main": "dist_ts_web/index.js",
|
"main": "dist_ts_web/index.js",
|
||||||
@ -16,28 +16,28 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@design.estate/dees-domtools": "^2.0.55",
|
"@design.estate/dees-domtools": "^2.0.55",
|
||||||
"@design.estate/dees-element": "^2.0.31",
|
"@design.estate/dees-element": "^2.0.33",
|
||||||
"@design.estate/dees-wcctools": "^1.0.81",
|
"@design.estate/dees-wcctools": "^1.0.81",
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
"@fortawesome/fontawesome-svg-core": "^6.5.0",
|
||||||
"@fortawesome/free-brands-svg-icons": "^6.4.2",
|
"@fortawesome/free-brands-svg-icons": "^6.5.0",
|
||||||
"@fortawesome/free-regular-svg-icons": "^6.4.2",
|
"@fortawesome/free-regular-svg-icons": "^6.5.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
"@fortawesome/free-solid-svg-icons": "^6.5.0",
|
||||||
"@push.rocks/smarti18n": "^1.0.4",
|
"@push.rocks/smarti18n": "^1.0.4",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@push.rocks/smartstring": "^4.0.9",
|
"@push.rocks/smartstring": "^4.0.9",
|
||||||
"@tsclass/tsclass": "^4.0.46",
|
"@tsclass/tsclass": "^4.0.46",
|
||||||
"highlight.js": "11.9.0",
|
"highlight.js": "11.9.0",
|
||||||
"ibantools": "^4.3.5",
|
"ibantools": "^4.3.6",
|
||||||
"pdfjs-dist": "^3.11.174"
|
"pdfjs-dist": "^3.11.174"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.66",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^2.0.8",
|
"@git.zone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tstest": "^1.0.77",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@gitzone/tswatch": "^2.0.7",
|
"@git.zone/tswatch": "^2.0.7",
|
||||||
"@push.rocks/projectinfo": "^5.0.2",
|
"@push.rocks/projectinfo": "^5.0.2",
|
||||||
"@push.rocks/tapbundle": "^5.0.15",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"@types/node": "^20.8.7"
|
"@types/node": "^20.10.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
2330
pnpm-lock.yaml
generated
2330
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@design.estate/dees-catalog',
|
name: '@design.estate/dees-catalog',
|
||||||
version: '1.0.228',
|
version: '1.0.235',
|
||||||
description: 'website for lossless.com'
|
description: 'website for lossless.com'
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,41 @@
|
|||||||
import { html } from '@design.estate/dees-element';
|
import { html } from '@design.estate/dees-element';
|
||||||
|
|
||||||
export const demoFunc = () => html`
|
export const demoFunc = () => html`
|
||||||
<dees-chips
|
<style>
|
||||||
selectionMode="none"
|
.demoContainer {
|
||||||
.selectableChips=${[
|
display: flex;
|
||||||
{ key: 'account1', value: 'Payment Account 1' },
|
flex-direction: column;
|
||||||
{ key: 'account2', value: 'PaymentAccount2' },
|
align-items: center;
|
||||||
{ key: 'account3', value: 'Payment Account 3' }
|
justify-content: center;
|
||||||
]}
|
height: 100%;
|
||||||
></dees-chips>
|
background: #222;
|
||||||
<dees-chips
|
}
|
||||||
selectionMode="single"
|
</style>
|
||||||
.selectableChips=${[
|
<div class="demoContainer">
|
||||||
{ key: 'account1', value: 'Payment Account 1' },
|
<dees-chips
|
||||||
{ key: 'account2', value: 'PaymentAccount2' },
|
selectionMode="none"
|
||||||
{ key: 'account3', value: 'Payment Account 3' }
|
.selectableChips=${[
|
||||||
]}
|
{ key: 'account1', value: 'Payment Account 1' },
|
||||||
></dees-chips>
|
{ key: 'account2', value: 'PaymentAccount2' },
|
||||||
<dees-chips
|
{ key: 'account3', value: 'Payment Account 3' },
|
||||||
selectionMode="multiple"
|
]}
|
||||||
.selectableChips=${[
|
></dees-chips>
|
||||||
{ key: 'account1', value: 'Payment Account 1' },
|
<dees-chips
|
||||||
{ key: 'account2', value: 'PaymentAccount2' },
|
selectionMode="single"
|
||||||
{ key: 'account3', value: 'Payment Account 3' }
|
chipsAreRemovable
|
||||||
]}
|
.selectableChips=${[
|
||||||
></dees-chips>
|
{ 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>
|
||||||
`;
|
`;
|
||||||
|
@ -19,7 +19,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tag = { key: string, value: string };
|
type Tag = { key: string; value: string };
|
||||||
|
|
||||||
@customElement('dees-chips')
|
@customElement('dees-chips')
|
||||||
export class DeesChips extends DeesElement {
|
export class DeesChips extends DeesElement {
|
||||||
@ -29,7 +29,12 @@ export class DeesChips extends DeesElement {
|
|||||||
public selectionMode: 'none' | 'single' | 'multiple' = 'single';
|
public selectionMode: 'none' | 'single' | 'multiple' = 'single';
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array
|
type: Boolean,
|
||||||
|
})
|
||||||
|
public chipsAreRemovable: boolean = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Array,
|
||||||
})
|
})
|
||||||
public selectableChips: Tag[] = [];
|
public selectableChips: Tag[] = [];
|
||||||
|
|
||||||
@ -37,10 +42,9 @@ export class DeesChips extends DeesElement {
|
|||||||
public selectedChip: Tag = null;
|
public selectedChip: Tag = null;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array
|
type: Array,
|
||||||
})
|
})
|
||||||
public selectedChips: Tag[] = [];
|
public selectedChips: Tag[] = [];
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -49,7 +53,6 @@ export class DeesChips extends DeesElement {
|
|||||||
public static styles = [
|
public static styles = [
|
||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -70,22 +73,23 @@ export class DeesChips extends DeesElement {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
border-radius: 40px;
|
border-radius: 40px;
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 4px;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip:hover {
|
.chip:hover {
|
||||||
background: #666666;
|
background: #666666;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip.selected {
|
.chip.selected {
|
||||||
background: #00A3FF;
|
background: #00a3ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chipKey {
|
.chipKey {
|
||||||
background: rgba(0,0,0,0.3);
|
background: rgba(0, 0, 0, 0.3);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: -8px;
|
margin-left: -8px;
|
||||||
@ -93,18 +97,44 @@ export class DeesChips extends DeesElement {
|
|||||||
padding-right: 8px;
|
padding-right: 8px;
|
||||||
margin-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 {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="mainbox">
|
<div class="mainbox">
|
||||||
${this.selectableChips.map(chip => html`
|
${this.selectableChips.map(
|
||||||
<div @click=${() => this.selectChip(chip)} class="chip ${this.isSelected(chip) ? 'selected' : ''}">
|
(chip) => html`
|
||||||
${chip.key ? html`<div class="chipKey">${chip.key}</div>` : html``}${chip.value}
|
<div
|
||||||
</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>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -120,7 +150,7 @@ export class DeesChips extends DeesElement {
|
|||||||
if (this.selectionMode === 'single') {
|
if (this.selectionMode === 'single') {
|
||||||
return this.selectedChip?.key === chip.key;
|
return this.selectedChip?.key === chip.key;
|
||||||
} else {
|
} else {
|
||||||
return this.selectedChips.some(selected => selected.key === chip.key);
|
return this.selectedChips.some((selected) => selected.key === chip.key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,9 +167,9 @@ export class DeesChips extends DeesElement {
|
|||||||
this.selectedChip = chip;
|
this.selectedChip = chip;
|
||||||
this.selectedChips = [chip];
|
this.selectedChips = [chip];
|
||||||
}
|
}
|
||||||
} else if(this.selectionMode === 'multiple') {
|
} else if (this.selectionMode === 'multiple') {
|
||||||
if (this.isSelected(chip)) {
|
if (this.isSelected(chip)) {
|
||||||
this.selectedChips = this.selectedChips.filter(selected => selected.key !== chip.key);
|
this.selectedChips = this.selectedChips.filter((selected) => selected.key !== chip.key);
|
||||||
} else {
|
} else {
|
||||||
this.selectedChips = [...this.selectedChips, chip];
|
this.selectedChips = [...this.selectedChips, chip];
|
||||||
}
|
}
|
||||||
@ -147,4 +177,20 @@ export class DeesChips extends DeesElement {
|
|||||||
}
|
}
|
||||||
console.log(this.selectedChips);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,42 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
public static demo = demoFunc
|
public static demo = demoFunc
|
||||||
|
|
||||||
// STATIC
|
// 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[]) {
|
public static async openContextMenuWithOptions(eventArg: MouseEvent, menuItemsArg: plugins.tsclass.website.IMenuItem[]) {
|
||||||
|
if (this.contextMenuDeactivated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
eventArg.preventDefault();
|
eventArg.preventDefault();
|
||||||
eventArg.stopPropagation();
|
eventArg.stopPropagation();
|
||||||
const contextMenu = new DeesContextmenu();
|
const contextMenu = new DeesContextmenu();
|
||||||
@ -49,6 +84,7 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
contextMenu.style.transform = 'scale(1,1)';
|
contextMenu.style.transform = 'scale(1,1)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
@property({
|
@property({
|
||||||
type: Array,
|
type: Array,
|
||||||
})
|
})
|
||||||
@ -59,6 +95,9 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* STATIC STYLES
|
||||||
|
*/
|
||||||
public static styles = [
|
public static styles = [
|
||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
@ -115,10 +154,11 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
})}
|
})}
|
||||||
${this.menuItems.length === 0 ? html`
|
${this.menuItems.length === 0 ? html`
|
||||||
<div class="menuitem" @click=${() => {
|
<div class="menuitem" @click=${() => {
|
||||||
alert('No menu items...')
|
DeesContextmenu.contextMenuDeactivated = true;
|
||||||
|
this.destroy();
|
||||||
}}>
|
}}>
|
||||||
<dees-icon .iconFA=${'xmark'}></dees-icon
|
<dees-icon .iconFA=${'xmark'}></dees-icon
|
||||||
>No menu item present...
|
>Deactivate Contextmenu globally.
|
||||||
</div>
|
</div>
|
||||||
` : html``}
|
` : html``}
|
||||||
</div>
|
</div>
|
||||||
@ -144,3 +184,5 @@ export class DeesContextmenu extends DeesElement {
|
|||||||
this.parentElement.removeChild(this);
|
this.parentElement.removeChild(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeesContextmenu.initializeGlobalListener();
|
||||||
|
@ -20,9 +20,22 @@ export const demoFunc = () => html`
|
|||||||
form.setStatus('success', 'authenticated!');
|
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-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
<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="hello2" label="also a text"></dees-input-text>
|
||||||
<dees-input-text .required="${true}" key="hello3" label="a password" isPasswordBool></dees-input-text>
|
<dees-input-text
|
||||||
|
.required="${true}"
|
||||||
|
key="hello3"
|
||||||
|
label="a password"
|
||||||
|
isPasswordBool
|
||||||
|
></dees-input-text>
|
||||||
<dees-input-checkbox
|
<dees-input-checkbox
|
||||||
.required="${true}"
|
.required="${true}"
|
||||||
key="hello3"
|
key="hello3"
|
||||||
|
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 * as domtools from '@design.estate/dees-domtools';
|
||||||
|
import { demoFunc } from './dees-input-dropdown.demo.js';
|
||||||
|
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -9,15 +21,7 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-input-dropdown')
|
@customElement('dees-input-dropdown')
|
||||||
export class DeesInputDropdown extends DeesElement {
|
export class DeesInputDropdown extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<dees-input-dropdown
|
|
||||||
.options=${[
|
|
||||||
{option: 'option 1', key: 'option1'},
|
|
||||||
{option: 'option 2', key: 'option2'},
|
|
||||||
{option: 'option 3', key: 'option3'}
|
|
||||||
]}
|
|
||||||
></dees-input-dropdown>
|
|
||||||
`
|
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
@ -32,145 +36,266 @@ export class DeesInputDropdown extends DeesElement {
|
|||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public options: {option: string, key: string, payload?: any}[] = [];
|
public options: { option: string; key: string; payload?: any }[] = [];
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public selectedOption: {option: string, key: string, payload?: any} = {
|
public selectedOption: { option: string; key: string; payload?: any } = null;
|
||||||
key: null,
|
|
||||||
option: null,
|
|
||||||
payload: null
|
|
||||||
};
|
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public required: boolean = false;
|
public required: boolean = false;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
|
})
|
||||||
|
public enableSearch: boolean = true;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public disabled: boolean = false;
|
public disabled: boolean = false;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
public opensToTop: boolean = false;
|
||||||
|
|
||||||
public static styles = [
|
public static styles = [
|
||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
position: relative;
|
font-family: Roboto;
|
||||||
display: block;
|
position: relative;
|
||||||
height: 40px;
|
display: block;
|
||||||
color: ${cssManager.bdTheme('#222', '#fff')};
|
color: ${cssManager.bdTheme('#222', '#fff')};
|
||||||
}
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.maincontainer {
|
.maincontainer {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selectedBox {
|
.selectedBox {
|
||||||
cursor: pointer;
|
user-select: none;
|
||||||
position: relative;
|
cursor: pointer;
|
||||||
max-width: 420px;
|
position: relative;
|
||||||
height: 40px;
|
max-width: 420px;
|
||||||
line-height: 40px;
|
height: 40px;
|
||||||
padding: 0px 8px;
|
line-height: 40px;
|
||||||
z-index: 0px;
|
padding: 0px 8px;
|
||||||
background: ${cssManager.bdTheme('#ffffff', '#333333')};
|
background: ${cssManager.bdTheme('#fafafa', '#222')};
|
||||||
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
box-shadow: ${cssManager.bdTheme('0px 1px 4px rgba(0,0,0,0.3)', 'none')};
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border-top: 1px solid #CCCCCC00;
|
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||||
border-bottom: 1px solid #66666600;
|
border-bottom: ${cssManager.bdTheme('1px solid #CCC', '1px solid #333')};
|
||||||
}
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
.selectedBox.show {
|
.accentTop {
|
||||||
border-top: 1px solid ${cssManager.bdTheme('#ffffff', '#666666')};
|
border-top: 1px solid #e4002b;
|
||||||
border-bottom: 1px solid ${cssManager.bdTheme('#fafafa', '#222222')};
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.selectionBox {
|
.accentBottom {
|
||||||
will-change:transform;
|
border-bottom: 1px solid #e4002b;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
.selectionBox.show {
|
.selectionBox {
|
||||||
pointer-events: all;
|
will-change: transform;
|
||||||
opacity: 1;
|
pointer-events: none;
|
||||||
transform: scale(1,1);
|
cursor: pointer;
|
||||||
}
|
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: 3px;
|
||||||
|
padding: 4px;
|
||||||
|
transform: scale(0.99, 0.99);
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
.option {
|
.selectionBox.show {
|
||||||
transition: all 0.1s;
|
pointer-events: all;
|
||||||
line-height: 40px;
|
opacity: 1;
|
||||||
padding: 0px 4px;
|
transform: scale(1, 1);
|
||||||
border-radius: 3px;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.option:hover {
|
.option {
|
||||||
color: #fff;
|
transition: all 0.1s;
|
||||||
padding-left: 8px;
|
line-height: 40px;
|
||||||
background: #0277bd;
|
padding: 0px 4px;
|
||||||
}
|
border-radius: 3px;
|
||||||
`
|
}
|
||||||
]
|
|
||||||
|
.option:hover {
|
||||||
|
color: #fff;
|
||||||
|
padding-left: 8px;
|
||||||
|
background: #0277bd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
.search input {
|
||||||
|
display: block;
|
||||||
|
width: 80%;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
height: 24px;
|
||||||
|
color: inherit;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
background: ${cssManager.bdTheme('#00000010', '#ffffff08')};
|
||||||
|
border-radius: 16px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search input:focus {
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
${domtools.elementBasic.styles}
|
|
||||||
<style>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
<div class="maincontainer">
|
<div class="maincontainer">
|
||||||
<div class="selectedBox show" @click="${event => {this.toggleSelectionBox();}}">
|
${this.label ? html`<div class="label">${this.label}</div>` : html``}
|
||||||
${this.selectedOption?.option}
|
|
||||||
</div>
|
|
||||||
<div class="selectionBox">
|
<div class="selectionBox">
|
||||||
${this.options.map(option => {
|
${this.enableSearch && !this.opensToTop
|
||||||
|
? html`
|
||||||
|
<div class="search">
|
||||||
|
<input type="text" placeholder="Search" />
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: null}
|
||||||
|
${this.options.map((option) => {
|
||||||
return html`
|
return html`
|
||||||
<div class="option" @click=${() => {this.updateSelection(option);}}>${option.option}</div>
|
<div
|
||||||
`
|
class="option"
|
||||||
|
@click=${() => {
|
||||||
|
this.updateSelection(option);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
${option.option}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
})}
|
})}
|
||||||
|
${this.enableSearch && this.opensToTop
|
||||||
|
? html`
|
||||||
|
<div class="search">
|
||||||
|
<input type="text" placeholder="Search" />
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: null}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="selectedBox"
|
||||||
|
@click="${(event) => {
|
||||||
|
if (!this.isElevated) {
|
||||||
|
this.toggleSelectionBox();
|
||||||
|
} else {
|
||||||
|
this.updateSelection(this.selectedOption);
|
||||||
|
}
|
||||||
|
}}"
|
||||||
|
>
|
||||||
|
${this.selectedOption?.option}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated() {
|
firstUpdated() {
|
||||||
this.selectedOption = this.options[0] || null;
|
this.selectedOption = this.selectedOption || this.options[0] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateSelection(selectedOption) {
|
public async updateSelection(selectedOption) {
|
||||||
this.selectedOption = selectedOption;
|
this.selectedOption = selectedOption;
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent('selectedOption', {
|
this.dispatchEvent(
|
||||||
detail: selectedOption,
|
new CustomEvent('selectedOption', {
|
||||||
bubbles: true
|
detail: selectedOption,
|
||||||
}));
|
bubbles: true,
|
||||||
this.toggleSelectionBox();
|
})
|
||||||
|
);
|
||||||
|
if (this.isElevated) {
|
||||||
|
this.toggleSelectionBox();
|
||||||
|
}
|
||||||
this.changeSubject.next(this);
|
this.changeSubject.next(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleSelectionBox() {
|
private isElevated: boolean = false;
|
||||||
this.shadowRoot.querySelector('.selectedBox').classList.toggle('show');
|
private windowOverlay: DeesWindowLayer;
|
||||||
this.shadowRoot.querySelector('.selectionBox').classList.toggle('show');
|
public async toggleSelectionBox() {
|
||||||
|
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;
|
||||||
|
console.log(elevatedDropdown.selectedOption);
|
||||||
|
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';
|
||||||
|
selectionBox.classList.add('show');
|
||||||
|
const spaceData = selectedBox.getBoundingClientRect();
|
||||||
|
if (300 > window.innerHeight - spaceData.bottom) {
|
||||||
|
this.opensToTop = true;
|
||||||
|
selectedBox.classList.add('accentTop');
|
||||||
|
selectionBox.style.bottom = selectedBox.clientHeight + 2 + 'px';
|
||||||
|
} else {
|
||||||
|
selectedBox.classList.add('accentBottom');
|
||||||
|
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();
|
||||||
|
} else {
|
||||||
|
selectedBox.style.pointerEvents = 'none';
|
||||||
|
selectionBox.classList.remove('show');
|
||||||
|
selectedBox.style.opacity = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,7 @@ export class DeesInputText extends DeesElement {
|
|||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
padding: 4px 0px;
|
padding: 4px 0px;
|
||||||
width: 40px;
|
width: 40px;
|
||||||
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.showPassword:hover {
|
.showPassword:hover {
|
||||||
@ -169,7 +170,7 @@ export class DeesInputText extends DeesElement {
|
|||||||
return html`
|
return html`
|
||||||
<style>
|
<style>
|
||||||
input {
|
input {
|
||||||
font-family: ${this.isPasswordBool ? 'monospace' : 'Inter'};
|
font-family: ${this.isPasswordBool ? 'monospace' : 'Roboto'};
|
||||||
letter-spacing: ${this.isPasswordBool ? '1px' : 'normal'};
|
letter-spacing: ${this.isPasswordBool ? '1px' : 'normal'};
|
||||||
color: ${this.goBright ? '#333' : '#ccc'};
|
color: ${this.goBright ? '#333' : '#ccc'};
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ export class DeesModal extends DeesElement {
|
|||||||
:host {
|
:host {
|
||||||
font-family: 'Roboto', 'Inter', sans-serif;
|
font-family: 'Roboto', 'Inter', sans-serif;
|
||||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
||||||
|
will-change: transform;
|
||||||
}
|
}
|
||||||
.modalContainer {
|
.modalContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -61,8 +61,8 @@ export interface ITableAction<T = any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ITableActionDataArg<T> {
|
export interface ITableActionDataArg<T> {
|
||||||
item: T,
|
item: T;
|
||||||
table: DeesTable<T>,
|
table: DeesTable<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TDisplayFunction<T = any> = (itemArg: T) => object;
|
export type TDisplayFunction<T = any> = (itemArg: T) => object;
|
||||||
@ -396,6 +396,8 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
</div>
|
</div>
|
||||||
<div class="headingSeparation"></div>
|
<div class="headingSeparation"></div>
|
||||||
|
|
||||||
|
<dees-input-text></dees-input-text>
|
||||||
|
|
||||||
<!-- the actual table -->
|
<!-- the actual table -->
|
||||||
<style></style>
|
<style></style>
|
||||||
${this.data.length > 0
|
${this.data.length > 0
|
||||||
@ -524,10 +526,11 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
${this.getActionsForType('inRow').map(
|
${this.getActionsForType('inRow').map(
|
||||||
(actionArg) => html`<div
|
(actionArg) => html`<div
|
||||||
class="action"
|
class="action"
|
||||||
@click=${() => actionArg.actionFunc({
|
@click=${() =>
|
||||||
item: itemArg,
|
actionArg.actionFunc({
|
||||||
table: this,
|
item: itemArg,
|
||||||
})}
|
table: this,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
${actionArg.iconName
|
${actionArg.iconName
|
||||||
? html`
|
? html`
|
||||||
@ -584,8 +587,7 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async firstUpdated() {
|
public async firstUpdated() {}
|
||||||
}
|
|
||||||
|
|
||||||
public async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
|
public async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
|
||||||
super.updated(changedProperties);
|
super.updated(changedProperties);
|
||||||
@ -609,7 +611,8 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
// Get computed width
|
// Get computed width
|
||||||
const width = window.getComputedStyle(cell).width;
|
const width = window.getComputedStyle(cell).width;
|
||||||
if (cell.textContent.includes('Actions')) {
|
if (cell.textContent.includes('Actions')) {
|
||||||
const neededWidth = this.dataActions.filter(actionArg => actionArg.type.includes('inRow')).length * 35;
|
const neededWidth =
|
||||||
|
this.dataActions.filter((actionArg) => actionArg.type.includes('inRow')).length * 35;
|
||||||
cell.style.width = `${Math.max(neededWidth, 68)}px`;
|
cell.style.width = `${Math.max(neededWidth, 68)}px`;
|
||||||
} else {
|
} else {
|
||||||
cell.style.width = width;
|
cell.style.width = width;
|
||||||
@ -620,7 +623,7 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
});
|
});
|
||||||
await done.promise;
|
await done.promise;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
if (cells[cells.length - 1].textContent.includes('Actions')) {
|
if (cells[cells.length - 1].textContent.includes('Actions')) {
|
||||||
await handleColumnByIndex(cells.length - 1, true);
|
await handleColumnByIndex(cells.length - 1, true);
|
||||||
|
@ -66,6 +66,15 @@ export class DeesWindowLayer extends DeesElement {
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 200;
|
z-index: 200;
|
||||||
}
|
}
|
||||||
|
.slotContent {
|
||||||
|
position: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 201;
|
||||||
|
}
|
||||||
|
|
||||||
.visible {
|
.visible {
|
||||||
background: rgba(0, 0, 0, 0.2);
|
background: rgba(0, 0, 0, 0.2);
|
||||||
@ -73,7 +82,9 @@ export class DeesWindowLayer extends DeesElement {
|
|||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
}
|
}
|
||||||
</style>
|
</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>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"useDefineForClassFields": false,
|
"useDefineForClassFields": false,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "NodeNext",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user