Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 771b5c4

Browse files
committed
updates to elements and Trustee works with lookup API
1 parent d344c8d commit 771b5c4

12 files changed

Lines changed: 210 additions & 61 deletions

File tree

docs/Playground.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Playground as DoczPlayground } from 'docz';
3-
import { CssResets } from '../packages/theming/src';
3+
import { CssResets } from '../packages/theming/src/theming';
44
import fetch from 'node-fetch';
55

66
export const Playground = (props) => {
@@ -11,13 +11,11 @@ export const Playground = (props) => {
1111
);
1212
};
1313

14-
console.log(process.env);
15-
1614
export const experianApiGet = (endpoint) => {
1715
return fetch(`https://api.edq.com/capture/address/v2/${endpoint}`, {
1816
method: 'get',
1917
headers: {
20-
'Auth-Token': process.env.DOCZ_LOOKUP_API_URL,
18+
'Auth-Token': process.env.GATSBY_LOOKUP_API_URL,
2119
},
2220
}).then((resp) => resp.json());
2321
};

packages/forms/src/elements/date/date.mdx

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,35 @@ import { FFInputDate } from './date';
1010
import { validate } from '../../validation';
1111
import { renderFields } from '../../renderFields';
1212

13-
# Date
13+
# Date Input
14+
15+
To input a date.
16+
17+
## When To Use
18+
19+
- By entering date number in each input box, you can create a date object.
1420

1521
## Usage
1622

23+
`Inside your React project directory, run the following:`
24+
1725
```js
18-
import { FFInputDate } from '@tpr/forms';
26+
yarn add @tpr/forms
1927
```
2028

21-
## Usage
29+
`or with npm`
30+
31+
```js
32+
npm install @tpr/forms
33+
```
2234

23-
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum nostrum omnis ea unde totam, est
24-
consectetur odio! Harum vitae, sed totam aperiam consequuntur nostrum repudiandae non nemo porro,
25-
dolorem nulla corrupti hic consectetur eaque fuga illo numquam modi similique ipsam recusandae! Harum,
26-
possimus suscipit. Quibusdam totam, fugiat officiis qui nisi tempora. Accusantium corrupti similique
27-
et at ipsum, eveniet tempore nostrum quasi est unde modi impedit quaerat suscipit aspernatur ratione
28-
quo corporis? Cum dignissimos adipisci itaque sint tempore, saepe dolorem fugit quia placeat officiis
29-
earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque magnam illo ipsa officia nulla ipsum.
35+
`import items you wish to use from the library`
36+
37+
```js
38+
import { FFInputDate } from '@tpr/forms';
39+
```
40+
41+
## Examples
3042

3143
[CodeSandbox](https://codesandbox.io/s/nice-dream-xs3zp)
3244

@@ -59,3 +71,15 @@ earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque mag
5971
);
6072
}}
6173
</Playground>
74+
75+
## API
76+
77+
### Props
78+
79+
| Property | Required | Type | Description |
80+
| -------- | -------- | ------- | -------------------------------------------- |
81+
| cfg | false | object | FlexProps & SpaceProps |
82+
| disabled | false | boolean | Disable checkbox |
83+
| testId | false | string | data attribute for testers |
84+
| label | true | string | Checkbox description |
85+
| hint | false | string | More detailed description about the checkbox |

