on d760cbf help sign in
180 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';
67// HOC validated form components
69const RequiredInput = advancedInput({
70 WrappedComponent: Input,
71 validators: [validateNotEmpty],
72});
74const NetworkKeyInput = advancedInput({
75 WrappedComponent: Input,
76 validators: [validateNotEmpty, validateNetworkKey],
77});
79const NetworkSeedInput = advancedInput({
80 WrappedComponent: Input,
81 validators: [validateNotEmpty, validateNetworkSeed],
82});
84const AddressInput = advancedInput({
85 WrappedComponent: Input,
86 validators: [validateEthereumAddress, validateNotEmpty],
87});
89const MnemonicInput = advancedInput({
90 WrappedComponent: Textarea,
91 validators: [validateMnemonic, validateNotEmpty],
92});
94const GalaxyInput = advancedInput({
95 WrappedComponent: Input,
96 validators: [validateGalaxy, validateNotEmpty],
97 transformers: [prependSig],
98});
100const PointInput = advancedInput({
101 WrappedComponent: Input,
102 validators: [validatePoint, validateNotEmpty],
103 transformers: [prependSig],
104});
106const TicketInput = advancedInput({
107 WrappedComponent: Input,
108 validators: [validateTicket, validateNotEmpty],
109 transformers: [prependSig],
110});
112const VerifyTicketInput = matchingTicket =>
113 advancedInput({
114 WrappedComponent: Input,
115 validators: [
116 validateTicket,
117 validateNotEmpty,
119 // TODO: This should be in /lib/validators, but we'd need a way for
120 // validators to compare against dynamic values
121 m =>
122 simpleValidatorWrapper({
123 prevMessage: m,
124 validator: d => d === matchingTicket,
125 errorMessage: 'This does not match the provided master ticket',
126 }),
127 ],
128 transformers: [prependSig],
129 });
131const ShardInput = advancedInput({
132 WrappedComponent: Input,
133 validators: [validateShard],
134 transformers: [],
135});
137export {
138 Button,
139 CheckboxButton,
140 UploadButton,
141 Anchor,
142 InputCaption,
143 Form,
144 Label,
145 Input,
146 InnerLabel,
147 Textarea,
148 AddressInput,
149 MnemonicInput,
150 GalaxyInput,
151 PointInput,
152 TicketInput,
153 VerifyTicketInput,
154 ShardInput,
155 RequiredInput,
156 NetworkKeyInput,
157 NetworkSeedInput,
158 advancedInput,
159 ValidatedSigil,
160 ValidatedBlockie,
161 ShowBlockie,
162 DropdownItem,
163 DropdownDivider,
164 InnerLabelDropdown,
165 HorizontalSelector,
166 Breadcrumb,
167 BreadcrumbItem,
168 Col,
169 Row,
170 // FlexRow,
171 // FlexCol,
172 Spacing,
173 H1,
174 H2,
175 H3,
176 H4,
177 P,
178 Code,
179 Warning,
180};