// all examples in this section are taken from the product demo page on ampbyexample.com
https://ampbyexample.com/samples_templates/product_page/
`` tab content: https://codepen.io/cathyxz/pen/vReqdy
// all examples in this section are taken from the product demo page on ampbyexample.com
https://ampbyexample.com/samples_templates/product_page/
`` tab content: https://codepen.io/cathyxz/pen/vReqdy
| type State = { | |
| added: boolean; | |
| interval: false | ReturnType<typeof setInterval>; | |
| inFrame: boolean; | |
| callbacks: Array<SetFocusedCallback>; | |
| }; | |
| type EnrichedHTMLIFrameElement = HTMLIFrameElement & { ___onWindowFocusHandled: boolean }; | |
| type SetFocusedCallback = (focused?: boolean) => void; |
| type ValidationResult<T, U> = Partial<{ [Key in keyof T]: U }>; | |
| type Validation<T, U> = (input: T) => ValidationResult<T, U>; | |
| const mergeAll = <T, U>( | |
| results: ValidationResult<T, U>[] | |
| ): ValidationResult<T, U> => | |
| results.reduce((acc, a) => Object.assign(acc, a), {}); | |
| const validate = <T, U = boolean | string>( | |
| validations: Validation<T, U>[] |