Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c7b5dc690 | |||
| 2f4afddf73 | |||
| 212a46894e | |||
| 653ef109be | |||
| a0b17132ad | |||
| 486ec11ce6 |
14
changelog.md
14
changelog.md
@@ -1,5 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## 2026-04-12 - 3.74.1 - fix(dees-input-text)
|
||||
adjust password toggle and validation icon alignment in text input
|
||||
|
||||
- positions the password toggle and validation icon with fixed top offsets for improved vertical alignment
|
||||
- updates the validation icon styling to use a larger themed icon without the circular background
|
||||
|
||||
## 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)
|
||||
correct validation state attribute handling in text inputs and refine label description icon styling
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@design.estate/dees-catalog",
|
||||
"version": "3.73.2",
|
||||
"version": "3.74.1",
|
||||
"private": false,
|
||||
"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",
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@design.estate/dees-catalog',
|
||||
version: '3.73.2',
|
||||
version: '3.74.1',
|
||||
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}
|
||||
.required=${this.required}
|
||||
.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) => {
|
||||
this.validateIban(eventArg);
|
||||
}}
|
||||
@@ -81,10 +91,6 @@ export class DeesInputIban extends DeesInputBase<DeesInputIban> {
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
||||
@@ -210,39 +210,7 @@ export const demoFunc = () => html`
|
||||
</dees-panel>
|
||||
</dees-demowrapper>
|
||||
|
||||
<dees-demowrapper .runAfterRender=${async (elementArg: HTMLElement) => {
|
||||
// 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-demowrapper>
|
||||
<dees-panel .title=${'Validation & States'} .subtitle=${'Different validation states and input configurations'}>
|
||||
<div class="input-group">
|
||||
<dees-input-text
|
||||
@@ -258,10 +226,15 @@ export const demoFunc = () => html`
|
||||
></dees-input-text>
|
||||
|
||||
<dees-input-text
|
||||
.label=${'Field with Error'}
|
||||
.label=${'Email with Validation'}
|
||||
.value=${'invalid@'}
|
||||
.validationText=${'Please enter a valid email address'}
|
||||
.validationState=${'invalid'}
|
||||
.validationFunction=${(value: string) => {
|
||||
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>
|
||||
</div>
|
||||
</dees-panel>
|
||||
|
||||
@@ -7,11 +7,13 @@ import {
|
||||
customElement,
|
||||
type TemplateResult,
|
||||
property,
|
||||
state,
|
||||
html,
|
||||
cssManager,
|
||||
css,
|
||||
} from '@design.estate/dees-element';
|
||||
import { themeDefaultStyles } from '../../00theme.js';
|
||||
import '../../00group-overlay/dees-contextmenu/dees-contextmenu.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
@@ -54,8 +56,8 @@ export class DeesInputText extends DeesInputBase {
|
||||
})
|
||||
accessor validationText: string = '';
|
||||
|
||||
@property({})
|
||||
accessor validationFunction!: (value: string) => boolean;
|
||||
@property({ attribute: false })
|
||||
accessor validationFunction!: (value: string) => { valid: boolean; message?: string };
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
@@ -63,6 +65,11 @@ export class DeesInputText extends DeesInputBase {
|
||||
})
|
||||
accessor vintegrated: boolean = false;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor validConfirmed: boolean = false;
|
||||
|
||||
private validTimeout: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
public static styles = [
|
||||
themeDefaultStyles,
|
||||
...DeesInputBase.baseStyles,
|
||||
@@ -127,7 +134,7 @@ export class DeesInputText extends DeesInputBase {
|
||||
.showPassword {
|
||||
position: absolute;
|
||||
right: 1px;
|
||||
top: 50%;
|
||||
top: 20px;
|
||||
transform: translateY(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -145,6 +152,29 @@ export class DeesInputText extends DeesInputBase {
|
||||
color: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 93.9%)')};
|
||||
}
|
||||
|
||||
/* Valid checkmark icon */
|
||||
.validIcon {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 20px;
|
||||
transform: translateY(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
pointer-events: none;
|
||||
color: ${cssManager.bdTheme('hsl(142.1 76.2% 36.3%)', 'hsl(142.1 70.6% 45.3%)')};
|
||||
}
|
||||
|
||||
.validIcon.show {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.validIcon dees-icon {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
/* Validation styles */
|
||||
.validationContainer {
|
||||
margin-top: 4px;
|
||||
@@ -156,7 +186,7 @@ export class DeesInputText extends DeesInputBase {
|
||||
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)')};
|
||||
color: ${cssManager.bdTheme('hsl(0 84.2% 60.2%)', 'hsl(0 72.2% 50.6%)')};
|
||||
}
|
||||
@@ -239,9 +269,9 @@ export class DeesInputText extends DeesInputBase {
|
||||
input {
|
||||
font-family: ${this.isPasswordBool ? cssMonoFontFamily : 'inherit'};
|
||||
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`
|
||||
.validationContainer {
|
||||
height: auto;
|
||||
@@ -275,9 +305,12 @@ export class DeesInputText extends DeesInputBase {
|
||||
</div>
|
||||
`
|
||||
: html``}
|
||||
<div class="validIcon ${this.validConfirmed ? 'show' : ''}">
|
||||
<dees-icon .icon=${'lucide:Check'}></dees-icon>
|
||||
</div>
|
||||
${this.validationText
|
||||
? html`
|
||||
<div class="validationContainer ${this.validationState || 'error'}">
|
||||
<div class="validationContainer ${this.validationState || 'invalid'}">
|
||||
${this.validationText}
|
||||
</div>
|
||||
`
|
||||
@@ -288,15 +321,97 @@ export class DeesInputText extends DeesInputBase {
|
||||
}
|
||||
|
||||
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) {
|
||||
const target: any = eventArg.target;
|
||||
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);
|
||||
}
|
||||
|
||||
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 {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user