Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/errorIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/successIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/core/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import {
appendZeroToOne, domReady, getMaskedOutput, handleCopyIconClick, styleToString,
} from '../../utils/helpers';
import { ContainerType } from '../../skyflow';
import successIcon from '../../../assets/successIcon.svg'
import errorIcon from '../../../assets/errorIcon.svg'

export class FrameController {
controller?: FrameController;
Expand Down Expand Up @@ -128,6 +130,10 @@ export class FrameElement {

private isRequiredLabel?: HTMLLabelElement;

private isValidIcon?: HTMLImageElement;

private isInvalidIcon?: HTMLImageElement;

private dropdownIcon?: HTMLImageElement;

private dropdownSelect?: HTMLSelectElement;
Expand Down Expand Up @@ -239,6 +245,16 @@ export class FrameElement {
this.isRequiredLabel.className = `SkyflowElement-label-${this.options.elementName}-${STYLE_TYPE.REQUIRED_ASTERISK}`;
this.labelDiv.append(this.isRequiredLabel);
}
if (this.domError) {
this.isValidIcon = document.createElement('img');
this.isValidIcon.src = successIcon;
this.labelDiv.append(this.isValidIcon);
}
if (this.domError) {
this.isInvalidIcon = document.createElement('img');
this.isInvalidIcon.src = errorIcon;
this.labelDiv.append(this.isInvalidIcon);
}
this.iFrameFormElement.on(ELEMENT_EVENTS_TO_CLIENT.FOCUS, (state) => {
this.focusChange(true);
state.isEmpty = !state.value;
Expand Down Expand Up @@ -296,6 +312,18 @@ export class FrameElement {
this.domCopy.style.display = 'none';
}

if (!state.isEmpty && state.isValid && this.domError && this.isValidIcon) {
this.isValidIcon.style.display = 'block';
} else if(this.isValidIcon) {
this.isValidIcon.style.display = 'none';
}

if(!state.isEmpty && !state.isValid && this.domError && this.isInvalidIcon) {
this.isInvalidIcon.style.display = 'block';
} else if(this.isInvalidIcon) {
this.isInvalidIcon.style.display = 'none';
}

// On CHANGE set isEmpty to false
state.isEmpty = !state.value;

Expand Down