on 04765bb help sign in
182 lines 4.0 kB history raw
1// Helpers
2import {
3 simpleValidatorWrapper,
4 validateMnemonic,
5 validateNotEmpty,
6 validateEthereumAddress,
7 validateGalaxy,
8 validatePoint,
9 validateTicket,
10 validateNetworkKey,
11 validateNetworkSeed,
12 validateShard,
13} from '../../lib/validators';
15import { prependSig } from '../../lib/transformers';
17// Buttons
18import Button from './Button';
19import UploadButton from './UploadButton';
20// import Checkbox from './Checkbox';
21import CheckboxButton from './CheckboxButton';
22import Anchor from './Anchor';
23// import ToggleButton from './ToggleButton';
25// Input
26import Form from './Form';
27import Label from './Label';
28import InnerLabel from './InnerLabel';
29import InputCaption from './InputCaption';
30import Input from './Input';
31import Textarea from './Textarea';
32import advancedInput from './advancedInput';
34// Dropdowns
35import DropdownItem from './DropdownItem';
36import DropdownDivider from './DropdownDivider';
37import InnerLabelDropdown from './InnerLabelDropdown';
39// Option selectors
40import HorizontalSelector from './HorizontalSelector';
42// Path Control
43import Breadcrumb from './Breadcrumb';
44import BreadcrumbItem from './BreadcrumbItem';
46// Layout
47import Col from './Col';
48import Row from './Row';
49// import FlexRow from './FlexRow';
50// import FlexCol from './FlexCol';
51import Spacing from './Spacing';
53// Type
54import H1 from './H1';
55import H2 from './H2';
56import H3 from './H3';
57import H4 from './H4';
58import P from './P';
59import Code from './Code';
60import Warning from './Warning';
62// Misc
63import ValidatedSigil from './ValidatedSigil';
64import ValidatedBlockie from './ValidatedBlockie';
65import ShowBlockie from './ShowBlockie';
66import Passport from './Passport';
68// HOC validated form components
70const RequiredInput = advancedInput({
71 WrappedComponent: Input,
72 validators: [validateNotEmpty],
73});
75const NetworkKeyInput = advancedInput({
76 WrappedComponent: Input,
77 validators: [validateNotEmpty, validateNetworkKey],
78});
80const NetworkSeedInput = advancedInput({
81 WrappedComponent: Input,
82 validators: [validateNotEmpty, validateNetworkSeed],
83});
85const AddressInput = advancedInput({
86 WrappedComponent: Input,
87 validators: [validateEthereumAddress, validateNotEmpty],
88});
90const MnemonicInput = advancedInput({
91 WrappedComponent: Textarea,
92 validators: [validateMnemonic, validateNotEmpty],
93});
95const GalaxyInput = advancedInput({
96 WrappedComponent: Input,
97 validators: [validateGalaxy, validateNotEmpty],
98 transformers: [prependSig],
99});
101const PointInput = advancedInput({
102 WrappedComponent: Input,
103 validators: [validatePoint, validateNotEmpty],
104 transformers: [prependSig],
105});
107const TicketInput = advancedInput({
108 WrappedComponent: Input,
109 validators: [validateTicket, validateNotEmpty],
110 transformers: [prependSig],
111});
113const VerifyTicketInput = matchingTicket =>
114 advancedInput({
115 WrappedComponent: Input,
116 validators: [
117 validateTicket,
118 validateNotEmpty,
120 // TODO: This should be in /lib/validators, but we'd need a way for
121 // validators to compare against dynamic values
122 m =>
123 simpleValidatorWrapper({
124 prevMessage: m,
125 validator: d => d === matchingTicket,
126 errorMessage: 'This does not match the provided master ticket',
127 }),
128 ],
129 transformers: [prependSig],
130 });
132const ShardInput = advancedInput({
133 WrappedComponent: Input,
134 validators: [validateShard],
135 transformers: [],
136});
138export {
139 Button,
140 CheckboxButton,
141 UploadButton,
142 Anchor,
143 InputCaption,
144 Form,
145 Label,
146 Input,
147 InnerLabel,
148 Textarea,
149 AddressInput,
150 MnemonicInput,
151 GalaxyInput,
152 PointInput,
153 TicketInput,
154 VerifyTicketInput,
155 ShardInput,
156 RequiredInput,
157 NetworkKeyInput,
158 NetworkSeedInput,
159 advancedInput,
160 ValidatedSigil,
161 ValidatedBlockie,
162 ShowBlockie,
163 DropdownItem,
164 DropdownDivider,
165 InnerLabelDropdown,
166 HorizontalSelector,
167 Breadcrumb,
168 BreadcrumbItem,
169 Col,
170 Row,
171 // FlexRow,
172 // FlexCol,
173 Spacing,
174 H1,
175 H2,
176 H3,
177 H4,
178 P,
179 Code,
180 Warning,
181 Passport,
182};