@searchspring/snap-preact-components 0.65.2 → 0.66.1
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/dist/cjs/components/Atoms/Icon/Icon.d.ts +1 -0
- package/dist/cjs/components/Atoms/Icon/Icon.d.ts.map +1 -1
- package/dist/cjs/components/Atoms/Icon/Icon.js +14 -12
- package/dist/cjs/components/Molecules/Carousel/Carousel.d.ts +2 -0
- package/dist/cjs/components/Molecules/Carousel/Carousel.d.ts.map +1 -1
- package/dist/cjs/components/Molecules/Carousel/Carousel.js +32 -3
- package/dist/cjs/components/Molecules/Result/Result.d.ts.map +1 -1
- package/dist/cjs/components/Molecules/Result/Result.js +2 -6
- package/dist/cjs/components/Organisms/Recommendation/Recommendation.d.ts +1 -0
- package/dist/cjs/components/Organisms/Recommendation/Recommendation.d.ts.map +1 -1
- package/dist/cjs/components/Organisms/RecommendationBundle/RecommendationBundle.js +1 -1
- package/dist/cjs/components/Organisms/Results/Results.d.ts.map +1 -1
- package/dist/cjs/components/Organisms/Results/Results.js +11 -9
- package/dist/cjs/components/Trackers/ResultTracker/ResultTracker.d.ts.map +1 -1
- package/dist/cjs/components/Trackers/ResultTracker/ResultTracker.js +7 -18
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/useIntersectionAdvanced.d.ts +1 -2
- package/dist/cjs/hooks/useIntersectionAdvanced.d.ts.map +1 -1
- package/dist/cjs/hooks/useIntersectionAdvanced.js +47 -53
- package/dist/cjs/hooks/useTracking.d.ts +12 -0
- package/dist/cjs/hooks/useTracking.d.ts.map +1 -0
- package/dist/cjs/hooks/useTracking.js +41 -0
- package/dist/cjs/providers/index.d.ts +1 -0
- package/dist/cjs/providers/index.d.ts.map +1 -1
- package/dist/cjs/providers/index.js +1 -0
- package/dist/cjs/providers/withTracking.d.ts +11 -0
- package/dist/cjs/providers/withTracking.d.ts.map +1 -0
- package/dist/cjs/providers/withTracking.js +66 -0
- package/dist/cjs/utilities/createImpressionObserver.d.ts +8 -0
- package/dist/cjs/utilities/createImpressionObserver.d.ts.map +1 -0
- package/dist/cjs/utilities/createImpressionObserver.js +19 -0
- package/dist/cjs/utilities/index.d.ts +1 -0
- package/dist/cjs/utilities/index.d.ts.map +1 -1
- package/dist/cjs/utilities/index.js +1 -0
- package/dist/esm/components/Atoms/Icon/Icon.d.ts +1 -0
- package/dist/esm/components/Atoms/Icon/Icon.d.ts.map +1 -1
- package/dist/esm/components/Atoms/Icon/Icon.js +14 -12
- package/dist/esm/components/Molecules/Carousel/Carousel.d.ts +2 -0
- package/dist/esm/components/Molecules/Carousel/Carousel.d.ts.map +1 -1
- package/dist/esm/components/Molecules/Carousel/Carousel.js +35 -3
- package/dist/esm/components/Molecules/Result/Result.d.ts.map +1 -1
- package/dist/esm/components/Molecules/Result/Result.js +2 -4
- package/dist/esm/components/Organisms/Recommendation/Recommendation.d.ts +1 -0
- package/dist/esm/components/Organisms/Recommendation/Recommendation.d.ts.map +1 -1
- package/dist/esm/components/Organisms/RecommendationBundle/RecommendationBundle.js +1 -1
- package/dist/esm/components/Organisms/Results/Results.d.ts.map +1 -1
- package/dist/esm/components/Organisms/Results/Results.js +5 -5
- package/dist/esm/components/Trackers/ResultTracker/ResultTracker.d.ts.map +1 -1
- package/dist/esm/components/Trackers/ResultTracker/ResultTracker.js +7 -18
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useIntersectionAdvanced.d.ts +1 -2
- package/dist/esm/hooks/useIntersectionAdvanced.d.ts.map +1 -1
- package/dist/esm/hooks/useIntersectionAdvanced.js +36 -51
- package/dist/esm/hooks/useTracking.d.ts +12 -0
- package/dist/esm/hooks/useTracking.d.ts.map +1 -0
- package/dist/esm/hooks/useTracking.js +36 -0
- package/dist/esm/providers/index.d.ts +1 -0
- package/dist/esm/providers/index.d.ts.map +1 -1
- package/dist/esm/providers/index.js +1 -0
- package/dist/esm/providers/withTracking.d.ts +11 -0
- package/dist/esm/providers/withTracking.d.ts.map +1 -0
- package/dist/esm/providers/withTracking.js +45 -0
- package/dist/esm/utilities/createImpressionObserver.d.ts +8 -0
- package/dist/esm/utilities/createImpressionObserver.d.ts.map +1 -0
- package/dist/esm/utilities/createImpressionObserver.js +15 -0
- package/dist/esm/utilities/index.d.ts +1 -0
- package/dist/esm/utilities/index.d.ts.map +1 -1
- package/dist/esm/utilities/index.js +1 -0
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../../../src/components/Atoms/Icon/Icon.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,OAAO,EAAe,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAMxD,OAAO,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAa9C,wBAAgB,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../../../src/components/Atoms/Icon/Icon.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,OAAO,EAAe,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAMxD,OAAO,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAa9C,wBAAgB,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAmDvD;AAED,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACX,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACF,CAAC;AAEF,MAAM,WAAW,SAAU,SAAQ,cAAc;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -52,7 +52,7 @@ function Icon(properties) {
|
|
|
52
52
|
var props = __assign(__assign(__assign({
|
|
53
53
|
// default props
|
|
54
54
|
size: '16px', viewBox: '0 0 56 56' }, (_a = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _a === void 0 ? void 0 : _a.icon), properties), (_c = (_b = properties.theme) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.icon);
|
|
55
|
-
var color = props.color, icon = props.icon, path = props.path, children = props.children, size = props.size, width = props.width, height = props.height, viewBox = props.viewBox, disableStyles = props.disableStyles, className = props.className, style = props.style, otherProps = __rest(props, ["color", "icon", "path", "children", "size", "width", "height", "viewBox", "disableStyles", "className", "style"]);
|
|
55
|
+
var color = props.color, icon = props.icon, path = props.path, children = props.children, size = props.size, width = props.width, title = props.title, height = props.height, viewBox = props.viewBox, disableStyles = props.disableStyles, className = props.className, style = props.style, otherProps = __rest(props, ["color", "icon", "path", "children", "size", "width", "title", "height", "viewBox", "disableStyles", "className", "style"]);
|
|
56
56
|
var iconPath = paths_1.iconPaths[icon] || path;
|
|
57
57
|
var pathType = typeof iconPath;
|
|
58
58
|
var styling = {};
|
|
@@ -63,16 +63,18 @@ function Icon(properties) {
|
|
|
63
63
|
styling.css = [style];
|
|
64
64
|
}
|
|
65
65
|
return children || (iconPath && (pathType === 'string' || (pathType === 'object' && Array.isArray(iconPath)))) ? ((0, react_1.jsx)(providers_1.CacheProvider, null,
|
|
66
|
-
(0, react_1.jsx)("svg", __assign({}, styling, { className: (0, classnames_1.default)('ss__icon', icon ? "ss__icon--".concat(icon) : null, className), viewBox: viewBox, xmlns: "http://www.w3.org/2000/svg", width: disableStyles ? width || size : undefined, height: disableStyles ? height || size : undefined }, otherProps),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
(0, react_1.jsx)("svg", __assign({}, styling, { className: (0, classnames_1.default)('ss__icon', icon ? "ss__icon--".concat(icon) : null, className), viewBox: viewBox, xmlns: "http://www.w3.org/2000/svg", width: disableStyles ? width || size : undefined, height: disableStyles ? height || size : undefined }, otherProps),
|
|
67
|
+
title ? (0, react_1.jsx)("title", null, title) : null,
|
|
68
|
+
(function () {
|
|
69
|
+
if (children) {
|
|
70
|
+
return children;
|
|
71
|
+
}
|
|
72
|
+
else if (pathType === 'string') {
|
|
73
|
+
return (0, react_1.jsx)("path", { fill: disableStyles ? color : undefined, d: iconPath });
|
|
74
|
+
}
|
|
75
|
+
else if (iconPath && pathType === 'object' && Array.isArray(iconPath)) {
|
|
76
|
+
return iconPath.map(function (p, i) { return (0, react_1.jsx)(p.type, __assign({ key: i }, p.attributes)); });
|
|
77
|
+
}
|
|
78
|
+
})()))) : ((0, react_1.jsx)(preact_1.Fragment, null));
|
|
77
79
|
}
|
|
78
80
|
exports.Icon = Icon;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Swiper as SwiperTypes } from 'swiper';
|
|
3
3
|
import type { PaginationOptions } from 'swiper/types/modules/pagination';
|
|
4
4
|
import type { NavigationOptions } from 'swiper/types/modules/navigation';
|
|
5
|
+
import type { ScrollbarOptions } from 'swiper/types/modules/scrollbar';
|
|
5
6
|
import { ComponentProps, BreakpointsProps } from '../../../types';
|
|
6
7
|
export declare const defaultCarouselBreakpoints: {
|
|
7
8
|
0: {
|
|
@@ -48,6 +49,7 @@ export interface CarouselProps extends ComponentProps {
|
|
|
48
49
|
vertical?: boolean;
|
|
49
50
|
pagination?: boolean | PaginationOptions;
|
|
50
51
|
navigation?: boolean | NavigationOptions;
|
|
52
|
+
scrollbar?: boolean | ScrollbarOptions;
|
|
51
53
|
autoAdjustSlides?: boolean;
|
|
52
54
|
onClick?: (swiper: SwiperTypes, e: MouseEvent | TouchEvent | PointerEvent) => void;
|
|
53
55
|
onNextButtonClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/Carousel/Carousel.tsx"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/Carousel/Carousel.tsx"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIvE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAkJ9E,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BtC,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,QAAQ,eAAyB,aAAa,KAAG,WA2Q5D,CAAC;AAEH,MAAM,WAAW,aAAc,SAAQ,cAAc;IACpD,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IACvC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,YAAY,KAAK,IAAI,CAAC;IACnF,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAC3E,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAC3E,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC7C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;CACxB"}
|
|
@@ -41,7 +41,7 @@ var providers_1 = require("../../../providers");
|
|
|
41
41
|
var useDisplaySettings_1 = require("../../../hooks/useDisplaySettings");
|
|
42
42
|
var CSS = {
|
|
43
43
|
carousel: function (_a) {
|
|
44
|
-
var _b, _c;
|
|
44
|
+
var _b, _c, _d;
|
|
45
45
|
var theme = _a.theme, vertical = _a.vertical;
|
|
46
46
|
return (0, react_1.css)({
|
|
47
47
|
display: 'flex',
|
|
@@ -159,6 +159,22 @@ var CSS = {
|
|
|
159
159
|
'.swiper-vertical': {
|
|
160
160
|
touchAction: 'pan-x',
|
|
161
161
|
},
|
|
162
|
+
'.swiper-scrollbar': {
|
|
163
|
+
position: 'absolute',
|
|
164
|
+
bottom: '0',
|
|
165
|
+
left: '0',
|
|
166
|
+
width: '100%',
|
|
167
|
+
height: '2px',
|
|
168
|
+
backgroundColor: '#d9d9d9',
|
|
169
|
+
'&:empty': {
|
|
170
|
+
display: 'none',
|
|
171
|
+
},
|
|
172
|
+
'.swiper-scrollbar-drag': {
|
|
173
|
+
position: 'relative',
|
|
174
|
+
height: '100%',
|
|
175
|
+
backgroundColor: ((_d = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _d === void 0 ? void 0 : _d.primary) || '#000',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
162
178
|
});
|
|
163
179
|
},
|
|
164
180
|
};
|
|
@@ -225,6 +241,7 @@ exports.Carousel = (0, mobx_react_1.observer)(function (properties) {
|
|
|
225
241
|
var children = props.children, loop = props.loop, nextButton = props.nextButton, prevButton = props.prevButton, hideButtons = props.hideButtons, vertical = props.vertical, onInit = props.onInit, onBeforeInit = props.onBeforeInit, onAfterInit = props.onAfterInit, onNextButtonClick = props.onNextButtonClick, onPrevButtonClick = props.onPrevButtonClick, onClick = props.onClick, disableStyles = props.disableStyles, style = props.style, modules = props.modules, className = props.className, additionalProps = __rest(props, ["children", "loop", "nextButton", "prevButton", "hideButtons", "vertical", "onInit", "onBeforeInit", "onAfterInit", "onNextButtonClick", "onPrevButtonClick", "onClick", "disableStyles", "style", "modules", "className"]);
|
|
226
242
|
var pagination = props.pagination;
|
|
227
243
|
var navigation = props.navigation;
|
|
244
|
+
var scrollbar = props.scrollbar;
|
|
228
245
|
var subProps = {
|
|
229
246
|
icon: __assign(__assign(__assign({
|
|
230
247
|
// default props
|
|
@@ -234,7 +251,9 @@ exports.Carousel = (0, mobx_react_1.observer)(function (properties) {
|
|
|
234
251
|
// component theme overrides
|
|
235
252
|
theme: props.theme }),
|
|
236
253
|
};
|
|
237
|
-
var swiperModulesUnfiltered = Array.isArray(modules)
|
|
254
|
+
var swiperModulesUnfiltered = Array.isArray(modules)
|
|
255
|
+
? [modules_1.Navigation, modules_1.Pagination, modules_1.Scrollbar, modules_1.A11y].concat(modules)
|
|
256
|
+
: [modules_1.Navigation, modules_1.Pagination, modules_1.Scrollbar, modules_1.A11y];
|
|
238
257
|
//remove any duplicates, in case user passes in Navigation or Pagination
|
|
239
258
|
var swiperModules = swiperModulesUnfiltered.filter(function (module, pos) { return swiperModulesUnfiltered.indexOf(module) === pos; });
|
|
240
259
|
var navigationPrevRef = (0, hooks_1.useRef)(null);
|
|
@@ -278,6 +297,16 @@ exports.Carousel = (0, mobx_react_1.observer)(function (properties) {
|
|
|
278
297
|
prevEl: '.ss_carousel_DNE',
|
|
279
298
|
};
|
|
280
299
|
}
|
|
300
|
+
if (scrollbar) {
|
|
301
|
+
if (typeof scrollbar == 'object') {
|
|
302
|
+
scrollbar = __assign({ enabled: true }, scrollbar);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
scrollbar = {
|
|
306
|
+
enabled: true,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
281
310
|
var attachClasstoLastVisibleSlide = function () {
|
|
282
311
|
if (rootComponentRef.current) {
|
|
283
312
|
var swiperElem = rootComponentRef.current;
|
|
@@ -329,7 +358,7 @@ exports.Carousel = (0, mobx_react_1.observer)(function (properties) {
|
|
|
329
358
|
}
|
|
330
359
|
}, onClick: function (swiper, e) {
|
|
331
360
|
onClick && onClick(swiper, e);
|
|
332
|
-
}, direction: vertical ? 'vertical' : 'horizontal', loop: loop, threshold: 7, loopAddBlankSlides: false, modules: swiperModules }, additionalProps, displaySettings, { navigation: navigation, pagination: pagination, onResize: function (swiper) {
|
|
361
|
+
}, direction: vertical ? 'vertical' : 'horizontal', loop: loop, threshold: 7, loopAddBlankSlides: false, modules: swiperModules }, additionalProps, displaySettings, { navigation: navigation, pagination: pagination, scrollbar: scrollbar, onResize: function (swiper) {
|
|
333
362
|
if (additionalProps.onResize) {
|
|
334
363
|
additionalProps.onResize();
|
|
335
364
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Result.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/Result/Result.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAsB,MAAM,gBAAgB,CAAC;AAGhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AA4D7D,eAAO,MAAM,MAAM,eAAyB,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"Result.d.ts","sourceRoot":"","sources":["../../../../../src/components/Molecules/Result/Result.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAsB,MAAM,gBAAgB,CAAC;AAGhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AA4D7D,eAAO,MAAM,MAAM,eAAyB,WAAW,KAAG,WAmKxD,CAAC;AAQH,UAAU,kBAAkB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,cAAc;IAClD,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;IAClE,UAAU,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;CAClF"}
|
|
@@ -88,7 +88,7 @@ exports.Result = (0, mobx_react_1.observer)(function (properties) {
|
|
|
88
88
|
var props = __assign(__assign(__assign({
|
|
89
89
|
// default props
|
|
90
90
|
layout: types_1.Layout.GRID }, (_a = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _a === void 0 ? void 0 : _a.result), properties), (_c = (_b = properties.theme) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.result);
|
|
91
|
-
var result = props.result, hideBadge = props.hideBadge, hideTitle = props.hideTitle, hidePricing = props.hidePricing, hideImage = props.hideImage, detailSlot = props.detailSlot, fallback = props.fallback, disableStyles = props.disableStyles, className = props.className, layout = props.layout, onClick = props.onClick, style = props.style, controller = props.controller;
|
|
91
|
+
var trackingRef = props.trackingRef, result = props.result, hideBadge = props.hideBadge, hideTitle = props.hideTitle, hidePricing = props.hidePricing, hideImage = props.hideImage, detailSlot = props.detailSlot, fallback = props.fallback, disableStyles = props.disableStyles, className = props.className, layout = props.layout, onClick = props.onClick, style = props.style, controller = props.controller;
|
|
92
92
|
var core = ((_d = result === null || result === void 0 ? void 0 : result.display) === null || _d === void 0 ? void 0 : _d.mappings.core) || ((_e = result === null || result === void 0 ? void 0 : result.mappings) === null || _e === void 0 ? void 0 : _e.core);
|
|
93
93
|
var subProps = {
|
|
94
94
|
price: __assign(__assign(__assign({
|
|
@@ -135,12 +135,10 @@ exports.Result = (0, mobx_react_1.observer)(function (properties) {
|
|
|
135
135
|
styling.css = [style];
|
|
136
136
|
}
|
|
137
137
|
return core ? ((0, react_1.jsx)(providers_1.CacheProvider, null,
|
|
138
|
-
(0, react_1.jsx)("article", __assign({}, styling, { className: (0, classnames_1.default)('ss__result', "ss__result--".concat(layout), className) }),
|
|
138
|
+
(0, react_1.jsx)("article", __assign({}, styling, { ref: trackingRef, className: (0, classnames_1.default)('ss__result', "ss__result--".concat(layout), className) }),
|
|
139
139
|
(0, react_1.jsx)("div", { className: "ss__result__image-wrapper" },
|
|
140
140
|
(0, react_1.jsx)("a", { href: core.url, onClick: function (e) {
|
|
141
|
-
var _a, _b;
|
|
142
141
|
onClick && onClick(e);
|
|
143
|
-
(_b = (_a = controller === null || controller === void 0 ? void 0 : controller.track) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.click(e, result);
|
|
144
142
|
} }, !hideImage &&
|
|
145
143
|
(!hideBadge ? ((0, react_1.jsx)(OverlayBadge_1.OverlayBadge, __assign({}, subProps.overlayBadge, { controller: controller }),
|
|
146
144
|
(0, react_1.jsx)(Image_1.Image, __assign({}, subProps.image)))) : ((0, react_1.jsx)(Image_1.Image, __assign({}, subProps.image)))))),
|
|
@@ -148,9 +146,7 @@ exports.Result = (0, mobx_react_1.observer)(function (properties) {
|
|
|
148
146
|
!hideBadge && ((0, react_1.jsx)(CalloutBadge_1.CalloutBadge, __assign({}, subProps.calloutBadge, { controller: controller }))),
|
|
149
147
|
!hideTitle && ((0, react_1.jsx)("div", { className: "ss__result__details__title" },
|
|
150
148
|
(0, react_1.jsx)("a", { href: core.url, onClick: function (e) {
|
|
151
|
-
var _a, _b;
|
|
152
149
|
onClick && onClick(e);
|
|
153
|
-
(_b = (_a = controller === null || controller === void 0 ? void 0 : controller.track) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.click(e, result);
|
|
154
150
|
}, dangerouslySetInnerHTML: {
|
|
155
151
|
__html: displayName || '',
|
|
156
152
|
} }))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Recommendation.d.ts","sourceRoot":"","sources":["../../../../../src/components/Organisms/Recommendation/Recommendation.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,OAAO,EAAe,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAMxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAO7D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAe9E,eAAO,MAAM,cAAc,eAAyB,mBAAmB,KAAG,WA8JxE,CAAC;AAEH,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IAC1D,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,wBAAwB,CAAC;IACrC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE;QACZ,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"Recommendation.d.ts","sourceRoot":"","sources":["../../../../../src/components/Organisms/Recommendation/Recommendation.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,OAAO,EAAe,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAMxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAO7D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAe9E,eAAO,MAAM,cAAc,eAAyB,mBAAmB,KAAG,WA8JxE,CAAC;AAEH,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IAC1D,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,wBAAwB,CAAC;IACrC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE;QACZ,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACF"}
|
|
@@ -266,7 +266,7 @@ exports.RecommendationBundle = (0, mobx_react_1.observer)(function (properties)
|
|
|
266
266
|
};
|
|
267
267
|
var addToCart = function (e) {
|
|
268
268
|
// add to cart tracking
|
|
269
|
-
controller.
|
|
269
|
+
controller.addToCart(selectedItems);
|
|
270
270
|
//call the function passed
|
|
271
271
|
onAddToCart && onAddToCart(e, selectedItems);
|
|
272
272
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Results.d.ts","sourceRoot":"","sources":["../../../../../src/components/Organisms/Results/Results.tsx"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,+BAA+B,CAAC;AAIxF,OAAO,EAAE,cAAc,EAAU,UAAU,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Results.d.ts","sourceRoot":"","sources":["../../../../../src/components/Organisms/Results/Results.tsx"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,+BAA+B,CAAC;AAIxF,OAAO,EAAE,cAAc,EAAU,UAAU,EAAE,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAgClG,eAAO,MAAM,OAAO,eAAyB,WAAW,KAAG,WA4GzD,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,cAAc;IAClD,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,UAAU,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;CAClF"}
|
|
@@ -28,7 +28,6 @@ var types_1 = require("../../../types");
|
|
|
28
28
|
var utilities_1 = require("../../../utilities");
|
|
29
29
|
var providers_1 = require("../../../providers");
|
|
30
30
|
var useDisplaySettings_1 = require("../../../hooks/useDisplaySettings");
|
|
31
|
-
var ResultTracker_1 = require("../../Trackers/ResultTracker");
|
|
32
31
|
var CSS = {
|
|
33
32
|
results: function (_a) {
|
|
34
33
|
var columns = _a.columns, gapSize = _a.gapSize;
|
|
@@ -53,6 +52,7 @@ var CSS = {
|
|
|
53
52
|
});
|
|
54
53
|
},
|
|
55
54
|
};
|
|
55
|
+
var ResultComponent = (0, providers_1.withTracking)(Result_1.Result);
|
|
56
56
|
exports.Results = (0, mobx_react_1.observer)(function (properties) {
|
|
57
57
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
58
58
|
var globalTheme = (0, providers_1.useTheme)();
|
|
@@ -105,12 +105,14 @@ exports.Results = (0, mobx_react_1.observer)(function (properties) {
|
|
|
105
105
|
styling.css = [style];
|
|
106
106
|
}
|
|
107
107
|
return (results === null || results === void 0 ? void 0 : results.length) ? ((0, react_1.jsx)(providers_1.CacheProvider, null,
|
|
108
|
-
(0, react_1.jsx)("div", __assign({}, styling, { className: (0, classnames_1.default)('ss__results', "ss__results-".concat(props.layout), className) }), results.map(function (result) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
(0, react_1.jsx)("div", __assign({}, styling, { className: (0, classnames_1.default)('ss__results', "ss__results-".concat(props.layout), className) }), results.map(function (result) {
|
|
109
|
+
return (function () {
|
|
110
|
+
switch (result.type) {
|
|
111
|
+
case snap_store_mobx_1.ContentType.BANNER:
|
|
112
|
+
return (0, react_1.jsx)(InlineBanner_1.InlineBanner, __assign({}, subProps.inlineBanner, { key: result.id, banner: result, layout: props.layout }));
|
|
113
|
+
default:
|
|
114
|
+
return ((0, react_1.jsx)(ResultComponent, __assign({ key: result.id }, subProps.result, { result: result, layout: props.layout, controller: controller })));
|
|
115
|
+
}
|
|
116
|
+
})();
|
|
117
|
+
})))) : ((0, react_1.jsx)(preact_1.Fragment, null));
|
|
116
118
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultTracker.d.ts","sourceRoot":"","sources":["../../../../../src/components/Trackers/ResultTracker/ResultTracker.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,OAAO,EAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"ResultTracker.d.ts","sourceRoot":"","sources":["../../../../../src/components/Trackers/ResultTracker/ResultTracker.tsx"],"names":[],"mappings":";AAAA,eAAe;AACf,OAAO,EAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAI9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AASrE,eAAO,MAAM,aAAa,eAAyB,kBAAkB,KAAG,WAsDtE,CAAC;AAEH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACzD,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,UAAU,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;IACjF,KAAK,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,KAAK,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;CACF"}
|
|
@@ -16,11 +16,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.ResultTracker = void 0;
|
|
18
18
|
var react_1 = require("@emotion/react");
|
|
19
|
-
var hooks_1 = require("preact/hooks");
|
|
20
19
|
var mobx_react_1 = require("mobx-react");
|
|
21
20
|
var providers_1 = require("../../../providers");
|
|
22
|
-
var hooks_2 = require("../../../hooks");
|
|
23
21
|
var classnames_1 = __importDefault(require("classnames"));
|
|
22
|
+
var utilities_1 = require("../../../utilities");
|
|
24
23
|
var CSS = {
|
|
25
24
|
ResultTracker: function () { return (0, react_1.css)({}); },
|
|
26
25
|
};
|
|
@@ -35,16 +34,8 @@ exports.ResultTracker = (0, mobx_react_1.observer)(function (properties) {
|
|
|
35
34
|
var props = __assign(__assign(__assign({}, (_a = globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.components) === null || _a === void 0 ? void 0 : _a.ResultTracker), properties), (_c = (_b = properties.theme) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.ResultTracker);
|
|
36
35
|
var children = props.children, result = props.result, track = props.track, controller = props.controller, className = props.className, disableStyles = props.disableStyles, style = props.style;
|
|
37
36
|
var mergedTrack = __assign(__assign({}, defaultTrack), track);
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
key: result.id,
|
|
41
|
-
rootMargin: '0px',
|
|
42
|
-
fireOnce: true,
|
|
43
|
-
threshold: 0.75,
|
|
44
|
-
startDelay: 2000, // TODO: look into dynamically setting this to a lower value for first row of products
|
|
45
|
-
minVisibleTime: 150,
|
|
46
|
-
});
|
|
47
|
-
if (resultInViewport && mergedTrack.impression) {
|
|
37
|
+
var _d = (0, utilities_1.createImpressionObserver)(), ref = _d.ref, inViewport = _d.inViewport;
|
|
38
|
+
if (inViewport && mergedTrack.impression) {
|
|
48
39
|
if (result.type === 'product') {
|
|
49
40
|
controller === null || controller === void 0 ? void 0 : controller.track.product.impression(result);
|
|
50
41
|
}
|
|
@@ -59,11 +50,9 @@ exports.ResultTracker = (0, mobx_react_1.observer)(function (properties) {
|
|
|
59
50
|
else if (style) {
|
|
60
51
|
styling.css = [style];
|
|
61
52
|
}
|
|
62
|
-
return ((0, react_1.jsx)("div", __assign({
|
|
63
|
-
if (mergedTrack.click) {
|
|
64
|
-
|
|
65
|
-
controller === null || controller === void 0 ? void 0 : controller.track.product.click(e, result);
|
|
66
|
-
}
|
|
53
|
+
return ((0, react_1.jsx)("div", __assign({ className: (0, classnames_1.default)('ss__result-tracker', "ss__".concat(controller === null || controller === void 0 ? void 0 : controller.type, "-result-tracker"), className), onClick: function (e) {
|
|
54
|
+
if (result.type === 'product' && mergedTrack.click) {
|
|
55
|
+
controller === null || controller === void 0 ? void 0 : controller.track.product.click(e, result);
|
|
67
56
|
}
|
|
68
|
-
}, ref:
|
|
57
|
+
}, ref: ref }, styling), children));
|
|
69
58
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MutableRef } from 'preact/hooks';
|
|
2
2
|
interface UseIntersectionOptions {
|
|
3
|
-
key?: string;
|
|
4
3
|
rootMargin?: string;
|
|
5
4
|
fireOnce?: boolean;
|
|
6
5
|
threshold?: number | number[];
|
|
7
|
-
startDelay?: number;
|
|
8
6
|
minVisibleTime?: number;
|
|
7
|
+
additionalEffectKeys?: unknown[];
|
|
9
8
|
}
|
|
10
9
|
export declare const useIntersectionAdvanced: (ref: MutableRef<HTMLElement | null>, options?: UseIntersectionOptions) => boolean;
|
|
11
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionAdvanced.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIntersectionAdvanced.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,UAAU,sBAAsB;IAC/B,
|
|
1
|
+
{"version":3,"file":"useIntersectionAdvanced.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIntersectionAdvanced.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,UAAU,sBAAsB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,OAAO,EAAE,CAAC;CACjC;AAED,eAAO,MAAM,uBAAuB,QAAS,WAAW,WAAW,GAAG,IAAI,CAAC,YAAW,sBAAsB,KAAQ,OAiFnH,CAAC"}
|
|
@@ -1,82 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.useIntersectionAdvanced = void 0;
|
|
4
13
|
var hooks_1 = require("preact/hooks");
|
|
5
14
|
var useIntersectionAdvanced = function (ref, options) {
|
|
6
15
|
if (options === void 0) { options = {}; }
|
|
7
|
-
var _a = options.
|
|
16
|
+
var _a = options.rootMargin, rootMargin = _a === void 0 ? '0px' : _a, _b = options.fireOnce, fireOnce = _b === void 0 ? false : _b, _c = options.threshold, threshold = _c === void 0 ? 0 : _c, _d = options.minVisibleTime, minVisibleTime = _d === void 0 ? 0 : _d;
|
|
8
17
|
// State and setter for storing whether element is visible
|
|
9
|
-
var
|
|
18
|
+
var _e = (0, hooks_1.useState)(false), isIntersecting = _e[0], setIntersecting = _e[1];
|
|
10
19
|
// Timer reference to track visibility duration
|
|
11
20
|
var visibleTimerRef = (0, hooks_1.useRef)(null);
|
|
12
21
|
// Track when the element started being visible
|
|
13
22
|
var visibleStartRef = (0, hooks_1.useRef)(null);
|
|
14
23
|
(0, hooks_1.useEffect)(function () {
|
|
15
24
|
setIntersecting(false);
|
|
16
|
-
var startDelayTimeout = null;
|
|
17
25
|
var observer = null;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (visibleTimerRef.current) {
|
|
31
|
-
window.clearTimeout(visibleTimerRef.current);
|
|
32
|
-
}
|
|
33
|
-
// Set up a timer for the minimum visibility duration
|
|
34
|
-
visibleTimerRef.current = window.setTimeout(function () {
|
|
35
|
-
setIntersecting(true);
|
|
36
|
-
if (fireOnce && ref.current && observer) {
|
|
37
|
-
observer.unobserve(ref.current);
|
|
38
|
-
}
|
|
39
|
-
}, minVisibleTime);
|
|
26
|
+
if (!ref.current)
|
|
27
|
+
return;
|
|
28
|
+
observer = new IntersectionObserver(function (_a) {
|
|
29
|
+
var entry = _a[0];
|
|
30
|
+
// If element becomes visible
|
|
31
|
+
if (entry.isIntersecting) {
|
|
32
|
+
// Start tracking visibility time if minVisibleTime is set
|
|
33
|
+
if (minVisibleTime > 0) {
|
|
34
|
+
visibleStartRef.current = Date.now();
|
|
35
|
+
// Clear any existing timer
|
|
36
|
+
if (visibleTimerRef.current) {
|
|
37
|
+
window.clearTimeout(visibleTimerRef.current);
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
// Set up a timer for the minimum visibility duration
|
|
40
|
+
visibleTimerRef.current = window.setTimeout(function () {
|
|
43
41
|
setIntersecting(true);
|
|
44
42
|
if (fireOnce && ref.current && observer) {
|
|
45
43
|
observer.unobserve(ref.current);
|
|
46
44
|
}
|
|
47
|
-
}
|
|
45
|
+
}, minVisibleTime);
|
|
48
46
|
}
|
|
49
47
|
else {
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
// If no minimum time required, update state immediately
|
|
49
|
+
setIntersecting(true);
|
|
50
|
+
if (fireOnce && ref.current && observer) {
|
|
51
|
+
observer.unobserve(ref.current);
|
|
54
52
|
}
|
|
55
|
-
visibleTimerRef.current = null;
|
|
56
|
-
visibleStartRef.current = null;
|
|
57
|
-
setIntersecting(false);
|
|
58
53
|
}
|
|
59
|
-
}, {
|
|
60
|
-
rootMargin: rootMargin,
|
|
61
|
-
threshold: threshold,
|
|
62
|
-
});
|
|
63
|
-
if (ref.current) {
|
|
64
|
-
observer.observe(ref.current);
|
|
65
54
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
else {
|
|
56
|
+
// Element is no longer visible
|
|
57
|
+
if (visibleTimerRef.current) {
|
|
58
|
+
// Clear the timer if element goes out of view before minimum time
|
|
59
|
+
window.clearTimeout(visibleTimerRef.current);
|
|
60
|
+
}
|
|
61
|
+
visibleTimerRef.current = null;
|
|
62
|
+
visibleStartRef.current = null;
|
|
63
|
+
setIntersecting(false);
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
rootMargin: rootMargin,
|
|
67
|
+
threshold: threshold,
|
|
68
|
+
});
|
|
69
|
+
if (ref.current) {
|
|
70
|
+
observer.observe(ref.current);
|
|
73
71
|
}
|
|
74
72
|
return function () {
|
|
75
73
|
setIntersecting(false);
|
|
76
|
-
// Clean up timers
|
|
77
|
-
if (startDelayTimeout) {
|
|
78
|
-
window.clearTimeout(startDelayTimeout);
|
|
79
|
-
}
|
|
80
74
|
if (visibleTimerRef.current) {
|
|
81
75
|
window.clearTimeout(visibleTimerRef.current);
|
|
82
76
|
}
|
|
@@ -85,7 +79,7 @@ var useIntersectionAdvanced = function (ref, options) {
|
|
|
85
79
|
observer.unobserve(ref.current);
|
|
86
80
|
}
|
|
87
81
|
};
|
|
88
|
-
}, [
|
|
82
|
+
}, __spreadArray([ref], ((options === null || options === void 0 ? void 0 : options.additionalEffectKeys) || []), true));
|
|
89
83
|
return isIntersecting;
|
|
90
84
|
};
|
|
91
85
|
exports.useIntersectionAdvanced = useIntersectionAdvanced;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Product } from '@searchspring/snap-store-mobx';
|
|
2
|
+
import type { SearchController, AutocompleteController, RecommendationController } from '@searchspring/snap-controller';
|
|
3
|
+
import { type Ref } from 'preact/hooks';
|
|
4
|
+
interface UseTrackingProps {
|
|
5
|
+
controller: SearchController | AutocompleteController | RecommendationController;
|
|
6
|
+
result: Product;
|
|
7
|
+
}
|
|
8
|
+
export declare function useTracking({ controller, result }: UseTrackingProps): {
|
|
9
|
+
trackingRef: Ref<HTMLElement | null>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=useTracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTracking.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTracking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC;AAGnD,UAAU,gBAAgB;IACzB,UAAU,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;IACjF,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,gBAAgB,GAAG;IAAE,WAAW,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CAAE,CAuC9G"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTracking = void 0;
|
|
4
|
+
var hooks_1 = require("preact/hooks");
|
|
5
|
+
var utilities_1 = require("../utilities");
|
|
6
|
+
function useTracking(_a) {
|
|
7
|
+
var controller = _a.controller, result = _a.result;
|
|
8
|
+
if (!controller) {
|
|
9
|
+
console.warn('Warning: No controller provided to useTracking');
|
|
10
|
+
}
|
|
11
|
+
if (!result) {
|
|
12
|
+
console.warn('Warning: No result provided to useTracking');
|
|
13
|
+
}
|
|
14
|
+
var _b = (0, utilities_1.createImpressionObserver)(), ref = _b.ref, inViewport = _b.inViewport;
|
|
15
|
+
(0, hooks_1.useEffect)(function () {
|
|
16
|
+
if (inViewport) {
|
|
17
|
+
// TODO: add support for disabling tracking events via config like in ResultTracker
|
|
18
|
+
if (result.type === 'product') {
|
|
19
|
+
controller === null || controller === void 0 ? void 0 : controller.track.product.impression(result);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// track banner in future
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, [inViewport]);
|
|
26
|
+
(0, hooks_1.useEffect)(function () {
|
|
27
|
+
var currentRef = ref.current;
|
|
28
|
+
if (currentRef) {
|
|
29
|
+
currentRef.setAttribute('sstracking', 'true');
|
|
30
|
+
var handleClick_1 = function (e) {
|
|
31
|
+
controller === null || controller === void 0 ? void 0 : controller.track.product.click(e, result);
|
|
32
|
+
};
|
|
33
|
+
currentRef.addEventListener('click', handleClick_1);
|
|
34
|
+
return function () {
|
|
35
|
+
currentRef.removeEventListener('click', handleClick_1);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}, [result]);
|
|
39
|
+
return { trackingRef: ref };
|
|
40
|
+
}
|
|
41
|
+
exports.useTracking = useTracking;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentType, FunctionComponent } from 'preact';
|
|
2
|
+
import type { Product } from '@searchspring/snap-store-mobx';
|
|
3
|
+
import type { SearchController, AutocompleteController, RecommendationController } from '@searchspring/snap-controller';
|
|
4
|
+
interface WithTrackingProps {
|
|
5
|
+
controller?: SearchController | AutocompleteController | RecommendationController;
|
|
6
|
+
result?: Product;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export declare function withTracking<Props extends WithTrackingProps>(WrappedComponent: ComponentType<Props>): FunctionComponent<Props>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=withTracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTracking.d.ts","sourceRoot":"","sources":["../../../src/providers/withTracking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIxH,UAAU,iBAAiB;IAC1B,UAAU,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,KAAK,SAAS,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC,4BA+CnG"}
|