Skip to content

Commit 6c640cb

Browse files
lloydafmartimalekMartí Maleksemantic-release-botNikolai Lopin
authored
Merge main (#270)
* docs: remove the experimental label for table (#255) * fix: display semantic colors in table and allow to filter them (#258) * fix: display semantic colors in table and allow to filter them * refactor: improve performance of SemanticColorsTable * fix: trim table filter input Co-authored-by: Martí Malek <[email protected]> * chore(release): 1.25.2 [skip ci] ### [1.25.2](v1.25.1...v1.25.2) (2022-07-11) ### Bug Fixes * display semantic colors in table and allow to filter them ([#258](#258)) ([2e83e76](2e83e76)) * update codeowners removes Rafa from the list 😢 * style(popover): expose padding prop for Popover component (#262) Co-authored-by: Ján Hamara <[email protected]> * fix: expose padding prop and adjust z-index for Popover component (#263) * style(popover): expose padding prop for Popover component * fix: update zIndex on Popover content container Co-authored-by: Ján Hamara <[email protected]> * chore(release): 1.25.3 [skip ci] ### [1.25.3](v1.25.2...v1.25.3) (2022-07-21) ### Bug Fixes * expose padding prop and adjust z-index for Popover component ([#263](#263)) ([da0e80b](da0e80b)) * Expand PhoneInput API (#261) Exposes properties to reach lower-level components of the `PhoneInput` Co-authored-by: martimalek <[email protected]> * 1.26.0 * 1.26.1 Co-authored-by: martimalek <[email protected]> Co-authored-by: Martí Malek <[email protected]> Co-authored-by: semantic-release-bot <[email protected]> Co-authored-by: Nikolai Lopin <[email protected]> Co-authored-by: Jan Hamara <[email protected]> Co-authored-by: Ján Hamara <[email protected]> Co-authored-by: Nikolai Lopin <[email protected]>
1 parent 4ba30b2 commit 6c640cb

File tree

14 files changed

+140
-25
lines changed

14 files changed

+140
-25
lines changed

CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @nlopin @martimalek @div-Leo @rafael-sepeda @jonotrujillo
1+
* @nlopin @martimalek @div-Leo @jonotrujillo

docs/changelog.mdx

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ cardHeadline: Changelog
55
cardSubHeadline: Keep up to date with the latest releases of @freenow/wave
66
---
77

8+
### [1.25.3](https://github.com/freenowtech/wave/compare/v1.25.2...v1.25.3) (2022-07-21)
9+
10+
11+
### Bug Fixes
12+
13+
* expose padding prop and adjust z-index for Popover component ([#263](https://github.com/freenowtech/wave/issues/263)) ([da0e80b](https://github.com/freenowtech/wave/commit/da0e80be5df4274220336451641b31d1fe8d524f))
14+
15+
### [1.25.2](https://github.com/freenowtech/wave/compare/v1.25.1...v1.25.2) (2022-07-11)
16+
17+
18+
### Bug Fixes
19+
20+
* display semantic colors in table and allow to filter them ([#258](https://github.com/freenowtech/wave/issues/258)) ([2e83e76](https://github.com/freenowtech/wave/commit/2e83e763427fb5ce67fc99719a0a3a8837be086c))
21+
822
### [1.25.1](https://github.com/freenowtech/wave/compare/v1.25.0...v1.25.1) (2022-06-16)
923

1024

fixtures/typescript-build/src/index.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
Logo,
2222
Modal,
2323
Pagination,
24+
PhoneInput,
2425
RadioButton,
2526
Select,
2627
TabBar,
@@ -443,6 +444,26 @@ const TestTooltip: React.FC = () => (
443444
</>
444445
);
445446

447+
const TestPhoneInput = () => (
448+
<>
449+
<PhoneInput />
450+
<PhoneInput id="hello" />
451+
<PhoneInput variant="boxed" size="medium" />
452+
<PhoneInput variant="bottom-lined" size="small" />
453+
<PhoneInput text="my text" />
454+
<PhoneInput
455+
inputProps={{
456+
onFocus: () => {}
457+
}}
458+
/>
459+
<PhoneInput
460+
selectListProps={{
461+
onFocus: () => {}
462+
}}
463+
/>
464+
</>
465+
);
466+
446467
const App: React.FC = () => (
447468
<>
448469
<TestBanner />
@@ -471,6 +492,7 @@ const App: React.FC = () => (
471492
<TestTextarea />
472493
<TestToggle />
473494
<TestTooltip />
495+
<TestPhoneInput />
474496
</>
475497
);
476498

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@freenow/wave",
3-
"version": "1.25.1",
3+
"version": "1.26.1",
44
"description": "React components of the Wave design system for your Front-End project",
55
"main": "lib/cjs/index.js",
66
"typings": "lib/types/index.d.ts",

src/components/PhoneInput/PhoneInput.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { extractWrapperMarginProps } from '../../utils/extractProps';
1313
import { Input } from '../Input/Input';
1414
import { InputProps } from '../Input/InputProps';
1515
import { SelectList } from '../SelectList/SelectList';
16+
import { SelectListProps } from '../SelectList/types';
1617
import { DynamicWidthMenu } from './components/DynamicWidthMenu';
1718
import { Option } from './components/Option';
1819
import { SingleValue } from './components/SingleValue';
@@ -30,13 +31,22 @@ interface PhoneInputProps
3031
onTextChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
3132
country?: PhoneAreaCodeCountry;
3233
onCountryChange?: (country?: PhoneAreaCodeCountry) => void;
34+
listPortalTarget?: SelectListProps['menuPortalTarget'];
35+
inputProps?: InputProps;
36+
selectListProps?: SelectListProps;
3337
}
3438

3539
const Box = styled.div<LayoutProps & WidthProps>`
3640
${compose(layout, widthFn, marginFn)}
3741
`;
3842

39-
const PhoneInput: React.FC<PhoneInputProps> = ({ width, variant = 'boxed', ...props }: PhoneInputProps) => {
43+
const PhoneInput: React.FC<PhoneInputProps> = ({
44+
width,
45+
variant = 'boxed',
46+
inputProps = {},
47+
selectListProps = {},
48+
...props
49+
}: PhoneInputProps) => {
4050
const { marginProps } = extractWrapperMarginProps(props);
4151

4252
const nationalNumberInputRef = React.createRef<HTMLDivElement>();
@@ -54,6 +64,7 @@ const PhoneInput: React.FC<PhoneInputProps> = ({ width, variant = 'boxed', ...pr
5464
return (
5565
<Box display="inline-flex" width={width} {...marginProps} ref={containerRef}>
5666
<SelectList
67+
{...selectListProps}
5768
id={`${props.id}-area-code`}
5869
name={`${props.name}-area-code`}
5970
value={props.country}
@@ -75,8 +86,10 @@ const PhoneInput: React.FC<PhoneInputProps> = ({ width, variant = 'boxed', ...pr
7586
variant={variant}
7687
size={props.size}
7788
isDisabled={props.disabled}
89+
menuPortalTarget={props.listPortalTarget}
7890
/>
7991
<Input
92+
{...inputProps}
8093
id={`${props.id}-national-number`}
8194
name={`${props.name}-national-number`}
8295
ml={spaceBetweenInputs}

src/components/PhoneInput/docs/PhoneInput.mdx

+22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import { COUNTRIES } from '../constants';
1515

1616
# PhoneInput
1717

18+
The `PhoneInput` is a component to input a phone number in international format.
19+
20+
The component consists of two controls: a select to pick a prefix and an input to type in the phone number. The select shows all the country codes available world-wide.
21+
1822
## Properties
1923

2024
<PhoneInputPropsTable />
@@ -40,3 +44,21 @@ return (
4044
/>
4145
);
4246
```
47+
48+
## Playground
49+
50+
<Playground>
51+
<ControlledPhoneInput label="Mobile Phone Number" />
52+
</Playground>
53+
54+
## Troubleshooting
55+
56+
### The list of prefixes is not fully visible
57+
58+
If the list of prefixes is not fully visible when opened, like in [this Sandbox example](https://codesandbox.io/s/inspiring-austin-2006xl?file=/src/index.js), use `listPortalTarget` prop to attach the popup to the document's body:
59+
60+
```jsx
61+
<PhoneInput listPortalTarget={document.body} />
62+
```
63+
64+
The reason of the issue is that the prefix selection popup is rendered inside the same container as the component by default. If the container does not allow content to overflow (e.g. via `overflow: hidden;`), everything that overflows the container borders will be hidden.

src/components/PhoneInput/docs/PhoneInputPropsTable.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ export const PhoneInputPropsTable: FC = () => {
5656
name: 'disabled',
5757
type: 'boolean',
5858
description: 'Disables both, the area code and national number inputs'
59+
},
60+
{
61+
name: 'listPortalTarget',
62+
type: 'HTMLElement',
63+
description: 'HTML element which will be used as a parent for the prefix list'
64+
},
65+
{
66+
name: 'inputProps',
67+
type: 'Object',
68+
description:
69+
'Pass props directly to the internal input component. ' +
70+
'Any value from the `Input` component props are allowed, but props from the `PhoneInput` take precedence'
71+
},
72+
{
73+
name: 'selectListProps',
74+
type: 'Object',
75+
description:
76+
'Pass props directly to the internal SelectList component used to show prefixes. ' +
77+
'Any value from the `SelectList` component props are allowed, but props from the `PhoneInput` take precedence'
5978
}
6079
];
6180
return <PropsTable props={props} />;

src/components/Popover/Popover.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ interface PopoverProps {
7272
* Popover content (can be any valid React Element or component containing React Elements)
7373
*/
7474
content: React.ReactNode;
75+
/**
76+
* Popover content padding
77+
*/
78+
padding?: string | number;
7579
/**
7680
* Optional: Specify the Popover content placement (it changes automatically if the Popover content cannot fit inside the viewport with the selected placement)
7781
*/
@@ -97,6 +101,7 @@ interface PopoverProps {
97101
const Popover: React.FC<PopoverProps> = ({
98102
children,
99103
content = '',
104+
padding = undefined,
100105
placement = 'bottom-start',
101106
offset = 5,
102107
isOpen = false,
@@ -228,12 +233,11 @@ const Popover: React.FC<PopoverProps> = ({
228233
<PopoverContentContainer
229234
id="popover-content"
230235
ref={setContentReference}
231-
// zIndex temporary until we have Portal component
232-
style={{ ...styles.popper, zIndex: 9999 }}
236+
style={{ ...styles.popper, zIndex: 999 }}
233237
{...attributes.popper}
234238
>
235239
<PopoverContentWrapper ref={popoverContentRef}>
236-
<PopoverContent>{content}</PopoverContent>
240+
<PopoverContent padding={padding}>{content}</PopoverContent>
237241
</PopoverContentWrapper>
238242
</PopoverContentContainer>
239243
)}

src/components/Popover/PopoverContent.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@ import styled from 'styled-components';
44
import { Spaces } from '../../essentials';
55
import { Card } from '../Card/Card';
66

7+
const DEFAULT_PADDING = Spaces[2];
8+
79
interface PopoverContentProps {
810
/**
911
* Popover content (can be any valid React Element or component)
1012
*/
1113
children: React.ReactNode;
14+
/**
15+
* Popover content padding
16+
*/
17+
padding: string | number;
1218
}
1319

14-
const PopoverContentContainer = styled(Card)`
20+
const PopoverContentContainer = styled(Card)<{ padding: string | number }>`
1521
display: block;
16-
padding: ${Spaces[2]};
22+
padding: ${props => props.padding};
1723
`;
1824

19-
export const PopoverContent = ({ children }: PopoverContentProps): React.ReactElement => (
25+
export const PopoverContent = ({ padding = DEFAULT_PADDING, children }: PopoverContentProps): React.ReactElement => (
2026
<>
21-
<PopoverContentContainer level={200}>{children}</PopoverContentContainer>
27+
<PopoverContentContainer padding={padding} level={200}>
28+
{children}
29+
</PopoverContentContainer>
2230
</>
2331
);

src/components/Popover/docs/Popover.mdx

+15
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ The Popover supports:
113113
```
114114
<br/>
115115

116+
### With No Padding
117+
118+
<ItemWrapper>
119+
<Popover content={'There is no padding...'} padding={0}>
120+
<Button size='small' variant="secondary"><SettingsIcon size={20} style={{marginRight: 5}} /> Manage Booking</Button>
121+
</Popover>
122+
</ItemWrapper>
123+
124+
```jsx
125+
<Popover content={'There is no padding...'} padding={0}>
126+
<Button size='small' variant="secondary"><SettingsIcon size={20} /> Manage Booking</Button>
127+
</Popover>
128+
```
129+
<br/>
130+
116131
## Playground
117132

118133
<Playground>

src/components/Table/docs/Table.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ActiveRowTable } from './ActiveRowTable'
99
import { ComplexDataTable } from './ComplexDataTable'
1010
import { SkeletonTable } from './SkeletonTable'
1111

12-
# Table (Experimental)
12+
# Table
1313

1414
Tables are used to render tabular data in a basic grid, making it easier for people to scan it. Tables are comprised of cells, columns, and rows.
1515

src/docs/PropsTable.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ export const PropsTable: React.FC<PropsTableProps> = ({ props: componentProps }:
3232
{prop.name}
3333
</Text>
3434
</TableCell>
35-
<TableCell>
35+
<TableCell style={{ whiteSpace: 'normal' }}>
3636
<Text fontSize="inherit" fontFamily="monospace" as="p">
3737
{prop.type}
3838
</Text>
3939
{prop.description && (
40-
<Text weak fontSize="inherit">
40+
<Text secondary fontSize="inherit">
4141
{prop.description}
4242
</Text>
4343
)}

src/essentials/Colors/docs/SemanticColorsTable.tsx

+8-10
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ const ColorBlock = styled.div<{ color: string }>`
2828
width: 4rem;
2929
`;
3030

31+
const flatSemanticColors = flattenObj(SemanticColors);
32+
const flatSemanticColorsKeys = [...flatSemanticColors.keys()] as string[];
33+
3134
export const SemanticColorsTable: FC = () => {
3235
const [nameSearchInput, setNameSearchInput] = useState('');
33-
const flatSemanticColors = flattenObj(SemanticColors);
34-
35-
const filteredColorKeys = Object.keys(flatSemanticColors).filter(it => {
36-
if (nameSearchInput === '') {
37-
return true;
38-
}
3936

40-
return it.toLowerCase().includes(nameSearchInput.toLowerCase());
41-
});
37+
const filteredColorKeys = !nameSearchInput
38+
? flatSemanticColorsKeys
39+
: flatSemanticColorsKeys.filter(it => it.toLowerCase().includes(nameSearchInput.toLowerCase().trim()));
4240

4341
return (
4442
<>
@@ -64,13 +62,13 @@ export const SemanticColorsTable: FC = () => {
6462
{filteredColorKeys.map(key => (
6563
<TableRow key={key}>
6664
<TableCell>
67-
<ColorBlock color={flatSemanticColors[key]} />
65+
<ColorBlock color={flatSemanticColors.get(key)} />
6866
</TableCell>
6967
<TableCell>
7068
<code>{key}</code>
7169
</TableCell>
7270
<TableCell>
73-
<code>{flatSemanticColors[key]}</code>
71+
<code>{flatSemanticColors.get(key)}</code>
7472
</TableCell>
7573
</TableRow>
7674
))}

0 commit comments

Comments
 (0)