2024-10-29 12:23:04 +00:00
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { map } from '@ember/object/computed';
|
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
2024-10-28 15:33:17 +00:00
|
|
|
|
2024-10-29 12:23:04 +00:00
|
|
|
const re = /.+@\S+\.\S+/;
|
2024-10-28 15:33:17 +00:00
|
|
|
|
|
|
|
export interface UtilMailEntrySignature {
|
|
|
|
// The arguments accepted by the component
|
|
|
|
Args: {
|
2024-10-29 12:23:04 +00:00
|
|
|
data: { mail: string; valid: boolean };
|
|
|
|
};
|
2024-10-28 15:33:17 +00:00
|
|
|
// Any blocks yielded by the component
|
|
|
|
Blocks: {
|
2024-10-29 12:23:04 +00:00
|
|
|
default: [];
|
|
|
|
};
|
2024-10-28 15:33:17 +00:00
|
|
|
// The element to which `...attributes` is applied in the component template
|
2024-10-29 12:23:04 +00:00
|
|
|
Element: null;
|
2024-10-28 15:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class UtilMailEntry extends Component<UtilMailEntrySignature> {
|
2024-10-29 12:23:04 +00:00
|
|
|
@tracked mailOk = this.args.data.valid;
|
2024-10-28 15:33:17 +00:00
|
|
|
@action checkMail() {
|
2024-10-29 12:23:04 +00:00
|
|
|
this.args.data.valid = re.test(this.args.data.mail);
|
|
|
|
this.mailOk = this.args.data.valid;
|
2024-10-28 15:33:17 +00:00
|
|
|
}
|
|
|
|
}
|