@shopgate/pwa-common 7.32.0-beta.2 → 7.32.0-beta.21

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.
Files changed (68) hide show
  1. package/actions/app/handleLink.js +6 -2
  2. package/components/Button/index.js +6 -0
  3. package/components/Image/Image.d.ts +78 -0
  4. package/components/Image/Image.d.ts.map +1 -0
  5. package/components/Image/Image.js +123 -91
  6. package/components/Image/ImageInner.d.ts +45 -0
  7. package/components/Image/ImageInner.d.ts.map +1 -0
  8. package/components/Image/ImageInner.js +23 -29
  9. package/components/Image/index.d.ts +3 -0
  10. package/components/Image/index.d.ts.map +1 -0
  11. package/components/Swiper/index.js +17 -2
  12. package/constants/Configuration.js +7 -0
  13. package/helpers/html/decodeHTML.js +5 -3
  14. package/helpers/html/htmlToText.js +15 -0
  15. package/helpers/mocks/mockRenderOptions.js +21 -0
  16. package/helpers/router/index.js +85 -0
  17. package/package.json +3 -3
  18. package/providers/toast/index.js +54 -40
  19. package/subscriptions/error.js +50 -27
  20. package/subscriptions/helpers/pipeline.js +68 -0
  21. package/subscriptions/router.js +22 -8
  22. package/action-creators/app/spec.js +0 -96
  23. package/action-creators/client/spec.js +0 -44
  24. package/action-creators/menu/spec.js +0 -37
  25. package/action-creators/modal/spec.js +0 -26
  26. package/action-creators/page/spec.js +0 -38
  27. package/action-creators/url/spec.js +0 -45
  28. package/action-creators/user/spec.js +0 -186
  29. package/components/Backdrop/spec.js +0 -24
  30. package/components/Button/spec.js +0 -42
  31. package/components/Checkbox/spec.js +0 -111
  32. package/components/CountdownTimer/spec.js +0 -141
  33. package/components/Drawer/spec.js +0 -79
  34. package/components/Ellipsis/spec.js +0 -15
  35. package/components/EmbeddedMedia/spec.js +0 -61
  36. package/components/Grid/components/Item/spec.js +0 -24
  37. package/components/Grid/spec.js +0 -24
  38. package/components/HtmlSanitizer/spec.js +0 -229
  39. package/components/I18n/components/FormatDate/spec.js +0 -54
  40. package/components/I18n/components/FormatNumber/spec.js +0 -51
  41. package/components/I18n/components/FormatPrice/spec.js +0 -54
  42. package/components/I18n/components/FormatTime/spec.js +0 -51
  43. package/components/I18n/components/I18nProvider/spec.js +0 -40
  44. package/components/I18n/components/Placeholder/spec.js +0 -37
  45. package/components/I18n/components/Translate/spec.js +0 -33
  46. package/components/InfiniteContainer/spec.js +0 -204
  47. package/components/Input/spec.js +0 -123
  48. package/components/Link/spec.js +0 -60
  49. package/components/List/spec.js +0 -26
  50. package/components/ModalContainer/spec.js +0 -115
  51. package/components/Select/spec.js +0 -122
  52. package/components/SelectBox/spec.js +0 -68
  53. package/components/Swiper/components/SwiperItem/spec.js +0 -26
  54. package/components/Widgets/components/Widget/spec.js +0 -75
  55. package/components/Widgets/components/WidgetGrid/spec.js +0 -53
  56. package/components/Widgets/spec.js +0 -234
  57. package/helpers/data/spec.js +0 -194
  58. package/helpers/date/spec.js +0 -92
  59. package/helpers/style/spec.js +0 -108
  60. package/helpers/validation/spec.js +0 -10
  61. package/styles/reset/form.js +0 -58
  62. package/styles/reset/index.js +0 -8
  63. package/styles/reset/media.js +0 -26
  64. package/styles/reset/root.js +0 -37
  65. package/styles/reset/table.js +0 -14
  66. package/styles/reset/typography.js +0 -30
  67. package/tsconfig.build.json +0 -16
  68. package/tsconfig.json +0 -3
