Anything can implement persistent-form protocol.
import React, { Component } from 'react';
import { setPersisted, getPersisted } from 'react-persistent-form';
class CustomInput extends Component {
render () {| function getType (value: string | String): 'String'; | |
| function getType (value: number | Number): 'Number'; | |
| function getType (value: boolean | Boolean): 'Boolean'; | |
| function getType (value: any): string { | |
| const string = Object.prototype.toString.call(value); | |
| const type = string.substring(8, string.length - 1); | |
| return type; | |
| } | |
| function isType (value: any, type: 'String'): value is String; |
| const wait = (time: number) => new Promise((resolve) => setTimeout(resolve, time)); | |
| type InsistΛ = () => boolean | Promise<boolean>; | |
| const insist = (λ: InsistΛ, time: number = 200): Promise<void> => { | |
| return new Promise((resolve) => { | |
| const insist = () => Promise.resolve(λ()) | |
| .then((success: boolean) => { | |
| if (!success) | |
| throw new Error('Success not achieved. Keep insisting.'); |
| <template> | |
| <form @submit.prevent="submit()"> | |
| <fieldset> | |
| <label :for="'filter-include-' + hash">Filtros</label> | |
| <select> | |
| <option v-for="(option, property) in options" :key="option" :value=""> | |
| </option> | |
| </select> | |
| <button type="button" @click="exclude(filter)">Excluir</button> |
| <template> | |
| <fieldset class="actions dynamic-filter-actions"> | |
| <slot> | |
| <dynamic-filter-button class="action" type="submit"> | |
| Aplicar Filtros | |
| </dynamic-filter-button> | |
| </slot> | |
| </fieldset> | |
| </template> |
| const baseURL = process.env.API || ''; | |
| const resolveURL = (url: string): string => { | |
| const [ , protocol = '', domain = '' ] = /(https?:\/\/)?(.*)/.exec(url); | |
| return protocol + domain.replace(/\/+/g, '/'); | |
| }; | |
| const getHeaders = (): { [key: string]: string } => { | |
| const token = localStorage.getItem('token') as string; | |
| const headers = { |
| /** | |
| * Global object type. | |
| * @typedef {(NodeJS.Global|Window)} Global | |
| */ | |
| /** | |
| * Resolve and return global object. | |
| * @returns {Global} | |
| */ | |
| export const resolveGlobal = () => { |
| import { Constants } from 'expo'; | |
| import { Dimensions, Platform } from 'react-native'; | |
| /** | |
| * Obtém os espaçamentos considerando o tamanho da barra de status e do botão do iPhone X. | |
| * @returns {{ top: number, bottom: number }} | |
| */ | |
| const getOffset = () => { | |
| const { width, height } = Dimensions.get('window'); | |
| const { OS, isPad, isTVOS } = Platform; |