@woosmap/ui 4.228.9 → 4.230.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/ui",
3
- "version": "4.228.9",
3
+ "version": "4.230.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -21,6 +21,7 @@ export default class Button extends Component {
21
21
  className,
22
22
  disabled,
23
23
  label,
24
+ ariaLabel,
24
25
  onClick,
25
26
  isLoading,
26
27
  active,
@@ -53,7 +54,7 @@ export default class Button extends Component {
53
54
  <button
54
55
  ref={this.elementRef}
55
56
  type={submitType ? 'submit' : 'button'}
56
- aria-label={label}
57
+ aria-label={ariaLabel}
57
58
  disabled={disabled}
58
59
  onClick={isLoading || disabled ? undefined : onClick}
59
60
  {...rest}
@@ -78,6 +79,7 @@ Button.defaultProps = {
78
79
  type: 'primary',
79
80
  className: '',
80
81
  label: '',
82
+ ariaLabel: null,
81
83
  icon: null,
82
84
  iconSize: 22,
83
85
  isLoading: false,
@@ -118,6 +120,7 @@ Button.propTypes = {
118
120
  isLoading: PropTypes.bool,
119
121
  active: PropTypes.bool,
120
122
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
123
+ ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
121
124
  icon: PropTypes.string,
122
125
  iconSize: PropTypes.number,
123
126
  className: PropTypes.string,
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
 
@@ -27,28 +27,36 @@ it('render distance demo', () => {
27
27
  it('test transport button', () => {
28
28
  render(<DistanceDemo />);
29
29
  expect(screen.getByText('mode=driving&\\')).toBeVisible();
30
- fireEvent.click(screen.getByAltText('Cycling'));
30
+ act(() => {
31
+ fireEvent.click(screen.getByAltText('Cycling'));
32
+ });
31
33
  expect(screen.getByText('mode=cycling&\\')).toBeVisible();
32
34
  });
33
35
 
34
36
  it('test metrics button', () => {
35
37
  render(<DistanceDemo />);
36
38
  expect(screen.getByText('units=metric&\\')).toBeVisible();
37
- fireEvent.click(screen.getByLabelText('Imperial'));
39
+ act(() => {
40
+ fireEvent.click(screen.getByText('Imperial'));
41
+ });
38
42
  expect(screen.getByText('units=imperial&\\')).toBeVisible();
39
43
  });
40
44
 
41
45
  it('test method button', () => {
42
46
  render(<DistanceDemo />);
43
47
  expect(screen.getByText('method=distance&\\')).toBeVisible();
44
- fireEvent.click(screen.getByLabelText('Fastest'));
48
+ act(() => {
49
+ fireEvent.click(screen.getByText('Fastest'));
50
+ });
45
51
  expect(screen.getByText('method=time&\\')).toBeVisible();
46
52
  });
47
53
 
48
54
  it('test language button', () => {
49
55
  render(<DistanceDemo />);
50
56
  expect(screen.getByText('language=en&\\')).toBeVisible();
51
- fireEvent.click(screen.getByTitle('Italian'));
57
+ act(() => {
58
+ fireEvent.click(screen.getByTitle('Italian'));
59
+ });
52
60
  expect(screen.getByText('language=it&\\')).toBeVisible();
53
61
  });
54
62
 
@@ -56,7 +64,9 @@ it('test alternative route checkbox', () => {
56
64
  render(<DistanceDemo />);
57
65
  expect(screen.getByText('alternatives=false"')).toBeVisible();
58
66
  const [checkbox] = screen.getByText('Alternative routes').parentElement.querySelectorAll('input');
59
- fireEvent.click(checkbox);
67
+ act(() => {
68
+ fireEvent.click(checkbox);
69
+ });
60
70
  expect(screen.getByText('alternatives=true"')).toBeVisible();
61
71
  });
62
72
 
@@ -35,7 +35,7 @@ it('calls navigator.clipboard.writeText function when click on copy button if if
35
35
  id="skeleton-test"
36
36
  />,
37
37
  );
38
- fireEvent.click(screen.getByLabelText('Copy'));
38
+ fireEvent.click(screen.getByText('Copy'));
39
39
  expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
40
40
  'curl "https://api.woosmap.com/localities/autocomplete/?input=paris"',
41
41
  );
@@ -45,7 +45,7 @@ it('calls navigator.clipboard.writeText function when click on copy button if if
45
45
  it('calls copy exec command when click on copy button if navigator.clipboard not supported', () => {
46
46
  render(<SkeletonDemo noheader id="skeleton-test" />);
47
47
  document.execCommand = jest.fn();
48
- fireEvent.click(screen.getByLabelText('Copy'));
48
+ fireEvent.click(screen.getByText('Copy'));
49
49
  expect(document.execCommand).toHaveBeenCalledWith('copy');
50
50
  });
51
51
 
@@ -370,6 +370,7 @@ class Dropdown extends Component {
370
370
  disabled,
371
371
  className,
372
372
  label,
373
+ ariaLabel,
373
374
  btnFace,
374
375
  btnSize,
375
376
  btnFaceIcon,
@@ -405,6 +406,7 @@ class Dropdown extends Component {
405
406
  size={btnSize}
406
407
  iconSize={btnFaceIconSize}
407
408
  label={label}
409
+ ariaLabel={ariaLabel}
408
410
  testId={testId}
409
411
  onMouseEnter={this.onMouseEnter}
410
412
  onMouseLeave={this.onMouseLeave}
@@ -424,6 +426,7 @@ Dropdown.defaultProps = {
424
426
  disableCloseOutside: false,
425
427
  onDoubleClick: null,
426
428
  label: null,
429
+ ariaLabel: null,
427
430
  className: null,
428
431
  closeCb: null,
429
432
  openOnMouseEnter: false,
@@ -443,6 +446,7 @@ Dropdown.propTypes = {
443
446
  disableCloseOutside: PropTypes.bool,
444
447
  openOnMouseEnter: PropTypes.bool,
445
448
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
449
+ ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
446
450
  testId: PropTypes.string,
447
451
  children: PropTypes.node.isRequired,
448
452
  className: PropTypes.string,
@@ -1,9 +1,8 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { fireEvent, render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
  import 'resize-observer-polyfill/dist/ResizeObserver.global';
5
5
 
6
- import { act } from 'react-dom/test-utils';
7
6
  import Dropdown from './Dropdown';
8
7
 
9
8
  it('renders a Dropdown component ', () => {
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen, getByRole, fireEvent } from '@testing-library/react';
3
- import { act } from 'react-dom/test-utils';
4
3
  import '@testing-library/jest-dom/extend-expect';
5
4
 
6
5
  import DynamicTag from './DynamicTag';
@@ -9,7 +9,7 @@ export default class Input extends Component {
9
9
  super(props);
10
10
  this.inputId = uniqueId();
11
11
  this.inputRef = React.createRef();
12
- this.state = { showPassword: false, value: null };
12
+ this.state = { showPassword: false, value: '' };
13
13
  }
14
14
 
15
15
  componentDidMount() {
@@ -146,7 +146,7 @@ export default class Input extends Component {
146
146
  onFocus,
147
147
  onKeyDown: this.onKeyDown,
148
148
  type: type === 'password' && showPassword ? 'text' : type,
149
- value: value !== undefined ? value : stateValue,
149
+ value: value !== undefined ? value : stateValue || '',
150
150
  size: length,
151
151
  disabled,
152
152
  onChange: this.onChange,
@@ -172,7 +172,7 @@ export default class Input extends Component {
172
172
  <Icon
173
173
  icon={showPassword ? 'eye-crossed-out' : 'eye'}
174
174
  size={iconSize}
175
- className={{ showed: showPassword }}
175
+ className={showPassword ? 'showed' : ''}
176
176
  />
177
177
  </span>
178
178
  )}
@@ -1,7 +1,6 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen, fireEvent } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
- import { act } from 'react-dom/test-utils';
5
4
 
6
5
  import Modal from './Modal';
7
6
 
@@ -1,7 +1,6 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
- import { act } from 'react-dom/test-utils';
5
4
  import userEvent from '@testing-library/user-event';
6
5
 
7
6
  import Panel from './Panel';
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
 
@@ -23,23 +23,33 @@ const barColors = [grey, red, orange, blue, green];
23
23
  describe('PasswordStrengthBar', () => {
24
24
  describe('Color changing / complexity', () => {
25
25
  it('renders all bars in grey when password is too short', async () => {
26
- render(<PasswordStrengthBar password={password.tooShort} barColors={barColors} />);
26
+ act(() => {
27
+ render(<PasswordStrengthBar password={password.tooShort} barColors={barColors} />);
28
+ });
27
29
  });
28
30
 
29
31
  it('renders the first bar in red and the others in grey when password is weak', async () => {
30
- render(<PasswordStrengthBar password={password.weak} barColors={barColors} />);
32
+ act(() => {
33
+ render(<PasswordStrengthBar password={password.weak} barColors={barColors} />);
34
+ });
31
35
  });
32
36
 
33
37
  it('renders the two first bars in orange and others in grey when password is okay', async () => {
34
- render(<PasswordStrengthBar password={password.okay} barColors={barColors} />);
38
+ act(() => {
39
+ render(<PasswordStrengthBar password={password.okay} barColors={barColors} />);
40
+ });
35
41
  });
36
42
 
37
43
  it('renders the three first bars in blue and the last in grey when password is good', async () => {
38
- render(<PasswordStrengthBar password={password.good} barColors={barColors} />);
44
+ act(() => {
45
+ render(<PasswordStrengthBar password={password.good} barColors={barColors} />);
46
+ });
39
47
  });
40
48
 
41
49
  it('renders all bars in green when password is strong', async () => {
42
- render(<PasswordStrengthBar password={password.strong} barColors={barColors} />);
50
+ act(() => {
51
+ render(<PasswordStrengthBar password={password.strong} barColors={barColors} />);
52
+ });
43
53
  });
44
54
  });
45
55
  });
@@ -65,11 +65,17 @@ Popover.defaultProps = {
65
65
 
66
66
  function withLayer(MyComponent) {
67
67
  function WrappedComponent(props) {
68
+ const {
69
+ forwardedRef,
70
+ container = null,
71
+ placement = 'bottom-center',
72
+ disableClickOutside = false,
73
+ ...rest
74
+ } = props;
68
75
  const [isOpen, setOpen] = React.useState(false);
69
76
  function close() {
70
77
  setOpen(false);
71
78
  }
72
- const { forwardedRef, container, placement, disableClickOutside, ...rest } = props;
73
79
  const { renderLayer, triggerProps, layerProps, arrowProps } = useLayer({
74
80
  isOpen,
75
81
  container,
@@ -95,17 +101,17 @@ function withLayer(MyComponent) {
95
101
  />
96
102
  );
97
103
  }
98
- WrappedComponent.defaultProps = {
99
- container: null,
100
- placement: 'bottom-center',
101
- disableClickOutside: false,
102
- };
103
104
  WrappedComponent.propTypes = {
104
105
  forwardedRef: PropTypes.object.isRequired,
105
106
  container: PropTypes.string,
106
107
  placement: PropTypes.string,
107
108
  disableClickOutside: PropTypes.bool,
108
109
  };
110
+ WrappedComponent.defaultProps = {
111
+ container: null,
112
+ placement: 'bottom-center',
113
+ disableClickOutside: false,
114
+ };
109
115
  return React.forwardRef((props, ref) => <WrappedComponent {...props} forwardedRef={ref} />);
110
116
  }
111
117
 
@@ -1,7 +1,6 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
- import { act } from 'react-dom/test-utils';
5
4
 
6
5
  import Button from '../Button/Button';
7
6
  import Popover from './Popover';
@@ -32,11 +31,13 @@ it('renders a Popover component ', () => {
32
31
  it('Button click should make it visible', () => {
33
32
  const ref = React.createRef();
34
33
  const testId = 'popover-content';
35
- render(
36
- <Popover content="My popover" ref={ref}>
37
- <Button onClick={() => {}} label="my button" />
38
- </Popover>,
39
- );
34
+ act(() => {
35
+ render(
36
+ <Popover content="My popover" ref={ref}>
37
+ <Button onClick={() => {}} label="my button" />
38
+ </Popover>,
39
+ );
40
+ });
40
41
  try {
41
42
  screen.getByTestId(testId);
42
43
  expect('Popover displayed').toBeFalsy();
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import React, { act } from 'react';
2
2
  import { render } from '@testing-library/react';
3
- import { act } from 'react-dom/test-utils';
4
3
  import '@testing-library/jest-dom/extend-expect';
5
4
  import ServiceMessage from './ServiceMessage';
6
5
 
@@ -41,7 +41,7 @@ it('renders a withFormValidation component ', () => {
41
41
 
42
42
  it('validates min length', () => {
43
43
  let error = validationStrategy('minLength', { minLength: 6 }, 'short');
44
- expect(error).toEqual('Should be at least 6 char long');
44
+ expect(error).toEqual('Should be at least 6 char long__plural');
45
45
  error = validationStrategy('minLength', { minLength: 6 }, 'longvalue');
46
46
  expect(error).toBeFalsy();
47
47
  });
@@ -50,7 +50,7 @@ it('validates max length', () => {
50
50
  let error = validationStrategy('maxLength', { maxLength: 6 }, 'short');
51
51
  expect(error).toBeFalsy();
52
52
  error = validationStrategy('maxLength', { maxLength: 6 }, 'tooolong');
53
- expect(error).toEqual('Should be at most 6 char long');
53
+ expect(error).toEqual('Should be at most 6 char long__plural');
54
54
  });
55
55
 
56
56
  it('validates required', () => {
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="Encoding">
4
- <file url="PROJECT" charset="UTF-8" />
5
- </component>
6
- </project>
@@ -1,30 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
6
- <option name="ignoredPackages">
7
- <value>
8
- <list size="16">
9
- <item index="0" class="java.lang.String" itemvalue="Fabric" />
10
- <item index="1" class="java.lang.String" itemvalue="PyYAML" />
11
- <item index="2" class="java.lang.String" itemvalue="Jinja2" />
12
- <item index="3" class="java.lang.String" itemvalue="github3.py" />
13
- <item index="4" class="java.lang.String" itemvalue="schedule" />
14
- <item index="5" class="java.lang.String" itemvalue="tzlocal" />
15
- <item index="6" class="java.lang.String" itemvalue="pydantic" />
16
- <item index="7" class="java.lang.String" itemvalue="django" />
17
- <item index="8" class="java.lang.String" itemvalue="django-cors-middleware" />
18
- <item index="9" class="java.lang.String" itemvalue="timezonefinder" />
19
- <item index="10" class="java.lang.String" itemvalue="application_kit" />
20
- <item index="11" class="java.lang.String" itemvalue="requests" />
21
- <item index="12" class="java.lang.String" itemvalue="PLY" />
22
- <item index="13" class="java.lang.String" itemvalue="ddtrace" />
23
- <item index="14" class="java.lang.String" itemvalue="humanize" />
24
- <item index="15" class="java.lang.String" itemvalue="types-redis" />
25
- </list>
26
- </value>
27
- </option>
28
- </inspection_tool>
29
- </profile>
30
- </component>
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <settings>
3
- <option name="USE_PROJECT_PROFILE" value="false" />
4
- <version value="1.0" />
5
- </settings>
6
- </component>
package/.idea/misc.xml DELETED
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
4
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/ui.iml" filepath="$PROJECT_DIR$/.idea/ui.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PrettierConfiguration">
4
- <option name="myConfigurationMode" value="AUTOMATIC" />
5
- </component>
6
- </project>
package/.idea/ui.iml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="PYTHON_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$" />
5
- <orderEntry type="inheritedJdk" />
6
- <orderEntry type="sourceFolder" forTests="false" />
7
- </component>
8
- </module>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>