packages/forms/src/elements/date/date.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type DateInputFieldProps = {
4747
maxInt: number;
4848
meta: any;
4949
label: string;
50+
disabled?: boolean;
5051
};
5152
const DateInputField: React.FC<DateInputFieldProps> = ({
5253
small = true,
@@ -59,12 +60,14 @@ const DateInputField: React.FC<DateInputFieldProps> = ({
5960
setMonth,
6061
onBlur,
6162
meta,
63+
disabled,
6264
}) => {
6365
return (
6466
<label className={small ? styles.inputSmall : styles.inputLarge}>
6567
<P cfg={{ fontSize: 2, fontWeight: 3, mb: 1 }}>{label}</P>
6668
<Input
6769
type="number"
70+
disabled={disabled}
6871
aria-label={ariaLabel}
6972
data-testid={testId}
7073
value={value}
@@ -85,7 +88,7 @@ const DateInputField: React.FC<DateInputFieldProps> = ({
8588

8689
type InputDateProps = FieldRenderProps<string> & FieldExtraProps;
8790
export const InputDate: React.FC<InputDateProps> = memo(
88-
({ label, hint, required, input, meta, testId = 'field', cfg }) => {
91+
({ label, hint, required, input, meta, testId = 'field', cfg, disabled }) => {
8992
// react-final-form types says it's a string, incorrect, it's a date object.
9093
const { dd, mm, yyyy } = transformDate(meta.initial);
9194
const [{ dd: day, mm: month, yyyy: year }, setState] = useReducer(
@@ -137,6 +140,7 @@ export const InputDate: React.FC<InputDateProps> = memo(
137140
setMonth={(mm: number) => setState({ mm })}
138141
onBlur={input.onBlur}
139142
meta={meta}
143+
disabled={disabled}
140144
/>
141145
<DateInputField
142146
label="Month"
@@ -148,6 +152,7 @@ export const InputDate: React.FC<InputDateProps> = memo(
148152
setMonth={(mm: number) => setState({ mm })}
149153
onBlur={input.onBlur}
150154
meta={meta}
155+
disabled={disabled}
151156
/>
152157
<DateInputField
153158
label="Year"
@@ -160,6 +165,7 @@ export const InputDate: React.FC<InputDateProps> = memo(
160165
setMonth={(mm: number) => setState({ mm })}
161166
onBlur={input.onBlur}
162167
meta={meta}
168+
disabled={disabled}
163169
/>
164170
</Flex>
165171
</StyledInputLabel>

packages/forms/src/elements/input/input.module.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
}
2020

2121
.inputText:disabled {
22-
background: $colors-neutral-6;
22+
background: $colors-neutral-2;
23+
border-color: $colors-neutral-6;
24+
cursor: not-allowed;
2325
}
2426

2527
.inputText-error {

packages/forms/src/elements/number/number.mdx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,35 @@ import { renderFields } from '../../renderFields';
1212

1313
# Number Input
1414

15+
Enter a number within certain range with the mouse or keyboard.
16+
17+
## When To Use
18+
19+
- When a numeric value needs to be provided
20+
1521
## Usage
1622

23+
`Inside your React project directory, run the following:`
24+
1725
```js
18-
import { Form, FFInputNumber } from '@tpr/forms';
26+
yarn add @tpr/forms
1927
```
2028

21-
[CodeSandbox](https://codesandbox.io)
29+
`or with npm`
2230

23-
Example using field level validation
31+
```js
32+
npm install @tpr/forms
33+
```
34+
35+
`import items you wish to use from the library`
36+
37+
```js
38+
import { FFInputNumber } from '@tpr/forms';
39+
```
40+
41+
## Examples
42+
43+
[CodeSandbox](https://codesandbox.io)
2444

2545
<Playground>
2646
<Form onSubmit={(values) => console.log(values)}>
@@ -81,3 +101,15 @@ import { Form, validate, renderFields } from '@tpr/forms';
81101
);
82102
}}
83103
</Playground>
104+
105+
## API
106+
107+
### Props
108+
109+
| Property | Required | Type | Description |
110+
| -------- | -------- | ------- | -------------------------------------------- |
111+
| cfg | false | object | FlexProps & SpaceProps |
112+
| disabled | false | boolean | Disable checkbox |
113+
| testId | false | string | data attribute for testers |
114+
| label | true | string | Checkbox description |
115+
| hint | false | string | More detailed description about the checkbox |

packages/forms/src/elements/radio/radio.mdx

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,36 @@ import { Playground } from '@playground';
88
import { Form } from 'react-final-form';
99
import { FFRadioButton } from './radio';
1010

11-
# Radio Button
11+
# Radio
12+
13+
Radio.
14+
15+
## When To Use
16+
17+
- Used to select a single state from multiple options.
18+
- The difference from Select is that Radio is visible to the user and can facilitate the comparison of choice, which means there shouldn't be too many of them.
1219

1320
## Usage
1421

22+
`Inside your React project directory, run the following:`
23+
1524
```js
16-
import { FFRadioButton } from '@tpr/forms';
25+
yarn add @tpr/forms
1726
```
1827

19-
## Usage
28+
`or with npm`
29+
30+
```js
31+
npm install @tpr/forms
32+
```
2033

21-
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum nostrum omnis ea unde totam, est
22-
consectetur odio! Harum vitae, sed totam aperiam consequuntur nostrum repudiandae non nemo porro,
23-
dolorem nulla corrupti hic consectetur eaque fuga illo numquam modi similique ipsam recusandae! Harum,
24-
possimus suscipit. Quibusdam totam, fugiat officiis qui nisi tempora. Accusantium corrupti similique
25-
et at ipsum, eveniet tempore nostrum quasi est unde modi impedit quaerat suscipit aspernatur ratione
26-
quo corporis? Cum dignissimos adipisci itaque sint tempore, saepe dolorem fugit quia placeat officiis
27-
earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque magnam illo ipsa officia nulla ipsum.
34+
`import items you wish to use from the library`
35+
36+
```js
37+
import { FFRadioButton } from '@tpr/forms';
38+
```
39+
40+
## Examples
2841

2942
[CodeSandbox](https://codesandbox.io/s/lively-wood-rxcpu)
3043

@@ -75,3 +88,17 @@ earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque mag
7588
);
7689
}}
7790
</Playground>
91+
92+
## API
93+
94+
### Props
95+
96+
| Property | Required | Type | Description |
97+
| -------- | -------- | -------------------- | --------------------------------------------------------------- |
98+
| cfg | false | object | FlexProps & SpaceProps |
99+
| disabled | false | boolean | Disable checkbox |
100+
| testId | false | string | data attribute for testers |
101+
| checked | true | boolean | Specifies whether the checkbox is selected. |
102+
| onChange | true | function(evt: Event) | The callback function that is triggered when the state changes. |
103+
| label | true | string | Checkbox description |
104+
| hint | false | string | More detailed description about the checkbox |

packages/forms/src/elements/select/select.mdx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,39 @@ import { Playground } from '@playground';
88
import { Form } from 'react-final-form';
99
import { FFSelect, Select } from './select';
1010

11-
# Select Dropdown
11+
# Select
12+
13+
Select component to select value from options.
14+
15+
## When To Use
16+
17+
- A dropdown menu for displaying choices - an elegant alternative to the native `<select>` element.
18+
- Utilizing Radio is recommended when there are fewer total options (less than 5).
1219

1320
## Usage
1421

22+
`Inside your React project directory, run the following:`
23+
24+
```js
25+
yarn add @tpr/forms
26+
```
27+
28+
`or with npm`
29+
30+
```js
31+
npm install @tpr/forms
32+
```
33+
34+
`import items you wish to use from the library`
35+
1536
```js
1637
import { FFSelect } from '@tpr/forms';
1738
```
1839

40+
## Examples
41+
42+
[CodeSandbox](https://codesandbox.io)
43+
1944
<Playground>
2045
{() => {
2146
const FIELD_NAME = 'fruit';
@@ -53,3 +78,14 @@ import { FFSelect } from '@tpr/forms';
5378
);
5479
}}
5580
</Playground>
81+
82+
## API
83+
84+
### Props
85+
86+
| Property | Required | Type | Description |
87+
| -------- | -------- | ------- | ------------------------------------------- |
88+
| cfg | false | object | FlexProps & SpaceProps |
89+
| disabled | false | boolean | Disable checkbox |
90+
| testId | false | string | data attribute for testers |
91+
| checked | true | boolean | Specifies whether the checkbox is selected. |

packages/forms/src/elements/select/select.module.scss

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
@import '@tpr/theming/lib/variables.scss';
22

3-
.selectInput {
4-
font-family: $fonts-sans-serif;
5-
display: flex;
6-
align-items: center;
7-
width: 100%;
8-
font-size: $font-size-2;
9-
font-weight: $font-weight-1;
10-
background: $white;
11-
height: 40px;
12-
outline: none;
13-
padding: 0 5px;
14-
cursor: default;
15-
}
16-
17-
.selectInput:focus {
18-
border: 4px solid $colors-neutral-7;
19-
box-shadow: 0 0 0 3px $colors-warning-1;
20-
}
21-
22-
.selectInput:disabled {
23-
background: $colors-neutral-6;
24-
}
25-
263
.popup {
274
display: none;
285
flex: 0 0 auto;
@@ -56,10 +33,15 @@
5633
display: flex;
5734
align-items: center;
5835
position: absolute;
59-
background: $white;
36+
background: none;
6037
top: 9px;
6138
right: 4px;
6239
width: 30px;
6340
height: 32px;
6441
cursor: pointer;
42+
outline: none;
43+
}
44+
45+
.iconButton:disabled {
46+
cursor: not-allowed;
6547
}

packages/forms/src/elements/select/select.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@ export const Select: React.FC<SelectProps> = ({
7878
onClick={() => toggleMenu()}
7979
{...getInputProps()}
8080
/>
81-
<div
82-
role="button"
81+
<button
82+
type="button"
83+
disabled={disabled}
8384
data-testid={`${testId}-button`}
8485
className={styles.iconButton}
8586
onClick={() => toggleMenu()}
8687
>
8788
<UnfoldMore />
88-
</div>
89+
</button>
8990
</Flex>
9091
</StyledInputLabel>
9192
<Flex cfg={{ width }} className={styles.relative}>

0 commit comments

Comments
 (0)