@shopgate/pwa-common 7.32.0-beta.2 → 7.32.0-beta.20
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/components/Button/index.js +6 -0
- package/components/Image/Image.d.ts +78 -0
- package/components/Image/Image.d.ts.map +1 -0
- package/components/Image/Image.js +123 -91
- package/components/Image/ImageInner.d.ts +45 -0
- package/components/Image/ImageInner.d.ts.map +1 -0
- package/components/Image/ImageInner.js +23 -29
- package/components/Image/index.d.ts +3 -0
- package/components/Image/index.d.ts.map +1 -0
- package/components/Swiper/index.js +17 -2
- package/constants/Configuration.js +7 -0
- package/helpers/mocks/mockRenderOptions.js +21 -0
- package/package.json +3 -3
- package/providers/toast/index.js +54 -40
- package/subscriptions/error.js +50 -27
- package/subscriptions/helpers/pipeline.js +68 -0
- package/subscriptions/router.js +2 -2
- package/action-creators/app/spec.js +0 -96
- package/action-creators/client/spec.js +0 -44
- package/action-creators/menu/spec.js +0 -37
- package/action-creators/modal/spec.js +0 -26
- package/action-creators/page/spec.js +0 -38
- package/action-creators/url/spec.js +0 -45
- package/action-creators/user/spec.js +0 -186
- package/components/Backdrop/spec.js +0 -24
- package/components/Button/spec.js +0 -42
- package/components/Checkbox/spec.js +0 -111
- package/components/CountdownTimer/spec.js +0 -141
- package/components/Drawer/spec.js +0 -79
- package/components/Ellipsis/spec.js +0 -15
- package/components/EmbeddedMedia/spec.js +0 -61
- package/components/Grid/components/Item/spec.js +0 -24
- package/components/Grid/spec.js +0 -24
- package/components/HtmlSanitizer/spec.js +0 -229
- package/components/I18n/components/FormatDate/spec.js +0 -54
- package/components/I18n/components/FormatNumber/spec.js +0 -51
- package/components/I18n/components/FormatPrice/spec.js +0 -54
- package/components/I18n/components/FormatTime/spec.js +0 -51
- package/components/I18n/components/I18nProvider/spec.js +0 -40
- package/components/I18n/components/Placeholder/spec.js +0 -37
- package/components/I18n/components/Translate/spec.js +0 -33
- package/components/InfiniteContainer/spec.js +0 -204
- package/components/Input/spec.js +0 -123
- package/components/Link/spec.js +0 -60
- package/components/List/spec.js +0 -26
- package/components/ModalContainer/spec.js +0 -115
- package/components/Select/spec.js +0 -122
- package/components/SelectBox/spec.js +0 -68
- package/components/Swiper/components/SwiperItem/spec.js +0 -26
- package/components/Widgets/components/Widget/spec.js +0 -75
- package/components/Widgets/components/WidgetGrid/spec.js +0 -53
- package/components/Widgets/spec.js +0 -234
- package/helpers/data/spec.js +0 -194
- package/helpers/date/spec.js +0 -92
- package/helpers/style/spec.js +0 -108
- package/helpers/validation/spec.js +0 -10
- package/styles/reset/form.js +0 -58
- package/styles/reset/index.js +0 -8
- package/styles/reset/media.js +0 -26
- package/styles/reset/root.js +0 -37
- package/styles/reset/table.js +0 -14
- package/styles/reset/typography.js +0 -30
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -3
package/helpers/date/spec.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { isBefore, isAfter, isBetween, parseDuration, addDuration } from '.';
|
|
2
|
-
describe('helpers/date', () => {
|
|
3
|
-
const date10Hours = new Date('2019-01-01T10:00:00.000Z');
|
|
4
|
-
const date12Hours = new Date('2019-01-01T12:00:00.000Z');
|
|
5
|
-
describe('isBefore', () => {
|
|
6
|
-
it('should be before', () => {
|
|
7
|
-
expect(isBefore(new Date('2019-01-01T09:59:59.000Z'), date10Hours)).toBeTruthy();
|
|
8
|
-
});
|
|
9
|
-
it('should be not before', () => {
|
|
10
|
-
expect(isBefore(new Date('2019-01-01T10:00:00.000Z'), date10Hours)).toBeFalsy();
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe('isAfter', () => {
|
|
14
|
-
it('should be after', () => {
|
|
15
|
-
expect(isAfter(new Date('2019-01-01T10:00:01.000Z'), date10Hours)).toBeTruthy();
|
|
16
|
-
});
|
|
17
|
-
it('should be not after', () => {
|
|
18
|
-
expect(isAfter(new Date('2019-01-01T10:00:00.000Z'), date10Hours)).toBeFalsy();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('isBetween', () => {
|
|
22
|
-
it('should be between', () => {
|
|
23
|
-
expect(isBetween(new Date('2019-01-01T11:00:00.000Z'), date10Hours, date12Hours)).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
it('should be not between', () => {
|
|
26
|
-
expect(isBetween(new Date('2019-01-01T09:00:00.000Z'), date10Hours, date12Hours)).toBeFalsy();
|
|
27
|
-
expect(isBetween(new Date('2019-01-01T13:00:00.000Z'), date10Hours, date12Hours)).toBeFalsy();
|
|
28
|
-
});
|
|
29
|
-
it('should be inclusively between', () => {
|
|
30
|
-
expect(isBetween(new Date('2019-01-01T10:00:00.000Z'), date10Hours, date12Hours)).toBeTruthy();
|
|
31
|
-
expect(isBetween(new Date('2019-01-01T12:00:00.000Z'), date10Hours, date12Hours)).toBeTruthy();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe('parseDuration', () => {
|
|
35
|
-
const parsed = {
|
|
36
|
-
Year: undefined,
|
|
37
|
-
Month: undefined,
|
|
38
|
-
Week: undefined,
|
|
39
|
-
Day: undefined,
|
|
40
|
-
Hour: undefined,
|
|
41
|
-
Minute: undefined,
|
|
42
|
-
Second: undefined
|
|
43
|
-
};
|
|
44
|
-
it('should parse 10 second', () => {
|
|
45
|
-
expect(parseDuration('PT10S')).toEqual({
|
|
46
|
-
...parsed,
|
|
47
|
-
Second: 10
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
it('should parse 1 hour', () => {
|
|
51
|
-
expect(parseDuration('PT1H')).toEqual({
|
|
52
|
-
...parsed,
|
|
53
|
-
Hour: 1
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
it('should parse 5 day', () => {
|
|
57
|
-
expect(parseDuration('P5D')).toEqual({
|
|
58
|
-
...parsed,
|
|
59
|
-
Day: 5
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
it('should parse -5 day', () => {
|
|
63
|
-
expect(parseDuration('-P5D')).toEqual({
|
|
64
|
-
...parsed,
|
|
65
|
-
Day: -5
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('addDuration', () => {
|
|
70
|
-
const dateStub = '2019-01-01T11:00:00.000Z';
|
|
71
|
-
let date;
|
|
72
|
-
beforeEach(() => {
|
|
73
|
-
date = new Date(dateStub);
|
|
74
|
-
});
|
|
75
|
-
it('should add 0sec', () => {
|
|
76
|
-
addDuration(date, 'PT0S');
|
|
77
|
-
expect(date).toEqual(date);
|
|
78
|
-
});
|
|
79
|
-
it('should add 1 hour', () => {
|
|
80
|
-
addDuration(date, 'PT1H');
|
|
81
|
-
expect(date).toEqual(new Date('2019-01-01T12:00:00.000Z'));
|
|
82
|
-
});
|
|
83
|
-
it('should add 5 day', () => {
|
|
84
|
-
addDuration(date, 'P5D');
|
|
85
|
-
expect(date).toEqual(new Date('2019-01-06T11:00:00.000Z'));
|
|
86
|
-
});
|
|
87
|
-
it('should subtract 5 day', () => {
|
|
88
|
-
addDuration(date, '-P5D');
|
|
89
|
-
expect(date).toEqual(new Date('2018-12-27T11:00:00.000Z'));
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
});
|
package/helpers/style/spec.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { rem, physicalPixelSize } from "./index";
|
|
2
|
-
describe('style helper', () => {
|
|
3
|
-
describe('rem helper with 16px rootSize', () => {
|
|
4
|
-
it('should output 0.875rem for 16px input', () => {
|
|
5
|
-
expect(rem(16)).toBe('1rem');
|
|
6
|
-
});
|
|
7
|
-
it('should output 0.875rem for 14px input', () => {
|
|
8
|
-
expect(rem(14)).toBe('0.875rem');
|
|
9
|
-
});
|
|
10
|
-
it('should output 0.75rem for 12px input', () => {
|
|
11
|
-
expect(rem(12)).toBe('0.75rem');
|
|
12
|
-
});
|
|
13
|
-
it('should output 0rem for 0px input', () => {
|
|
14
|
-
expect(rem(0)).toBe('0rem');
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe('rem helper error handling', () => {
|
|
18
|
-
let consoleSpy;
|
|
19
|
-
beforeAll(() => {
|
|
20
|
-
// Deactivate the console for the next tests to avoid logs within the test report.
|
|
21
|
-
consoleSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
22
|
-
});
|
|
23
|
-
afterAll(() => {
|
|
24
|
-
consoleSpy.mockRestore();
|
|
25
|
-
});
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
consoleSpy.mockReset();
|
|
28
|
-
});
|
|
29
|
-
it('should output 1rem as fallback for wrong parameters', () => {
|
|
30
|
-
expect(rem('rem')).toBe('1rem');
|
|
31
|
-
expect(consoleSpy).toHaveBeenCalledTimes(1);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe('physicalPixelSize', () => {
|
|
35
|
-
describe('non-Android devices', () => {
|
|
36
|
-
beforeAll(() => {
|
|
37
|
-
Object.defineProperty(window.navigator, 'userAgent', {
|
|
38
|
-
value: 'Not And... user agent',
|
|
39
|
-
configurable: true
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
it('should output declarations for 1px size', () => {
|
|
43
|
-
expect(physicalPixelSize('foo', 1)).toEqual({
|
|
44
|
-
foo: 1,
|
|
45
|
-
'@media (min-device-pixel-ratio: 2)': {
|
|
46
|
-
foo: 0.5
|
|
47
|
-
},
|
|
48
|
-
'@media (-webkit-min-device-pixel-ratio: 2)': {
|
|
49
|
-
foo: 0.5
|
|
50
|
-
},
|
|
51
|
-
'@media (min-device-pixel-ratio: 3)': {
|
|
52
|
-
foo: 0.33
|
|
53
|
-
},
|
|
54
|
-
'@media (-webkit-min-device-pixel-ratio: 3)': {
|
|
55
|
-
foo: 0.33
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
it('should output declarations for 2px size', () => {
|
|
60
|
-
expect(physicalPixelSize('foo', 2)).toEqual({
|
|
61
|
-
foo: 2,
|
|
62
|
-
'@media (min-device-pixel-ratio: 2)': {
|
|
63
|
-
foo: 1
|
|
64
|
-
},
|
|
65
|
-
'@media (-webkit-min-device-pixel-ratio: 2)': {
|
|
66
|
-
foo: 1
|
|
67
|
-
},
|
|
68
|
-
'@media (min-device-pixel-ratio: 3)': {
|
|
69
|
-
foo: 0.67
|
|
70
|
-
},
|
|
71
|
-
'@media (-webkit-min-device-pixel-ratio: 3)': {
|
|
72
|
-
foo: 0.67
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
it('should output declarations for 3px size', () => {
|
|
77
|
-
expect(physicalPixelSize('foo', 3)).toEqual({
|
|
78
|
-
foo: 3,
|
|
79
|
-
'@media (min-device-pixel-ratio: 2)': {
|
|
80
|
-
foo: 1.5
|
|
81
|
-
},
|
|
82
|
-
'@media (-webkit-min-device-pixel-ratio: 2)': {
|
|
83
|
-
foo: 1.5
|
|
84
|
-
},
|
|
85
|
-
'@media (min-device-pixel-ratio: 3)': {
|
|
86
|
-
foo: 1
|
|
87
|
-
},
|
|
88
|
-
'@media (-webkit-min-device-pixel-ratio: 3)': {
|
|
89
|
-
foo: 1
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe('android devices', () => {
|
|
95
|
-
beforeAll(() => {
|
|
96
|
-
Object.defineProperty(window.navigator, 'userAgent', {
|
|
97
|
-
value: 'Foo Android',
|
|
98
|
-
configurable: true
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
it('should return natural number rules only', () => {
|
|
102
|
-
expect(physicalPixelSize('foo', 3)).toEqual({
|
|
103
|
-
foo: 3
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { isNumeric } from "./index";
|
|
2
|
-
describe('helpers/validation', () => {
|
|
3
|
-
describe('isNumeric', () => {
|
|
4
|
-
describe('Non-regression, "123" is not numeric', () => {
|
|
5
|
-
it('should treat numeric number as numeric', () => {
|
|
6
|
-
expect(isNumeric('123')).toBe(true);
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
});
|
package/styles/reset/form.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 1. Correct the inability to style clickable types in iOS and Safari.
|
|
9
|
-
* since iOS 15 button has a default color of blue rgb(0, 122, 255);
|
|
10
|
-
*
|
|
11
|
-
* 1. Change font properties to `inherit` in Safari.
|
|
12
|
-
* 2. Correct the inability to style clickable types in iOS and Safari.
|
|
13
|
-
*
|
|
14
|
-
* Remove the inner padding and cancel buttons in Chrome and Safari for OS X.
|
|
15
|
-
*/
|
|
16
|
-
injectGlobal({
|
|
17
|
-
'button, html [type="button"], [type="reset"], [type="submit"]': {
|
|
18
|
-
WebkitAppearance: 'button'
|
|
19
|
-
},
|
|
20
|
-
button: {
|
|
21
|
-
color: 'inherit',
|
|
22
|
-
borderRadius: 0
|
|
23
|
-
},
|
|
24
|
-
'::-webkit-file-upload-button': {
|
|
25
|
-
font: 'inherit',
|
|
26
|
-
WebkitAppearance: 'button'
|
|
27
|
-
},
|
|
28
|
-
'::-webkit-search-cancel-button, ::-webkit-search-decoration': {
|
|
29
|
-
WebkitAppearance: 'none'
|
|
30
|
-
},
|
|
31
|
-
'button, input, select, textarea': {
|
|
32
|
-
background: 'transparent',
|
|
33
|
-
border: 0,
|
|
34
|
-
fontSize: '1em',
|
|
35
|
-
margin: 0
|
|
36
|
-
},
|
|
37
|
-
'input, select, textarea': {
|
|
38
|
-
fontFamily: 'inherit'
|
|
39
|
-
},
|
|
40
|
-
'button, textarea': {
|
|
41
|
-
fontFamily: 'inherit',
|
|
42
|
-
lineHeight: 'inherit'
|
|
43
|
-
},
|
|
44
|
-
'button, label, [type="checkbox"], [type="radio"]': {
|
|
45
|
-
cursor: 'pointer'
|
|
46
|
-
},
|
|
47
|
-
label: {
|
|
48
|
-
display: 'inline-block'
|
|
49
|
-
},
|
|
50
|
-
textarea: {
|
|
51
|
-
minHeight: '5em',
|
|
52
|
-
maxWidth: '100%',
|
|
53
|
-
resize: 'none'
|
|
54
|
-
},
|
|
55
|
-
'[type="search"]': {
|
|
56
|
-
WebkitAppearance: 'textfield'
|
|
57
|
-
}
|
|
58
|
-
});
|
package/styles/reset/index.js
DELETED
package/styles/reset/media.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles/reset instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
injectGlobal({
|
|
7
|
-
'audio:not([controls])': {
|
|
8
|
-
display: 'none',
|
|
9
|
-
height: 0
|
|
10
|
-
},
|
|
11
|
-
figure: {
|
|
12
|
-
margin: 0
|
|
13
|
-
},
|
|
14
|
-
iframe: {
|
|
15
|
-
border: 0,
|
|
16
|
-
display: 'block',
|
|
17
|
-
width: '100%'
|
|
18
|
-
},
|
|
19
|
-
'img, svg': {
|
|
20
|
-
display: 'block',
|
|
21
|
-
maxWidth: '100%'
|
|
22
|
-
},
|
|
23
|
-
progress: {
|
|
24
|
-
verticalAlign: 'baseline'
|
|
25
|
-
}
|
|
26
|
-
});
|
package/styles/reset/root.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
import { themeConfig } from "../../helpers/config";
|
|
7
|
-
const {
|
|
8
|
-
typography
|
|
9
|
-
} = themeConfig;
|
|
10
|
-
injectGlobal({
|
|
11
|
-
'*, *:before, *:after': {
|
|
12
|
-
boxSizing: 'border-box'
|
|
13
|
-
},
|
|
14
|
-
'html, body': {
|
|
15
|
-
WebkitTapHighlightColor: 'transparent',
|
|
16
|
-
width: '100%',
|
|
17
|
-
height: '100%'
|
|
18
|
-
},
|
|
19
|
-
html: {
|
|
20
|
-
overflow: 'hidden',
|
|
21
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
22
|
-
WebkitFontSmoothing: 'antialiased',
|
|
23
|
-
MsTextSizeAdjust: '100%',
|
|
24
|
-
WebkitTextSizeAdjust: '100%',
|
|
25
|
-
minHeight: '100%'
|
|
26
|
-
},
|
|
27
|
-
body: {
|
|
28
|
-
font: `${typography.rootSize}px/${typography.lineHeight} ${typography.family}`,
|
|
29
|
-
overflow: 'auto',
|
|
30
|
-
margin: 0,
|
|
31
|
-
WebkitOverflowScrolling: 'touch',
|
|
32
|
-
WebkitUserSelect: 'none'
|
|
33
|
-
},
|
|
34
|
-
'[data-pattern]': {
|
|
35
|
-
height: '100% !important'
|
|
36
|
-
}
|
|
37
|
-
});
|
package/styles/reset/table.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
injectGlobal({
|
|
7
|
-
table: {
|
|
8
|
-
borderCollapse: 'collapse',
|
|
9
|
-
minWidth: '100%'
|
|
10
|
-
},
|
|
11
|
-
'td, th': {
|
|
12
|
-
verticalAlign: 'top'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
import { rem } from "../../helpers/style";
|
|
7
|
-
injectGlobal({
|
|
8
|
-
a: {
|
|
9
|
-
color: 'inherit',
|
|
10
|
-
textDecoration: 'none',
|
|
11
|
-
WebkitTextDecorationSkip: 'objects'
|
|
12
|
-
},
|
|
13
|
-
'a:hover, a:focus, a:active, [tabindex]': {
|
|
14
|
-
outline: 0
|
|
15
|
-
},
|
|
16
|
-
'ol, ul': {
|
|
17
|
-
listStyle: 'none',
|
|
18
|
-
margin: 0,
|
|
19
|
-
paddingLeft: 0
|
|
20
|
-
},
|
|
21
|
-
'b, strong': {
|
|
22
|
-
fontWeight: 700
|
|
23
|
-
},
|
|
24
|
-
small: {
|
|
25
|
-
fontSize: rem(13)
|
|
26
|
-
},
|
|
27
|
-
'sub, sup': {
|
|
28
|
-
lineHeight: 0
|
|
29
|
-
}
|
|
30
|
-
});
|
package/tsconfig.build.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@shopgate/engage/tsconfig.build.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"rootDir": "."
|
|
6
|
-
},
|
|
7
|
-
"include": ["**/*.ts", "**/*.tsx"],
|
|
8
|
-
"exclude": [
|
|
9
|
-
"dist",
|
|
10
|
-
"node_modules",
|
|
11
|
-
"**/*.spec.*",
|
|
12
|
-
"**/__tests__/**",
|
|
13
|
-
"**/__snapshots__/**",
|
|
14
|
-
"coverage"
|
|
15
|
-
]
|
|
16
|
-
}
|
package/tsconfig.json
DELETED