on master help sign in
fix: rename to formatters, auto-downcase pat fields
80fec93Matt Condon (shrugs)
src/form/Inputs.js+10−3
@@ -2,7 +2,12 @@ import React from 'react';
2import { Input, AccessoryIcon } from 'indigo-react';
2import { Input, AccessoryIcon } from 'indigo-react';
3import { useField } from 'react-final-form';
3import { useField } from 'react-final-form';
4
4
5+import {
6+ prependSig,
5−import { prependSig, convertToNumber } from 'lib/transformers';
7+ convertToNumber,
8+ buildFormatter,
9+ downcase,
10+} from 'form/formatters';
6import { DEFAULT_HD_PATH } from 'lib/wallet';
11import { DEFAULT_HD_PATH } from 'lib/wallet';
7import InputSigil from 'components/InputSigil';
12import InputSigil from 'components/InputSigil';
8
13
@@ -16,6 +21,8 @@ const PLACEHOLDER_PRIVATE_KEY =
16 '0x12345abcdee6beb2f323fab48b432925c9785808d33a6ca6d7ba00b45e9370c3';
21 '0x12345abcdee6beb2f323fab48b432925c9785808d33a6ca6d7ba00b45e9370c3';
17const PLACEHOLDER_EMAIL = 'Email Address';
22const PLACEHOLDER_EMAIL = 'Email Address';
18
23
24+const formatPat = buildFormatter([downcase, prependSig]);
25+
19export function TicketInput({ name, ...rest }) {
26export function TicketInput({ name, ...rest }) {
20 const {
27 const {
21 meta: { valid, error, validating, touched, active },
28 meta: { valid, error, validating, touched, active },
@@ -43,7 +50,7 @@ export function TicketInput({ name, ...rest }) {
43 <AccessoryIcon.Success />
50 <AccessoryIcon.Success />
44 ) : null
51 ) : null
45 }
52 }
46− config={{ format: prependSig }}
53+ config={{ format: formatPat }}
47 mono
54 mono
48 {...rest}
55 {...rest}
49 />
56 />
@@ -103,7 +110,7 @@ export function PointInput({ name, size = 4, ...rest }) {
103 />
110 />
104 ) : null
111 ) : null
105 }
112 }
106− config={{ format: prependSig }}
113+ config={{ format: formatPat }}
107 mono
114 mono
108 {...rest}
115 {...rest}
109 />
116 />
src/lib/transformers.js → src/form/formatters.jsrenamed+11−1
@@ -1,4 +1,6 @@
1−// import { fill } from './lib'
1+import { compose } from 'lib/lib';
2+
3+export const buildFormatter = (formatters = []) => compose(...formatters);
2
4
3export const prependSig = (s = '') =>
5export const prependSig = (s = '') =>
4 s.length && s.charAt(0) !== '~' ? `~${s}` : s;
6 s.length && s.charAt(0) !== '~' ? `~${s}` : s;
@@ -11,6 +13,14 @@ export const convertToNumber = s => {
11 }
13 }
12};
14};
13
15
16+export const downcase = s => {
17+ if (!s) {
18+ return s;
19+ }
20+
21+ return s.toLowerCase();
22+};
23+
14// const hideAllButLast = s => {
24// const hideAllButLast = s => {
15// const ll = s[s.length -1];
25// const ll = s[s.length -1];
16// const bs = fill(s.length - 1, '•')
26// const bs = fill(s.length - 1, '•')
src/indigo-react/components/Input.js+2−2
@@ -85,8 +85,8 @@ export default function Input({
85 {
85 {
86 'b-green3': valid,
86 'b-green3': valid,
87 'b-black': !valid && active,
87 'b-black': !valid && active,
88− 'b-yellow3': !valid && !active && touched && error,
88+ 'b-yellow3': !valid && !active && touched,
89− 'b-gray2': !valid && !active && !touched && !error,
89+ 'b-gray2': !valid && !active && !touched,
90 }
90 }
91 )}
91 )}
92 id={name}
92 id={name}
src/lib/useImpliedPoint.js+1−1
@@ -1,6 +1,6 @@
1import * as ob from 'urbit-ob';
1import * as ob from 'urbit-ob';
2
2
3−import { prependSig } from './transformers';
3+import { prependSig } from 'form/formatters';
4
4
5/**
5/**
6 * pull the suggested point from the subdomain
6 * pull the suggested point from the subdomain
src/lib/useImpliedTicket.js+1−1
@@ -1,6 +1,6 @@
1import * as ob from 'urbit-ob';
1import * as ob from 'urbit-ob';
2
2
3−import { prependSig } from './transformers';
3+import { prependSig } from 'form/formatters';
4
4
5/**
5/**
6 * pull the suggested ticket from the #hash in the url
6 * pull the suggested ticket from the #hash in the url