on 8011c59 help sign in
186 lines 4.1 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 Container from './Container';
48import Col from './Col';
49import Row from './Row';
50// import FlexRow from './FlexRow';
51// import FlexCol from './FlexCol';
52import Spacing from './Spacing';
54// Type
55import H1 from './H1';
56import H2 from './H2';
57import H3 from './H3';
58import H4 from './H4';
59import P from './P';
60import Code from './Code';
61import Warning from './Warning';
63// Misc
64import ValidatedSigil from './ValidatedSigil';
65import ValidatedBlockie from './ValidatedBlockie';
66import Chevron from './icons/Chevron';
67import ShowBlockie from './ShowBlockie';
68import Passport from './Passport';
70// HOC validated form components
72const RequiredInput = advancedInput({
73 WrappedComponent: Input,
74 validators: [validateNotEmpty],
75});
77const NetworkKeyInput = advancedInput({
78 WrappedComponent: Input,
79 validators: [validateNotEmpty, validateNetworkKey],
80});
82const NetworkSeedInput = advancedInput({
83 WrappedComponent: Input,
84 validators: [validateNotEmpty, validateNetworkSeed],
85});
87const AddressInput = advancedInput({
88 WrappedComponent: Input,
89 validators: [validateEthereumAddress, validateNotEmpty],
90});
92const MnemonicInput = advancedInput({
93 WrappedComponent: Textarea,
94 validators: [validateMnemonic, validateNotEmpty],
95});
97const GalaxyInput = advancedInput({
98 WrappedComponent: Input,
99 validators: [validateGalaxy, validateNotEmpty],
100 transformers: [prependSig],
101});
103const PointInput = advancedInput({
104 WrappedComponent: Input,
105 validators: [validatePoint, validateNotEmpty],
106 transformers: [prependSig],
107});
109const TicketInput = advancedInput({
110 WrappedComponent: Input,
111 validators: [validateTicket, validateNotEmpty],
112 transformers: [prependSig],
113});
115const VerifyTicketInput = matchingTicket =>
116 advancedInput({
117 WrappedComponent: Input,
118 validators: [
119 validateTicket,
120 validateNotEmpty,
122 // TODO: This should be in /lib/validators, but we'd need a way for
123 // validators to compare against dynamic values
124 m =>
125 simpleValidatorWrapper({
126 prevMessage: m,
127 validator: d => d === matchingTicket,
128 errorMessage: 'This does not match the provided master ticket',
129 }),
130 ],
131 transformers: [prependSig],
132 });
134const ShardInput = advancedInput({
135 WrappedComponent: Input,
136 validators: [validateShard],
137 transformers: [],
138});
140export {
141 Button,
142 CheckboxButton,
143 UploadButton,
144 Anchor,
145 InputCaption,
146 Form,
147 Label,
148 Input,
149 InnerLabel,
150 Textarea,
151 AddressInput,
152 MnemonicInput,
153 GalaxyInput,
154 PointInput,
155 TicketInput,
156 VerifyTicketInput,
157 ShardInput,
158 RequiredInput,
159 NetworkKeyInput,
160 NetworkSeedInput,
161 advancedInput,
162 ValidatedSigil,
163 ValidatedBlockie,
164 ShowBlockie,
165 DropdownItem,
166 DropdownDivider,
167 InnerLabelDropdown,
168 HorizontalSelector,
169 Breadcrumb,
170 BreadcrumbItem,
171 Container,
172 Col,
173 Row,
174 // FlexRow,
175 // FlexCol,
176 Spacing,
177 H1,
178 H2,
179 H3,
180 H4,
181 P,
182 Code,
183 Warning,
184 Chevron,
185 Passport,
186};