@woosmap/ui 3.176.0 → 3.178.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc CHANGED
@@ -3,6 +3,13 @@
3
3
  "@babel/preset-react",
4
4
  "@babel/preset-env"
5
5
  ],
6
+ "env": {
7
+ "test": {
8
+ "plugins": [
9
+ "transform-dynamic-import"
10
+ ]
11
+ }
12
+ },
6
13
  "plugins": [
7
14
  [
8
15
  "@babel/plugin-proposal-class-properties"
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "3.176.0",
3
+ "version": "3.178.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
7
7
  },
8
8
  "main": "src/index.js",
9
+ "exports": {
10
+ ".": "./src/index.js",
11
+ "./src/website": "./src/website.js",
12
+ "./src/styles/style-website.styl": "./src/styles/style-website.styl"
13
+ },
9
14
  "dependencies": {
10
15
  "@mapbox/polyline": "^1.1.1",
11
16
  "axios": "^0.21.1",
@@ -75,6 +80,7 @@
75
80
  "@testing-library/react": "^11.2.7",
76
81
  "@testing-library/user-event": "^12.8.3",
77
82
  "babel-plugin-i18next-extract": "^0.8.3",
83
+ "babel-plugin-transform-dynamic-import": "^2.1.0",
78
84
  "concurrently": "^6.2.0",
79
85
  "eslint-config-airbnb": "^18.2.1",
80
86
  "eslint-config-prettier": "^8.3.0",
@@ -73,7 +73,7 @@ Label.defaultProps = {
73
73
  Label.propTypes = {
74
74
  label: PropTypes.string,
75
75
  testId: PropTypes.string,
76
- color: PropTypes.oneOf(['bleu', 'mauve', 'green', 'grey', 'orange', 'red', 'white', undefined, '']),
76
+ color: PropTypes.oneOf(['bleu', 'mauve', 'green', 'grey', 'orange', 'red', 'dark', 'white', undefined, '']),
77
77
  className: PropTypes.string,
78
78
  product: PropTypes.oneOf([
79
79
  'localities',
@@ -7,7 +7,7 @@
7
7
  font-size $buttonFontSize
8
8
  line-height 1.6
9
9
  padding .6rem $padding .6rem $padding
10
- color white
10
+ color $light
11
11
  background-color $primary
12
12
  margin .2rem 0
13
13
  word-break break-all
@@ -116,6 +116,8 @@
116
116
  background-color $labelOrange
117
117
  &--red
118
118
  background-color $labelRed
119
+ &--dark
120
+ background-color $secondary
119
121
  &--white
120
122
  background-color $light
121
123
  color $secondary
@@ -1,6 +1,5 @@
1
1
  import React, { Fragment, Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import zxcvbn from 'zxcvbn';
4
3
 
5
4
  export default class PasswordStrengthBar extends Component {
6
5
  constructor(props) {
@@ -25,20 +24,15 @@ export default class PasswordStrengthBar extends Component {
25
24
  const { password, minLength, onChangeScore } = this.props;
26
25
  let result = null;
27
26
  let score = 0;
28
- if (password.length >= minLength) {
29
- result = zxcvbn(password);
30
- ({ score } = result);
31
- }
32
- this.setState(
33
- {
34
- score,
35
- },
36
- () => {
37
- if (onChangeScore) {
38
- onChangeScore(score);
39
- }
27
+ import('zxcvbn').then(({ default: zxcvbn }) => {
28
+ if (password.length >= minLength) {
29
+ result = zxcvbn(password);
30
+ ({ score } = result);
40
31
  }
41
- );
32
+ this.setState({ score }, () => {
33
+ if (onChangeScore) onChangeScore(score);
34
+ });
35
+ });
42
36
  };
43
37
 
44
38
  render() {
@@ -1,41 +1,113 @@
1
1
  import React from 'react';
2
- import { render, screen } from '@testing-library/react';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
 
5
5
  import PasswordStrengthBar from './PasswordStrengthBar';
6
6
 
7
- it('renders a PasswordStrengthBar', () => {
8
- const { container } = render(<PasswordStrengthBar password="mypassword" />);
9
- expect(container.firstChild).toHaveClass('password-strength');
10
- });
7
+ const password = {
8
+ tooShort: '',
9
+ weak: 'mypassword',
10
+ okay: 'myPasswrd',
11
+ good: 'myPasswrd)',
12
+ strong: 'sdkjsd!!jdjdhsldkk!!!',
13
+ };
14
+
15
+ const grey = '#ddd';
16
+ const red = '#ef4836';
17
+ const orange = '#f6b44d';
18
+ const blue = '#2b90ef';
19
+ const green = '#25c281';
20
+
21
+ const barColors = [grey, red, orange, blue, green];
22
+
23
+ describe('PasswordStrengthBar', () => {
24
+ it('renders', async () => {
25
+ const { container } = render(<PasswordStrengthBar password="mypassword" />);
26
+ expect(container.firstChild).toHaveClass('password-strength');
27
+
28
+ const bar1 = await waitFor(() => screen.getByTestId('1'));
29
+ expect(bar1).toHaveClass('password-strength__item');
30
+ });
31
+
32
+ describe('Color changing / complexity', () => {
33
+ it('renders all bars in grey when password is too short', async () => {
34
+ render(<PasswordStrengthBar password={password.tooShort} barColors={barColors} />);
35
+
36
+ const bar1 = await waitFor(() => screen.getByTestId('1'));
37
+ expect(bar1).toHaveStyle({ backgroundColor: grey });
38
+
39
+ const bar2 = await waitFor(() => screen.getByTestId('2'));
40
+ expect(bar2).toHaveStyle({ backgroundColor: grey });
41
+
42
+ const bar3 = await waitFor(() => screen.getByTestId('3'));
43
+ expect(bar3).toHaveStyle({ backgroundColor: grey });
44
+
45
+ const bar4 = await waitFor(() => screen.getByTestId('4'));
46
+ expect(bar4).toHaveStyle({ backgroundColor: grey });
47
+ });
48
+
49
+ it('renders the first bar in red and the others in grey when password is weak', async () => {
50
+ render(<PasswordStrengthBar password={password.weak} barColors={barColors} />);
51
+
52
+ const bar1 = await waitFor(() => screen.getByTestId('1'));
53
+ expect(bar1).toHaveStyle({ backgroundColor: red });
54
+
55
+ const bar2 = await waitFor(() => screen.getByTestId('2'));
56
+ expect(bar2).toHaveStyle({ backgroundColor: grey });
57
+
58
+ const bar3 = await waitFor(() => screen.getByTestId('3'));
59
+ expect(bar3).toHaveStyle({ backgroundColor: grey });
60
+
61
+ const bar4 = await waitFor(() => screen.getByTestId('4'));
62
+ expect(bar4).toHaveStyle({ backgroundColor: grey });
63
+ });
64
+
65
+ it('renders the two first bars in orange and others in grey when password is okay', async () => {
66
+ render(<PasswordStrengthBar password={password.okay} barColors={barColors} />);
67
+
68
+ const bar1 = await waitFor(() => screen.getByTestId('1'));
69
+ expect(bar1).toHaveStyle({ backgroundColor: orange });
70
+
71
+ const bar2 = await waitFor(() => screen.getByTestId('2'));
72
+ expect(bar2).toHaveStyle({ backgroundColor: orange });
73
+
74
+ const bar3 = await waitFor(() => screen.getByTestId('3'));
75
+ expect(bar3).toHaveStyle({ backgroundColor: grey });
76
+
77
+ const bar4 = await waitFor(() => screen.getByTestId('4'));
78
+ expect(bar4).toHaveStyle({ backgroundColor: grey });
79
+ });
80
+
81
+ it('renders the three first bars in blue and the last in grey when password is good', async () => {
82
+ render(<PasswordStrengthBar password={password.good} barColors={barColors} />);
83
+
84
+ const bar1 = await waitFor(() => screen.getByTestId('1'));
85
+ expect(bar1).toHaveStyle({ backgroundColor: blue });
86
+
87
+ const bar2 = await waitFor(() => screen.getByTestId('2'));
88
+ expect(bar2).toHaveStyle({ backgroundColor: blue });
89
+
90
+ const bar3 = await waitFor(() => screen.getByTestId('3'));
91
+ expect(bar3).toHaveStyle({ backgroundColor: blue });
92
+
93
+ const bar4 = await waitFor(() => screen.getByTestId('4'));
94
+ expect(bar4).toHaveStyle({ backgroundColor: grey });
95
+ });
96
+
97
+ it('renders all bars in green when password is strong', async () => {
98
+ render(<PasswordStrengthBar password={password.strong} barColors={barColors} />);
99
+
100
+ const bar1 = await waitFor(() => screen.getByTestId('1'));
101
+ expect(bar1).toHaveStyle({ backgroundColor: green });
102
+
103
+ const bar2 = await waitFor(() => screen.getByTestId('2'));
104
+ expect(bar2).toHaveStyle({ backgroundColor: green });
105
+
106
+ const bar3 = await waitFor(() => screen.getByTestId('3'));
107
+ expect(bar3).toHaveStyle({ backgroundColor: green });
11
108
 
12
- it('renders a PasswordStrengthBar with color changing / complexity', () => {
13
- const { container } = render(
14
- <PasswordStrengthBar
15
- password=""
16
- barColors={['#ddd', '#ef4836', '#f6b44d', '#2b90ef', '#25c281']}
17
- />
18
- );
19
- expect(screen.getByTestId('1')).toHaveClass('password-strength__item');
20
- expect(screen.getByTestId('1')).toHaveStyle({ backgroundColor: '#ddd' });
21
-
22
- render(
23
- <PasswordStrengthBar
24
- password="mypassword"
25
- barColors={['#ddd', '#ef4836', '#f6b44d', '#2b90ef', '#25c281']}
26
- />,
27
- { container }
28
- );
29
- expect(screen.getByTestId('1')).toHaveStyle({ backgroundColor: '#ef4836' });
30
- expect(screen.getByTestId('4')).toHaveStyle({ backgroundColor: '#ddd' });
31
-
32
- render(
33
- <PasswordStrengthBar
34
- password="sdkjsd!!jdjdhsldkk!!!"
35
- barColors={['#ddd', '#ef4836', '#f6b44d', '#2b90ef', '#25c281']}
36
- />,
37
- { container }
38
- );
39
- expect(screen.getByTestId('1')).toHaveStyle({ backgroundColor: '#25c281' });
40
- expect(screen.getByTestId('4')).toHaveStyle({ backgroundColor: '#25c281' });
109
+ const bar4 = await waitFor(() => screen.getByTestId('4'));
110
+ expect(bar4).toHaveStyle({ backgroundColor: green });
111
+ });
112
+ });
41
113
  });
package/src/website.js ADDED
@@ -0,0 +1,23 @@
1
+ export { changeLanguage } from './components/utils/locale';
2
+
3
+ export { default as Button } from './components/Button/Button';
4
+ export { default as Dropdown } from './components/Dropdown/Dropdown';
5
+ export { default as Flash } from './components/Flash/Flash';
6
+ export { default as Icon } from './components/Icon/Icon';
7
+
8
+ export { default as Input } from './components/Input/Input';
9
+ export { default as PasswordStrengthBar } from './components/PasswordStrengthBar/PasswordStrengthBar';
10
+ export { default as Popover } from './components/Popover/Popover';
11
+ export { default as Select } from './components/Select/Select';
12
+
13
+ export { default as LocalitiesDemo } from './components/Demo/LocalitiesDemo';
14
+ export { default as LocalitiesCheckoutUKDemo } from './components/Demo/LocalitiesUKAddressDemo';
15
+ export { default as LocalitiesCheckoutFRDemo } from './components/Demo/LocalitiesFRAddressDemo';
16
+ export { default as LocalitiesAddressDemo } from './components/Demo/LocalitiesAddressDemo';
17
+ export { default as LocalitiesAllDemo } from './components/Demo/LocalitiesAllDemo';
18
+ export { default as MerchantDemo } from './components/Demo/MerchantDemo';
19
+ export { default as GeolocationDemo } from './components/Demo/GeolocationDemo';
20
+ export { default as DistanceDemo } from './components/Demo/DistanceDemo';
21
+ export { default as SearchDemo } from './components/Demo/SearchDemo';
22
+ export { default as AddressDemo } from './components/Demo/AddressDemo';
23
+ export { default as MapDemo } from './components/Demo/MapDemo';