@woosmap/ui 4.52.0 → 4.54.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.52.0",
3
+ "version": "4.54.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/WebGeoServices/ui.git"
@@ -111,6 +111,7 @@ Button.propTypes = {
111
111
  'tab',
112
112
  'tab--action',
113
113
  'tab--pills',
114
+ 'tab--disabled',
114
115
  'sidebar-link',
115
116
  ]),
116
117
  isLoading: PropTypes.bool,
@@ -4,6 +4,8 @@ import '@testing-library/jest-dom/extend-expect';
4
4
 
5
5
  import CopyClipboardButton from './CopyClipboardButton';
6
6
 
7
+ const textToBeCopied = 'Text to be copied';
8
+
7
9
  it('renders a CopyClipboardButton component ', () => {
8
10
  const { getByTestId } = render(<CopyClipboardButton text="Text" />);
9
11
  expect(getByTestId('copy-clipboard-button')).toHaveClass('btn');
@@ -14,15 +16,44 @@ it('renders a CopyClipboardButton component without label', () => {
14
16
  expect(getByTestId('copy-clipboard-button')).toHaveClass('btn--no-label');
15
17
  });
16
18
 
19
+ it('copies the content with navigator.clipboard supported', () => {
20
+ const writeText = jest.fn();
21
+
22
+ Object.assign(navigator, {
23
+ clipboard: {
24
+ writeText,
25
+ },
26
+ });
27
+ const { container } = render(<CopyClipboardButton text={textToBeCopied} />);
28
+ fireEvent.click(container.firstChild);
29
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith(textToBeCopied);
30
+ navigator.clipboard = null;
31
+ });
32
+
33
+ it('copies the content from callback with navigator.clipboard supported', () => {
34
+ const writeText = jest.fn();
35
+
36
+ Object.assign(navigator, {
37
+ clipboard: {
38
+ writeText,
39
+ },
40
+ });
41
+ const { container } = render(<CopyClipboardButton getText={() => textToBeCopied} />);
42
+ fireEvent.click(container.firstChild);
43
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith(textToBeCopied);
44
+ navigator.clipboard = null;
45
+ });
46
+
17
47
  it('copies the content', () => {
18
- const { container } = render(<CopyClipboardButton text="Text to be copied" />);
48
+ navigator.clipboard = null;
49
+ const { container } = render(<CopyClipboardButton text={textToBeCopied} />);
19
50
  document.execCommand = jest.fn();
20
51
  fireEvent.click(container.firstChild);
21
52
  expect(document.execCommand).toHaveBeenCalledWith('copy');
22
53
  });
23
54
 
24
55
  it('copies the content from callback', () => {
25
- const { container } = render(<CopyClipboardButton getText={() => 'Text to be copied'} />);
56
+ const { container } = render(<CopyClipboardButton getText={() => textToBeCopied} />);
26
57
  document.execCommand = jest.fn();
27
58
  fireEvent.click(container.firstChild);
28
59
  expect(document.execCommand).toHaveBeenCalledWith('copy');
@@ -110,7 +110,7 @@ export default class SkeletonDemo extends Component {
110
110
  serializedParams = `?\\\n${this.serializedParams()}`;
111
111
  }
112
112
 
113
- let curl = `curl ${xMethod}"${request}${serializedParams}" `;
113
+ let curl = `curl ${xMethod}"${request}${serializedParams}"`;
114
114
 
115
115
  if (referer) {
116
116
  curl += `\\\n -H 'referer: ${referer}'`;
@@ -121,7 +121,11 @@ export default class SkeletonDemo extends Component {
121
121
  }
122
122
 
123
123
  if (removeLineBreak) {
124
- curl = curl.replaceAll('\\\n', '');
124
+ if (!String.prototype.replaceAll) {
125
+ curl = curl.split('\\\n').join('');
126
+ } else {
127
+ curl = curl.replaceAll('\\\n', '');
128
+ }
125
129
  }
126
130
 
127
131
  return curl;
@@ -16,7 +16,29 @@ it('renders a SkeletonDemo component ', () => {
16
16
  expect(container.firstChild).toHaveAttribute('class', 'demo');
17
17
  });
18
18
 
19
- it('calls copy exec command when click on copy button', () => {
19
+ it('calls navigator.clipboard.writeText function when click on copy button if if navigator.clipboard supported', () => {
20
+ const writeText = jest.fn();
21
+
22
+ Object.assign(navigator, {
23
+ clipboard: {
24
+ writeText,
25
+ },
26
+ });
27
+ render(
28
+ <SkeletonDemo
29
+ request="https://api.woosmap.com/localities/autocomplete/?input=paris"
30
+ noheader
31
+ id="skeleton-test"
32
+ />
33
+ );
34
+ fireEvent.click(screen.getByLabelText('Copy'));
35
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
36
+ 'curl "https://api.woosmap.com/localities/autocomplete/?input=paris"'
37
+ );
38
+ navigator.clipboard = null;
39
+ });
40
+
41
+ it('calls copy exec command when click on copy button if navigator.clipboard not supported', () => {
20
42
  render(<SkeletonDemo noheader id="skeleton-test" />);
21
43
  document.execCommand = jest.fn();
22
44
  fireEvent.click(screen.getByLabelText('Copy'));
@@ -7,7 +7,11 @@ export default function CopyToClipboard(sourceStr = '') {
7
7
  document.body.appendChild(inputDom);
8
8
  inputDom.setSelectionRange(0, sourceStr.length);
9
9
  inputDom.select();
10
- document.execCommand('copy');
10
+ if (!navigator.clipboard) {
11
+ document.execCommand('copy');
12
+ } else {
13
+ navigator.clipboard.writeText(inputDom.value);
14
+ }
11
15
  document.body.removeChild(inputDom);
12
16
  return true;
13
17
  } catch (error) {
@@ -639,6 +639,9 @@
639
639
  &--demo
640
640
  &.btn.btn--primary
641
641
  background-color $demo
642
+ &:disabled
643
+ &:hover
644
+ background-color $demo
642
645
  &--small
643
646
  buttonSmall()
644
647
  &.btn--group