Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 212a46894e | |||
| 653ef109be | |||
| a0b17132ad | |||
| 486ec11ce6 |
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-04-12 - 3.74.0 - feat(input-text)
|
||||||
|
add validated success state and text editing context menu to text inputs
|
||||||
|
|
||||||
|
- show a delayed checkmark confirmation for successful validation and hide inline validation text afterward
|
||||||
|
- move IBAN validation handling into the shared text input validation function
|
||||||
|
- improve the email validation demo to use a stricter regex-based check
|
||||||
|
- add cut, copy, paste, and select-all context menu actions for text inputs
|
||||||
|
|
||||||
## 2026-04-12 - 3.73.2 - fix(input,label)
|
## 2026-04-12 - 3.73.2 - fix(input,label)
|
||||||
correct validation state attribute handling in text inputs and refine label description icon styling
|
correct validation state attribute handling in text inputs and refine label description icon styling
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@design.estate/dees-catalog",
|
"name": "@design.estate/dees-catalog",
|
||||||
"version": "3.73.2",
|
"version": "3.74.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.",
|
"description": "A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.",
|
||||||
"main": "dist_ts_web/index.js",
|
"main": "dist_ts_web/index.js",
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@design.estate/dees-catalog',
|
name: '@design.estate/dees-catalog',
|
||||||
version: '3.73.2',
|
version: '3.74.0',
|
||||||
description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
|
description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,16 @@ export class DeesInputIban extends DeesInputBase<DeesInputIban> {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
.placeholder=${'DE89 3704 0044 0532 0130 00'}
|
.placeholder=${'DE89 3704 0044 0532 0130 00'}
|
||||||
|
.validationFunction=${(value: string) => {
|
||||||
|
const normalized = value.replace(/ /g, '');
|
||||||
|
if (normalized.length === 0) {
|
||||||
|
return { valid: true, message: '' };
|
||||||
|
}
|
||||||
|
const isValid = ibantools.isValidIBAN(normalized);
|
||||||
|
return isValid
|
||||||
|
? { valid: true, message: 'IBAN is valid' }
|
||||||
|
: { valid: false, message: 'Please enter a valid IBAN' };
|
||||||
|
}}
|
||||||
@input=${(eventArg: InputEvent) => {
|
@input=${(eventArg: InputEvent) => {
|
||||||
this.validateIban(eventArg);
|
this.validateIban(eventArg);
|
||||||
}}
|
}}
|
||||||
@@ -81,10 +91,6 @@ export class DeesInputIban extends DeesInputBase<DeesInputIban> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.enteredIbanIsValid = ibantools.isValidIBAN(this.enteredString.replace(/ /g, ''));
|
this.enteredIbanIsValid = ibantools.isValidIBAN(this.enteredString.replace(/ /g, ''));
|
||||||
const deesInputText = this.shadowRoot!.querySelector('dees-input-text') as any;
|
|
||||||
if (deesInputText) {
|
|
||||||
deesInputText.validationText = `IBAN is valid: ${this.enteredIbanIsValid}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getValue(): string {
|
public getValue(): string {
|
||||||
|
|||||||
@@ -210,39 +210,7 @@ export const demoFunc = () => html`
|
|||||||
</dees-panel>
|
</dees-panel>
|
||||||
</dees-demowrapper>
|
</dees-demowrapper>
|
||||||
|
|
||||||
<dees-demowrapper .runAfterRender=${async (elementArg: HTMLElement) => {
|
<dees-demowrapper>
|
||||||
// Demonstrate validation states
|
|
||||||
const requiredInput = elementArg.querySelector('dees-input-text[required]') as DeesInputText;
|
|
||||||
const disabledInput = elementArg.querySelector('dees-input-text[disabled]') as DeesInputText;
|
|
||||||
const errorInput = elementArg.querySelector('dees-input-text[validationState="invalid"]') as DeesInputText;
|
|
||||||
|
|
||||||
if (requiredInput) {
|
|
||||||
// Show validation on blur for empty required field
|
|
||||||
requiredInput.addEventListener('blur', () => {
|
|
||||||
if (!requiredInput.getValue()) {
|
|
||||||
console.log('Required field is empty!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disabledInput) {
|
|
||||||
console.log('Disabled input cannot be edited');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorInput) {
|
|
||||||
console.log('Error input shows validation message:', errorInput.validationText);
|
|
||||||
|
|
||||||
// Simulate fixing the error
|
|
||||||
errorInput.addEventListener('changeSubject', () => {
|
|
||||||
const value = errorInput.getValue();
|
|
||||||
if (value.includes('@') && value.includes('.')) {
|
|
||||||
errorInput.validationState = 'valid';
|
|
||||||
errorInput.validationText = '';
|
|
||||||
console.log('Email validation passed!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
<dees-panel .title=${'Validation & States'} .subtitle=${'Different validation states and input configurations'}>
|
<dees-panel .title=${'Validation & States'} .subtitle=${'Different validation states and input configurations'}>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<dees-input-text
|
<dees-input-text
|
||||||
@@ -258,10 +226,15 @@ export const demoFunc = () => html`
|
|||||||
></dees-input-text>
|
></dees-input-text>
|
||||||
|
|
||||||
<dees-input-text
|
<dees-input-text
|
||||||
.label=${'Field with Error'}
|
.label=${'Email with Validation'}
|
||||||
.value=${'invalid@'}
|
.value=${'invalid@'}
|
||||||
.validationText=${'Please enter a valid email address'}
|
.validationFunction=${(value: string) => {
|
||||||
.validationState=${'invalid'}
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
if (emailRegex.test(value)) {
|
||||||
|
return { valid: true, message: 'Email address is valid' };
|
||||||
|
}
|
||||||
|
return { valid: false, message: 'Please enter a valid email address' };
|
||||||
|
}}
|
||||||
></dees-input-text>
|
></dees-input-text>
|
||||||
</div>
|
</div>
|
||||||
</dees-panel>
|
</dees-panel>
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ import {
|
|||||||
customElement,
|
customElement,
|
||||||
type TemplateResult,
|
type TemplateResult,
|
||||||
property,
|
property,
|
||||||
|
state,
|
||||||
html,
|
html,
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
} from '@design.estate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
import { themeDefaultStyles } from '../../00theme.js';
|
import { themeDefaultStyles } from '../../00theme.js';
|
||||||
|
import '../../00group-overlay/dees-contextmenu/dees-contextmenu.js';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
@@ -54,8 +56,8 @@ export class DeesInputText extends DeesInputBase {
|
|||||||
})
|
})
|
||||||
accessor validationText: string = '';
|
accessor validationText: string = '';
|
||||||
|
|
||||||
@property({})
|
@property({ attribute: false })
|
||||||
accessor validationFunction!: (value: string) => boolean;
|
accessor validationFunction!: (value: string) => { valid: boolean; message?: string };
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -63,6 +65,11 @@ export class DeesInputText extends DeesInputBase {
|
|||||||
})
|
})
|
||||||
accessor vintegrated: boolean = false;
|
accessor vintegrated: boolean = false;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
accessor validConfirmed: boolean = false;
|
||||||
|
|
||||||
|
private validTimeout: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
|
||||||
public static styles = [
|
public static styles = [
|
||||||
themeDefaultStyles,
|
themeDefaultStyles,
|
||||||
...DeesInputBase.baseStyles,
|
...DeesInputBase.baseStyles,
|
||||||
@@ -145,6 +152,33 @@ export class DeesInputText extends DeesInputBase {
|
|||||||
color: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 93.9%)')};
|
color: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 93.9%)')};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Valid checkmark icon */
|
||||||
|
.validIcon {
|
||||||
|
position: absolute;
|
||||||
|
right: 8px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: ${cssManager.bdTheme('hsl(142.1 76.2% 36.3%)', 'hsl(142.1 70.6% 45.3%)')};
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.validIcon.show {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.validIcon dees-icon {
|
||||||
|
font-size: 14px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
/* Validation styles */
|
/* Validation styles */
|
||||||
.validationContainer {
|
.validationContainer {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
@@ -156,7 +190,7 @@ export class DeesInputText extends DeesInputBase {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.validationContainer.error {
|
.validationContainer.invalid {
|
||||||
background: ${cssManager.bdTheme('hsl(0 84.2% 60.2% / 0.1)', 'hsl(0 72.2% 50.6% / 0.1)')};
|
background: ${cssManager.bdTheme('hsl(0 84.2% 60.2% / 0.1)', 'hsl(0 72.2% 50.6% / 0.1)')};
|
||||||
color: ${cssManager.bdTheme('hsl(0 84.2% 60.2%)', 'hsl(0 72.2% 50.6%)')};
|
color: ${cssManager.bdTheme('hsl(0 84.2% 60.2%)', 'hsl(0 72.2% 50.6%)')};
|
||||||
}
|
}
|
||||||
@@ -239,9 +273,9 @@ export class DeesInputText extends DeesInputBase {
|
|||||||
input {
|
input {
|
||||||
font-family: ${this.isPasswordBool ? cssMonoFontFamily : 'inherit'};
|
font-family: ${this.isPasswordBool ? cssMonoFontFamily : 'inherit'};
|
||||||
letter-spacing: ${this.isPasswordBool ? '0.5px' : 'normal'};
|
letter-spacing: ${this.isPasswordBool ? '0.5px' : 'normal'};
|
||||||
padding-right: ${this.isPasswordBool ? '48px' : '12px'};
|
padding-right: ${this.isPasswordBool ? '48px' : this.validConfirmed ? '40px' : '12px'};
|
||||||
}
|
}
|
||||||
${this.validationText
|
${this.validationText && !this.validConfirmed
|
||||||
? css`
|
? css`
|
||||||
.validationContainer {
|
.validationContainer {
|
||||||
height: auto;
|
height: auto;
|
||||||
@@ -275,9 +309,12 @@ export class DeesInputText extends DeesInputBase {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: html``}
|
: html``}
|
||||||
|
<div class="validIcon ${this.validConfirmed ? 'show' : ''}">
|
||||||
|
<dees-icon .icon=${'lucide:Check'}></dees-icon>
|
||||||
|
</div>
|
||||||
${this.validationText
|
${this.validationText
|
||||||
? html`
|
? html`
|
||||||
<div class="validationContainer ${this.validationState || 'error'}">
|
<div class="validationContainer ${this.validationState || 'invalid'}">
|
||||||
${this.validationText}
|
${this.validationText}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -288,15 +325,97 @@ export class DeesInputText extends DeesInputBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated() {
|
firstUpdated() {
|
||||||
// Input event handling is already done in updateValue method
|
if (this.validationFunction && this.value) {
|
||||||
|
const result = this.validationFunction(this.value);
|
||||||
|
this.validationState = result.valid ? 'valid' : 'invalid';
|
||||||
|
this.validationText = result.message || '';
|
||||||
|
if (result.valid) {
|
||||||
|
this.validConfirmed = false;
|
||||||
|
this.validTimeout = setTimeout(() => {
|
||||||
|
this.validConfirmed = true;
|
||||||
|
this.validationState = undefined as any;
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
if (this.validationFunction) {
|
||||||
|
const result = this.validationFunction(this.value);
|
||||||
|
this.validationState = result.valid ? 'valid' : 'invalid';
|
||||||
|
this.validationText = result.message || '';
|
||||||
|
if (result.valid) {
|
||||||
|
this.validConfirmed = false;
|
||||||
|
clearTimeout(this.validTimeout);
|
||||||
|
this.validTimeout = setTimeout(() => {
|
||||||
|
this.validConfirmed = true;
|
||||||
|
this.validationState = undefined as any;
|
||||||
|
}, 500);
|
||||||
|
} else {
|
||||||
|
clearTimeout(this.validTimeout);
|
||||||
|
this.validConfirmed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.changeSubject.next(this);
|
this.changeSubject.next(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getContextMenuItems() {
|
||||||
|
const input = this.shadowRoot!.querySelector('input')!;
|
||||||
|
const hasSelection = input.selectionStart !== input.selectionEnd;
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: 'Cut',
|
||||||
|
iconName: 'lucide:Scissors',
|
||||||
|
shortcut: 'Cmd+X',
|
||||||
|
disabled: !hasSelection,
|
||||||
|
action: async () => {
|
||||||
|
const selected = this.value.substring(input.selectionStart!, input.selectionEnd!);
|
||||||
|
await navigator.clipboard.writeText(selected);
|
||||||
|
const start = input.selectionStart!;
|
||||||
|
this.value = this.value.substring(0, start) + this.value.substring(input.selectionEnd!);
|
||||||
|
input.value = this.value;
|
||||||
|
input.setSelectionRange(start, start);
|
||||||
|
this.changeSubject.next(this);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Copy',
|
||||||
|
iconName: 'lucide:Copy',
|
||||||
|
shortcut: 'Cmd+C',
|
||||||
|
disabled: !hasSelection,
|
||||||
|
action: async () => {
|
||||||
|
const selected = this.value.substring(input.selectionStart!, input.selectionEnd!);
|
||||||
|
await navigator.clipboard.writeText(selected);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Paste',
|
||||||
|
iconName: 'lucide:ClipboardPaste',
|
||||||
|
shortcut: 'Cmd+V',
|
||||||
|
action: async () => {
|
||||||
|
const text = await navigator.clipboard.readText();
|
||||||
|
const start = input.selectionStart!;
|
||||||
|
const end = input.selectionEnd!;
|
||||||
|
this.value = this.value.substring(0, start) + text + this.value.substring(end);
|
||||||
|
input.value = this.value;
|
||||||
|
input.setSelectionRange(start + text.length, start + text.length);
|
||||||
|
this.changeSubject.next(this);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ divider: true },
|
||||||
|
{
|
||||||
|
name: 'Select All',
|
||||||
|
iconName: 'lucide:TextCursorInput',
|
||||||
|
shortcut: 'Cmd+A',
|
||||||
|
action: async () => {
|
||||||
|
input.select();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public getValue(): string {
|
public getValue(): string {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user