@@ -1,194 +0,0 @@
1
- import { assignObjectDeep } from '.';
2
- import { isObject } from "../validation";
3
- describe('helpers/data', () => {
4
- describe('assignObjectDeep', () => {
5
- it('should merge simple objects correctly', () => {
6
- const modifier = {
7
- b: 0,
8
- c: null,
9
- d: undefined,
10
- g: 1.7,
11
- h: 'g',
12
- i: {
13
- x: 'x'
14
- },
15
- j: ['a', 'b']
16
- };
17
-
18
- // Object to be mutated
19
- const actual = {
20
- a: 0,
21
- b: 1,
22
- c: 'abc',
23
- d: 'def',
24
- e: 'ghi',
25
- f: null,
26
- g: 1.6
27
- };
28
- assignObjectDeep(actual, modifier, false);
29
- expect(actual).toEqual({
30
- a: 0,
31
- b: 0,
32
- c: null,
33
- d: undefined,
34
- e: 'ghi',
35
- f: null,
36
- g: 1.7,
37
- h: 'g',
38
- i: {
39
- x: 'x'
40
- },
41
- j: ['a', 'b']
42
- });
43
- });
44
- it('should merge objects containing sub-objects correctly', () => {
45
- const modifier = {
46
- a: {
47
- x: 2,
48
- y: {
49
- i: 'first mod',
50
- k: 'new entry'
51
- }
52
- },
53
- b: 'c',
54
- c: undefined,
55
- d: {
56
- x: 'x'
57
- },
58
- e: ['a', 'b']
59
- };
60
-
61
- // Object to be mutated
62
- const actual = {
63
- a: {
64
- x: 1,
65
- y: {
66
- i: 'first',
67
- j: 'second'
68
- }
69
- },
70
- b: {
71
- x: 2,
72
- y: {
73
- i: 'first',
74
- j: 'second'
75
- }
76
- }
77
- };
78
- assignObjectDeep(actual, modifier, false);
79
- expect(actual).toEqual({
80
- a: {
81
- x: 2,
82
- y: {
83
- i: 'first mod',
84
- j: 'second',
85
- k: 'new entry'
86
- }
87
- },
88
- b: 'c',
89
- c: undefined,
90
- d: {
91
- x: 'x'
92
- },
93
- e: ['a', 'b']
94
- });
95
- });
96
- it('should merge objects containing arrays correctly', () => {
97
- /**
98
- * This comparator detects unique scalar types and objects containing an id
99
- * within the 'a' prop
100
- *
101
- * @param {string} path path
102
- * @param {*} prev prev
103
- * @param {*} next next
104
- * @returns {boolean}
105
- */
106
- const comparator = (path, prev, next) => {
107
- // Scalar types
108
- if (!isObject(prev) || !isObject(next)) {
109
- return prev === next;
110
- }
111
-
112
- // Object merge only occurring on array object-items within the 'a' prop
113
- if (path.startsWith('$.a.')) {
114
- return prev.id === next.id;
115
- }
116
- return false;
117
- };
118
- const modifier = {
119
- b: [1, 2, 3],
120
- a: [['non-unique1', 'non-unique1'], 'unique element', 2, {
121
- id: 'custom-id-2',
122
- data: {
123
- x: null,
124
- y: {
125
- i: 'first',
126
- j: 'second mod',
127
- k: 'third'
128
- },
129
- z: 'new data entry'
130
- }
131
- }, {
132
- id: 'custom-id-3',
133
- data: {
134
- x: 'a'
135
- }
136
- }]
137
- };
138
-
139
- // Object to be mutated
140
- const actual = {
141
- a: [1, 'unique element', {
142
- id: 'custom-id-1',
143
- data: {
144
- x: 1,
145
- y: {
146
- i: 'first',
147
- j: 'second'
148
- }
149
- }
150
- }, {
151
- id: 'custom-id-2',
152
- data: {
153
- x: 1,
154
- y: {
155
- i: 'first',
156
- j: 'second'
157
- }
158
- }
159
- }, ['non-unique1', 'non-unique1']],
160
- b: [0]
161
- };
162
- assignObjectDeep(actual, modifier, false, comparator, '$');
163
- expect(actual).toEqual({
164
- a: [1, 'unique element', {
165
- id: 'custom-id-1',
166
- data: {
167
- x: 1,
168
- y: {
169
- i: 'first',
170
- j: 'second'
171
- }
172
- }
173
- }, {
174
- id: 'custom-id-2',
175
- data: {
176
- x: null,
177
- y: {
178
- i: 'first',
179
- j: 'second mod',
180
- k: 'third'
181
- },
182
- z: 'new data entry'
183
- }
184
- }, ['non-unique1', 'non-unique1'], ['non-unique1', 'non-unique1'], 2, {
185
- id: 'custom-id-3',
186
- data: {
187
- x: 'a'
188
- }
189
- }],
190
- b: [0, 1, 2, 3]
191
- });
192
- });
193
- });
194
- });
@@ -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
- });
@@ -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
- });
@@ -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
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * @deprecated used @shopgate/engage/styles/reset instead
3
- */
4
- import "./root";
5
- import "./typography";
6
- import "./media";
7
- import "./form";
8
- import "./table";
@@ -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
- });
@@ -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
- });
@@ -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
- });
@@ -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
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@shopgate/engage/tsconfig.json",
3
- }