Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
7b7c469fab | |||
d852186888 | |||
6cfda1ebf3 | |||
8e0062fdd5 | |||
844cc30551 | |||
64074e37fc | |||
cd9b028e9b | |||
81da871e38 | |||
90e78a2e31 | |||
5cec1fea73 | |||
52130d67e2 | |||
a73ad40eb1 | |||
6589818b0b | |||
555fa32ac2 | |||
50a84f2422 | |||
c724a3e85b | |||
b47530e254 | |||
b80fdf113e | |||
963edbffa3 | |||
f3687f724f |
@ -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
|
||||||
|
30
package.json
30
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@design.estate/dees-catalog",
|
"name": "@design.estate/dees-catalog",
|
||||||
"version": "1.0.221",
|
"version": "1.0.231",
|
||||||
"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",
|
||||||
@ -15,27 +15,29 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@design.estate/dees-domtools": "^2.0.51",
|
"@design.estate/dees-domtools": "^2.0.55",
|
||||||
"@design.estate/dees-element": "^2.0.29",
|
"@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/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.43",
|
"@tsclass/tsclass": "^4.0.46",
|
||||||
"highlight.js": "11.8.0",
|
"highlight.js": "11.9.0",
|
||||||
|
"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.3"
|
"@types/node": "^20.10.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
2373
pnpm-lock.yaml
generated
2373
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.221',
|
version: '1.0.231',
|
||||||
description: 'website for lossless.com'
|
description: 'website for lossless.com'
|
||||||
}
|
}
|
||||||
|
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';
|
} 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-chips.demo.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -18,30 +19,32 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tag = { key: string; value: string };
|
||||||
|
|
||||||
@customElement('dees-chips')
|
@customElement('dees-chips')
|
||||||
export class DeesChips extends DeesElement {
|
export class DeesChips extends DeesElement {
|
||||||
public static demo = () => html`
|
public static demo = demoFunc;
|
||||||
<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>
|
|
||||||
|
|
||||||
`;
|
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public selectionMode: 'single' | 'multiple' = 'single';
|
public selectionMode: 'none' | 'single' | 'multiple' = 'single';
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public selectableChips: string[] = [];
|
public chipsAreRemovable: boolean = false;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: Array,
|
||||||
|
})
|
||||||
|
public selectableChips: Tag[] = [];
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public selectedChip: string = null;
|
public selectedChip: Tag = null;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array
|
type: Array,
|
||||||
})
|
})
|
||||||
public selectedChips: string[] = [];
|
public selectedChips: Tag[] = [];
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -50,47 +53,88 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mainbox {
|
.mainbox {
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip {
|
.chip {
|
||||||
background: #494949;
|
border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
|
||||||
display: inline-block;
|
background: #333333;
|
||||||
padding: 8px 12px;
|
display: inline-flex;
|
||||||
font-size: 14px;
|
height: 20px;
|
||||||
|
line-height: 20px;
|
||||||
|
padding: 0px 8px;
|
||||||
|
font-size: 12px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border-radius: 40px;
|
border-radius: 40px;
|
||||||
margin-right: 4px;
|
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 {
|
.chip:hover {
|
||||||
background: #666666;
|
background: #666666;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip.selected {
|
.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 {
|
public render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="mainbox">
|
<div class="mainbox">
|
||||||
${this.selectableChips.map(chipArg => html`
|
${this.selectableChips.map(
|
||||||
<div @click=${() => this.selectChip(chipArg)} class="chip ${this.selectedChip === chipArg || this.selectedChips.includes(chipArg) ? 'selected' : ''}">
|
(chip) => html`
|
||||||
${chipArg}
|
<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>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -102,23 +146,51 @@ export class DeesChips extends DeesElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async selectChip(chipArg: string) {
|
private isSelected(chip: Tag): boolean {
|
||||||
if (this.selectionMode === 'single') {
|
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.selectedChip = null;
|
||||||
this.selectedChips = [];
|
this.selectedChips = [];
|
||||||
} else {
|
} else {
|
||||||
this.selectedChip = chipArg;
|
this.selectedChip = chip;
|
||||||
this.selectedChips = [chipArg];
|
this.selectedChips = [chip];
|
||||||
}
|
}
|
||||||
} else if(this.selectionMode === 'multiple') {
|
} else if (this.selectionMode === 'multiple') {
|
||||||
if (this.selectedChips.includes(chipArg)) {
|
if (this.isSelected(chip)) {
|
||||||
this.selectedChips = this.selectedChips.filter(chipArg2 => chipArg !== chipArg2)
|
this.selectedChips = this.selectedChips.filter((selected) => selected.key !== chip.key);
|
||||||
} else {
|
} else {
|
||||||
this.selectedChips.push(chipArg);
|
this.selectedChips = [...this.selectedChips, chip];
|
||||||
}
|
}
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
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();
|
||||||
|
35
ts_web/elements/dees-form.demo.ts
Normal file
35
ts_web/elements/dees-form.demo.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
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-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 * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
import { DeesInputCheckbox } from './dees-input-checkbox.js';
|
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 { DeesInputQuantitySelector } from './dees-input-quantityselector.js';
|
||||||
import { DeesInputRadio } from './dees-input-radio.js';
|
import { DeesInputRadio } from './dees-input-radio.js';
|
||||||
import { DeesFormSubmit } from './dees-form-submit.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
|
// Unified set for form input types
|
||||||
const FORM_INPUT_TYPES = [
|
const FORM_INPUT_TYPES = [
|
||||||
DeesInputCheckbox,
|
DeesInputCheckbox,
|
||||||
|
DeesInputIban,
|
||||||
DeesInputText,
|
DeesInputText,
|
||||||
DeesInputQuantitySelector,
|
DeesInputQuantitySelector,
|
||||||
DeesInputRadio
|
DeesInputRadio,
|
||||||
|
DeesTable,
|
||||||
];
|
];
|
||||||
|
|
||||||
export type TFormInputElement = DeesInputCheckbox | DeesInputText | DeesInputQuantitySelector | DeesInputRadio;
|
export type TFormInputElement =
|
||||||
|
| DeesInputCheckbox
|
||||||
|
| DeesInputIban
|
||||||
|
| DeesInputText
|
||||||
|
| DeesInputQuantitySelector
|
||||||
|
| DeesInputRadio
|
||||||
|
| DeesTable<any>;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -25,26 +42,10 @@ declare global {
|
|||||||
|
|
||||||
@customElement('dees-form')
|
@customElement('dees-form')
|
||||||
export class DeesForm extends DeesElement {
|
export class DeesForm extends DeesElement {
|
||||||
|
public static demo = demoFunc;
|
||||||
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 name: string = 'myform';
|
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 readyDeferred = domtools.plugins.smartpromise.defer();
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
@ -75,14 +76,14 @@ export class DeesForm extends DeesElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getFormElements(): Array<TFormInputElement> {
|
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)
|
FORM_INPUT_TYPES.includes(child.constructor as any)
|
||||||
) as unknown as TFormInputElement[];
|
) as unknown as TFormInputElement[];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSubmitButton(): DeesFormSubmit | undefined {
|
public getSubmitButton(): DeesFormSubmit | undefined {
|
||||||
return Array.from(this.children).find(child =>
|
return Array.from(this.children).find(
|
||||||
child instanceof DeesFormSubmit
|
(child) => child instanceof DeesFormSubmit
|
||||||
) as DeesFormSubmit;
|
) as DeesFormSubmit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ export class DeesForm extends DeesElement {
|
|||||||
|
|
||||||
public async collectFormData() {
|
public async collectFormData() {
|
||||||
const children = this.getFormElements();
|
const children = this.getFormElements();
|
||||||
const valueObject: { [key: string]: string | number | boolean } = {};
|
const valueObject: { [key: string]: string | number | boolean | any[] } = {};
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (!child.key) {
|
if (!child.key) {
|
||||||
console.log(`form element with label "${child.label}" has no key. skipping.`);
|
console.log(`form element with label "${child.label}" has no key. skipping.`);
|
||||||
|
@ -22,7 +22,7 @@ export class DeesInputCheckbox extends DeesElement {
|
|||||||
public static demo = () => html`<dees-input-checkbox></dees-input-checkbox>`;
|
public static demo = () => html`<dees-input-checkbox></dees-input-checkbox>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
|
11
ts_web/elements/dees-input-dropdown.demo.ts
Normal file
11
ts_web/elements/dees-input-dropdown.demo.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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>
|
||||||
|
`
|
@ -1,5 +1,6 @@
|
|||||||
import { customElement, DeesElement, type TemplateResult, property, html, css, cssManager, type CSSResult, } from '@design.estate/dees-element';
|
import { customElement, DeesElement, type TemplateResult, property, 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';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@ -9,18 +10,10 @@ 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.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
@ -100,12 +93,11 @@ export class DeesInputDropdown extends DeesElement {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
position: relative;
|
position: absolute;
|
||||||
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
background: ${cssManager.bdTheme('#ffffff', '#222222')};
|
||||||
max-width: 420px;
|
max-width: 420px;
|
||||||
box-shadow: 0px 0px 5px rgba(0,0,0,0.2);
|
box-shadow: 0px 0px 5px rgba(0,0,0,0.2);
|
||||||
min-height: 40px;
|
min-height: 40px;
|
||||||
margin-top: -40px;
|
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@ -135,12 +127,8 @@ export class DeesInputDropdown extends DeesElement {
|
|||||||
|
|
||||||
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();}}">
|
<div class="selectedBox show" @click="${event => {this.openSelectionBox();}}">
|
||||||
${this.selectedOption?.option}
|
${this.selectedOption?.option}
|
||||||
</div>
|
</div>
|
||||||
<div class="selectionBox">
|
<div class="selectionBox">
|
||||||
@ -165,12 +153,16 @@ export class DeesInputDropdown extends DeesElement {
|
|||||||
detail: selectedOption,
|
detail: selectedOption,
|
||||||
bubbles: true
|
bubbles: true
|
||||||
}));
|
}));
|
||||||
this.toggleSelectionBox();
|
this.openSelectionBox();
|
||||||
this.changeSubject.next(this);
|
this.changeSubject.next(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleSelectionBox() {
|
public openSelectionBox() {
|
||||||
this.shadowRoot.querySelector('.selectedBox').classList.toggle('show');
|
this.shadowRoot.querySelector('.selectedBox').classList.toggle('show');
|
||||||
this.shadowRoot.querySelector('.selectionBox').classList.toggle('show');
|
this.shadowRoot.querySelector('.selectionBox').classList.toggle('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public closeSelectionBox() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,9 @@ import {
|
|||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
cssManager,
|
cssManager,
|
||||||
type CSSResult,
|
type CSSResult,
|
||||||
|
domtools,
|
||||||
} from '@design.estate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
|
|
||||||
import * as domtools from '@design.estate/dees-domtools';
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
'dees-input-fileupload': DeesInputFileupload;
|
'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>`;
|
public static demo = () => html`<dees-input-fileupload .label=${'Attachments'}></dees-input-fileupload>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
|
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}`;
|
||||||
|
}
|
||||||
|
}
|
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>`;
|
public static demo = () => html`<dees-input-quantityselector></dees-input-quantityselector>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
public label: string = 'Label';
|
public label: string = 'Label';
|
||||||
|
@ -12,7 +12,7 @@ export class DeesInputRadio extends DeesElement {
|
|||||||
public static demo = () => html`<dees-input-radio></dees-input-radio>`;
|
public static demo = () => html`<dees-input-radio></dees-input-radio>`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject();
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
|
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';
|
import * as domtools from '@design.estate/dees-domtools';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@ -15,11 +24,10 @@ export class DeesInputText extends DeesElement {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public changeSubject = new domtools.rxjs.Subject<DeesInputText>();
|
public changeSubject = new domtools.plugins.smartrx.rxjs.Subject<DeesInputText>();
|
||||||
public valueChangeSubject = new domtools.rxjs.Subject<string>();
|
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: String
|
type: String,
|
||||||
})
|
})
|
||||||
public label: string;
|
public label: string;
|
||||||
|
|
||||||
@ -36,12 +44,12 @@ export class DeesInputText extends DeesElement {
|
|||||||
public value: string = '';
|
public value: string = '';
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public required: boolean = false;
|
public required: boolean = false;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean
|
type: Boolean,
|
||||||
})
|
})
|
||||||
public disabled: boolean = false;
|
public disabled: boolean = false;
|
||||||
|
|
||||||
@ -57,93 +65,160 @@ export class DeesInputText extends DeesElement {
|
|||||||
})
|
})
|
||||||
public showPasswordBool = false;
|
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;
|
||||||
|
// see template for more
|
||||||
|
}
|
||||||
|
|
||||||
|
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: 7px;
|
||||||
|
right: 10px;
|
||||||
|
border: 1px dashed #444;
|
||||||
|
border-radius: 7px;
|
||||||
|
padding: 4px 0px;
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.showPassword:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
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 {
|
public render(): TemplateResult {
|
||||||
return html `
|
return html`
|
||||||
<style>
|
<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 {
|
input {
|
||||||
margin-top: 5px;
|
font-family: ${this.isPasswordBool ? 'monospace' : 'Inter'};
|
||||||
background: ${this.goBright ? '#fafafa' : '#222'};
|
letter-spacing: ${this.isPasswordBool ? '1px' : 'normal'};
|
||||||
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'};
|
|
||||||
color: ${this.goBright ? '#333' : '#ccc'};
|
color: ${this.goBright ? '#333' : '#ccc'};
|
||||||
}
|
}
|
||||||
|
${this.validationText ? css`
|
||||||
input:disabled {
|
.validationContainer {
|
||||||
background: ${cssManager.bdTheme('#ffffff00', '#11111100')};
|
height: 22px;
|
||||||
border: 1px dashed ${cssManager.bdTheme('#666666', '#666666')};
|
opacity: 1;
|
||||||
color: #9b9b9e;
|
}
|
||||||
cursor: default;
|
` : css`
|
||||||
}
|
.validationContainer {
|
||||||
|
height: 4px;
|
||||||
input:focus {
|
padding: 2px !important;
|
||||||
outline: none;
|
opacity: 0;
|
||||||
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: ${cssManager.bdTheme('#00000010', '#ffffff10')};
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
<div class="maincontainer">
|
<div class="maincontainer">
|
||||||
${this.label ? html`<div class="label">${this.label}</div>` : html``}
|
${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} />
|
<input
|
||||||
${this.isPasswordBool ? html`
|
type="${this.isPasswordBool && !this.showPasswordBool ? 'password' : 'text'}"
|
||||||
<div class="showPassword" @click=${this.togglePasswordView}>
|
.value=${this.value}
|
||||||
<dees-icon .iconFA=${this.showPasswordBool ? 'eye' : 'eyeSlash'}></dees-icon>
|
@input="${this.updateValue}"
|
||||||
</div>
|
.disabled=${this.disabled}
|
||||||
` : html``}
|
/>
|
||||||
|
<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>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstUpdated() {
|
||||||
|
const input = this.shadowRoot.querySelector('input');
|
||||||
|
input.addEventListener('input', (eventArg: InputEvent) => {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public async updateValue(eventArg: Event) {
|
public async updateValue(eventArg: Event) {
|
||||||
const target: any = eventArg.target;
|
const target: any = eventArg.target;
|
||||||
this.value = target.value;
|
this.value = target.value;
|
||||||
this.changeSubject.next(this);
|
this.changeSubject.next(this);
|
||||||
this.valueChangeSubject.next(this.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async freeze() {
|
public async freeze() {
|
||||||
@ -154,10 +229,10 @@ export class DeesInputText extends DeesElement {
|
|||||||
this.disabled = false;
|
this.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async togglePasswordView () {
|
public async togglePasswordView() {
|
||||||
const domtools = await this.domtoolsPromise;
|
const domtools = await this.domtoolsPromise;
|
||||||
this.showPasswordBool = !this.showPasswordBool;
|
this.showPasswordBool = !this.showPasswordBool;
|
||||||
console.log(`this.showPasswordBool is: ${this.showPasswordBool}`)
|
console.log(`this.showPasswordBool is: ${this.showPasswordBool}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async focus() {
|
public async focus() {
|
||||||
|
@ -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;
|
||||||
@ -88,6 +88,34 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
})
|
})
|
||||||
public data: T[] = [];
|
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({
|
@property({
|
||||||
type: String,
|
type: String,
|
||||||
reflect: true,
|
reflect: true,
|
||||||
@ -235,6 +263,8 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
th,
|
th,
|
||||||
td {
|
td {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
vertical-align: top;
|
||||||
|
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')};
|
border-right: 1px dashed ${cssManager.bdTheme('#999', '#808080')};
|
||||||
}
|
}
|
||||||
@ -335,7 +365,7 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
<!-- the heading part -->
|
<!-- the heading part -->
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="headingContainer">
|
<div class="headingContainer">
|
||||||
<div class="heading heading1">${this.heading1}</div>
|
<div class="heading heading1">${this.label || this.heading1}</div>
|
||||||
<div class="heading heading2">${this.heading2}</div>
|
<div class="heading heading2">${this.heading2}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="headerActions">
|
<div class="headerActions">
|
||||||
@ -366,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
|
||||||
@ -494,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`
|
||||||
@ -558,40 +591,51 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
|
|
||||||
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);
|
||||||
this.freezeColumnWidths();
|
this.determineColumnWidths();
|
||||||
}
|
}
|
||||||
|
|
||||||
freezeColumnWidths() {
|
public async determineColumnWidths() {
|
||||||
|
const domtools = await this.domtoolsPromise;
|
||||||
|
await domtools.convenience.smartdelay.delayFor(0);
|
||||||
// Get the table element
|
// Get the table element
|
||||||
const table = this.shadowRoot.querySelector('table');
|
const table = this.shadowRoot.querySelector('table');
|
||||||
if (!table) return;
|
if (!table) return;
|
||||||
|
|
||||||
// Create a colgroup if it doesn't exist
|
|
||||||
let colgroup = table.querySelector('colgroup');
|
|
||||||
if (!colgroup) {
|
|
||||||
colgroup = document.createElement('colgroup');
|
|
||||||
table.insertBefore(colgroup, table.firstChild);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the first row's cells to measure the widths
|
// Get the first row's cells to measure the widths
|
||||||
const cells = table.rows[0].cells;
|
const cells = table.rows[0].cells;
|
||||||
|
|
||||||
for (let i = 0; i < cells.length; i++) {
|
const handleColumnByIndex = async (i: number, waitForRenderArg: boolean = false) => {
|
||||||
|
const done = plugins.smartpromise.defer();
|
||||||
const cell = cells[i];
|
const cell = cells[i];
|
||||||
|
|
||||||
// Get computed width
|
// Get computed width
|
||||||
const width = window.getComputedStyle(cell).width;
|
const width = window.getComputedStyle(cell).width;
|
||||||
|
if (cell.textContent.includes('Actions')) {
|
||||||
// Check if there's already a <col> for this cell
|
const neededWidth =
|
||||||
let col = colgroup.children[i] as HTMLElement;
|
this.dataActions.filter((actionArg) => actionArg.type.includes('inRow')).length * 35;
|
||||||
if (!col) {
|
cell.style.width = `${Math.max(neededWidth, 68)}px`;
|
||||||
col = document.createElement('col');
|
} else {
|
||||||
colgroup.appendChild(col);
|
cell.style.width = width;
|
||||||
}
|
}
|
||||||
|
if (waitForRenderArg) {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
await done.promise;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Set the width
|
if (cells[cells.length - 1].textContent.includes('Actions')) {
|
||||||
col.style.width = width;
|
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]) {
|
getActionsForType(typeArg: ITableAction['type'][0]) {
|
||||||
@ -621,6 +665,7 @@ export class DeesTable<T> extends DeesElement {
|
|||||||
}
|
}
|
||||||
if (saveArg) {
|
if (saveArg) {
|
||||||
itemArg[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
|
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();
|
input.remove();
|
||||||
target.style.color = originalColor;
|
target.style.color = originalColor;
|
||||||
|
@ -66,14 +66,22 @@ export class DeesWindowLayer extends DeesElement {
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 200;
|
z-index: 200;
|
||||||
}
|
}
|
||||||
|
.slotContent {
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.visible {
|
.visible {
|
||||||
background: rgba(0, 0, 0, 0.2);
|
background: rgba(0, 0, 0, 0.2);
|
||||||
backdrop-filter: brightness(0.9) ${this.options.blur ? 'blur(2px)' : ''};
|
backdrop-filter: brightness(0.9) ${this.options.blur ? 'blur(2px)' : ''};
|
||||||
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>
|
||||||
`;
|
`;
|
||||||
|
@ -11,6 +11,8 @@ export * from './dees-icon.js';
|
|||||||
export * from './dees-input-checkbox.js';
|
export * from './dees-input-checkbox.js';
|
||||||
export * from './dees-input-dropdown.js';
|
export * from './dees-input-dropdown.js';
|
||||||
export * from './dees-input-fileupload.js';
|
export * from './dees-input-fileupload.js';
|
||||||
|
export * from './dees-input-iban.js';
|
||||||
|
export * from './dees-input-phone.js';
|
||||||
export * from './dees-input-quantityselector.js';
|
export * from './dees-input-quantityselector.js';
|
||||||
export * from './dees-input-radio.js';
|
export * from './dees-input-radio.js';
|
||||||
export * from './dees-input-text.js';
|
export * from './dees-input-text.js';
|
||||||
|
@ -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