Move utility functions to common functions
[MAILPOET-2677]
This commit is contained in:
committed by
Veljko V
parent
50ca3b7310
commit
dc0fc44194
8
assets/js/src/common/functions/change_handlers.ts
Normal file
8
assets/js/src/common/functions/change_handlers.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ChangeEvent } from 'react';
|
||||
|
||||
type Setter = (value: string) => any
|
||||
type Event = ChangeEvent<any>
|
||||
|
||||
export const onChange = (setter: Setter) => (e: Event) => setter(e.target.value);
|
||||
|
||||
export const onToggle = (setter: Setter) => (e: Event) => setter(e.target.checked ? '1' : '0');
|
3
assets/js/src/common/functions/index.ts
Normal file
3
assets/js/src/common/functions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './change_handlers';
|
||||
export { default as t } from './t';
|
||||
export { default as isEmail } from './is_email';
|
1
assets/js/src/common/functions/is_email.ts
Normal file
1
assets/js/src/common/functions/is_email.ts
Normal file
@@ -0,0 +1 @@
|
||||
export default (value: string): boolean => (window as any).mailpoet_email_regex.test(value);
|
3
assets/js/src/common/functions/t.ts
Normal file
3
assets/js/src/common/functions/t.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import MailPoet from 'mailpoet';
|
||||
|
||||
export default ([word]: TemplateStringsArray) => MailPoet.I18n.t(word);
|
Reference in New Issue
Block a user