@uncinc/uncinc-react-kitchen-sink 2.25.3 → 2.26.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/components/ApiAutocomplete/index.d.ts +4 -3
- package/dist/components/ApiAutocomplete/index.js +31 -9
- package/dist/helpers/apiAutoComplete.js +8 -10
- package/dist/hooks/useScrollDepth.d.ts +25 -0
- package/dist/hooks/useScrollDepth.js +104 -0
- package/dist/hooks/useScrollDepthGTM.d.ts +19 -0
- package/dist/hooks/useScrollDepthGTM.js +33 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ export interface ApiAutocompleteItem {
|
|
|
5
5
|
name: string;
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
}
|
|
8
|
-
export interface ApiAutocompleteProps<TSuggestion = ApiAutocompleteItem> extends InputProps<TSuggestion> {
|
|
8
|
+
export interface ApiAutocompleteProps<TSuggestion = ApiAutocompleteItem> extends Omit<InputProps<TSuggestion>, 'value' | 'onChange'> {
|
|
9
9
|
id: string;
|
|
10
10
|
endpoint: string;
|
|
11
11
|
placeholder?: string;
|
|
@@ -15,7 +15,8 @@ export interface ApiAutocompleteProps<TSuggestion = ApiAutocompleteItem> extends
|
|
|
15
15
|
queryParameter?: string;
|
|
16
16
|
getSuggestionValue: GetSuggestionValue<TSuggestion>;
|
|
17
17
|
requestOptions?: RequestInit;
|
|
18
|
-
|
|
18
|
+
debounce?: number;
|
|
19
|
+
suggestProps?: Omit<AutosuggestPropsBase<TSuggestion>, 'suggestions' | 'onSuggestionsFetchRequested' | 'onSuggestionsClearRequested' | 'getSuggestionValue' | 'renderSuggestion' | 'onSuggestionSelected' | 'inputProps'>;
|
|
19
20
|
}
|
|
20
|
-
declare const ApiAutocomplete: React.
|
|
21
|
+
declare const ApiAutocomplete: <TSuggestion extends object = ApiAutocompleteItem>({ endpoint, placeholder, renderItem, defaultValue, onSelectItem, queryParameter, getSuggestionValue, requestOptions, debounce, suggestProps, ...restProps }: ApiAutocompleteProps<TSuggestion>) => React.JSX.Element;
|
|
21
22
|
export default ApiAutocomplete;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["endpoint", "placeholder", "renderItem", "defaultValue", "onSelectItem", "queryParameter", "getSuggestionValue", "requestOptions", "suggestProps"];
|
|
2
|
+
var _excluded = ["endpoint", "placeholder", "renderItem", "defaultValue", "onSelectItem", "queryParameter", "getSuggestionValue", "requestOptions", "debounce", "suggestProps"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -14,11 +14,10 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
-
import React, { useState } from 'react';
|
|
17
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
18
18
|
import Autosuggest from 'react-autosuggest';
|
|
19
19
|
import getApiAutoCompleteSuggestions from '../../helpers/apiAutoComplete';
|
|
20
20
|
import './style.scss';
|
|
21
|
-
var currentFetch;
|
|
22
21
|
var ApiAutocomplete = function ApiAutocomplete(_ref) {
|
|
23
22
|
var endpoint = _ref.endpoint,
|
|
24
23
|
placeholder = _ref.placeholder,
|
|
@@ -34,6 +33,7 @@ var ApiAutocomplete = function ApiAutocomplete(_ref) {
|
|
|
34
33
|
} : _ref$getSuggestionVal,
|
|
35
34
|
_ref$requestOptions = _ref.requestOptions,
|
|
36
35
|
requestOptions = _ref$requestOptions === void 0 ? {} : _ref$requestOptions,
|
|
36
|
+
debounce = _ref.debounce,
|
|
37
37
|
suggestProps = _ref.suggestProps,
|
|
38
38
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
39
39
|
var _useState = useState(defaultValue || ''),
|
|
@@ -44,8 +44,22 @@ var ApiAutocomplete = function ApiAutocomplete(_ref) {
|
|
|
44
44
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
45
|
results = _useState4[0],
|
|
46
46
|
setResults = _useState4[1];
|
|
47
|
+
var debounceTimeout = useRef();
|
|
48
|
+
var abortController = useRef();
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
return function () {
|
|
51
|
+
return clearTimeout(debounceTimeout.current);
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
47
54
|
var getSuggestionsSetResults = function getSuggestionsSetResults(value) {
|
|
48
|
-
|
|
55
|
+
var _abortController$curr;
|
|
56
|
+
// Supersede the request that is still in flight, so its response cannot
|
|
57
|
+
// arrive after the one we are about to make.
|
|
58
|
+
(_abortController$curr = abortController.current) === null || _abortController$curr === void 0 ? void 0 : _abortController$curr.abort();
|
|
59
|
+
abortController.current = new AbortController();
|
|
60
|
+
getApiAutoCompleteSuggestions(endpoint, queryParameter, value, _objectSpread(_objectSpread({}, requestOptions), {}, {
|
|
61
|
+
signal: abortController.current.signal
|
|
62
|
+
})).then(function (data) {
|
|
49
63
|
if (data) {
|
|
50
64
|
setResults(data);
|
|
51
65
|
}
|
|
@@ -57,9 +71,17 @@ var ApiAutocomplete = function ApiAutocomplete(_ref) {
|
|
|
57
71
|
suggestions: results,
|
|
58
72
|
onSuggestionsFetchRequested: function onSuggestionsFetchRequested(_ref2) {
|
|
59
73
|
var value = _ref2.value;
|
|
60
|
-
|
|
74
|
+
if (!debounce) {
|
|
75
|
+
getSuggestionsSetResults(value);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
clearTimeout(debounceTimeout.current);
|
|
79
|
+
debounceTimeout.current = setTimeout(function () {
|
|
80
|
+
getSuggestionsSetResults(value);
|
|
81
|
+
}, debounce);
|
|
61
82
|
},
|
|
62
83
|
onSuggestionsClearRequested: function onSuggestionsClearRequested() {
|
|
84
|
+
clearTimeout(debounceTimeout.current);
|
|
63
85
|
setResults([]);
|
|
64
86
|
},
|
|
65
87
|
getSuggestionValue: getSuggestionValue,
|
|
@@ -75,10 +97,10 @@ var ApiAutocomplete = function ApiAutocomplete(_ref) {
|
|
|
75
97
|
inputProps: _objectSpread(_objectSpread({}, restProps), {}, {
|
|
76
98
|
placeholder: placeholder,
|
|
77
99
|
value: queryInput,
|
|
78
|
-
onBlur: function onBlur(
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
if (!value ||
|
|
100
|
+
onBlur: function onBlur(event) {
|
|
101
|
+
var _ref5 = event.target,
|
|
102
|
+
value = _ref5.value;
|
|
103
|
+
if (!value || value.length === 0) {
|
|
82
104
|
onSelectItem(null);
|
|
83
105
|
}
|
|
84
106
|
},
|
|
@@ -9,14 +9,13 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
9
9
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
10
|
function abortableFetch(request, opts) {
|
|
11
11
|
var controller = new AbortController();
|
|
12
|
-
var signal = controller.signal;
|
|
13
12
|
return {
|
|
14
13
|
abort: function abort() {
|
|
15
14
|
return controller.abort();
|
|
16
15
|
},
|
|
17
|
-
ready: fetch(request, _objectSpread(
|
|
18
|
-
signal: signal
|
|
19
|
-
}))
|
|
16
|
+
ready: fetch(request, _objectSpread({
|
|
17
|
+
signal: controller.signal
|
|
18
|
+
}, opts))
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
var getApiAutoCompleteSuggestions = /*#__PURE__*/function () {
|
|
@@ -29,10 +28,7 @@ var getApiAutoCompleteSuggestions = /*#__PURE__*/function () {
|
|
|
29
28
|
if (currentFetch) {
|
|
30
29
|
currentFetch.abort();
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
// eslint-disable-next-line no-param-reassign
|
|
34
|
-
currentFetch = abortableFetch(url, requestOptions);
|
|
35
|
-
return _context.abrupt("return", currentFetch.ready.then(function (response) {
|
|
31
|
+
return _context.abrupt("return", abortableFetch(url, requestOptions).ready.then(function (response) {
|
|
36
32
|
return response.json();
|
|
37
33
|
}).then(function (response) {
|
|
38
34
|
return (
|
|
@@ -46,11 +42,13 @@ var getApiAutoCompleteSuggestions = /*#__PURE__*/function () {
|
|
|
46
42
|
})
|
|
47
43
|
);
|
|
48
44
|
}).catch(function (e) {
|
|
49
|
-
|
|
45
|
+
if (e.name !== 'AbortError') {
|
|
46
|
+
console.warn(e);
|
|
47
|
+
}
|
|
50
48
|
return null;
|
|
51
49
|
// Catch the error so the browser does not output errors.
|
|
52
50
|
}));
|
|
53
|
-
case
|
|
51
|
+
case 3:
|
|
54
52
|
case "end":
|
|
55
53
|
return _context.stop();
|
|
56
54
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useScrollDepth
|
|
3
|
+
*
|
|
4
|
+
* Tracks scroll depth and calls `onThreshold` once per threshold per page.
|
|
5
|
+
*
|
|
6
|
+
* Why a custom hook instead of relying on third-party scroll tracking?
|
|
7
|
+
* Most trackers capture `document.scrollHeight` once at initialisation. With
|
|
8
|
+
* client-side rendering the page height changes as content loads asynchronously,
|
|
9
|
+
* so that snapshot is too small and all percentages end up wrong.
|
|
10
|
+
*
|
|
11
|
+
* How this avoids continuous re-renders:
|
|
12
|
+
* - All mutable state lives in `useRef` — nothing in `useState`.
|
|
13
|
+
* - Scroll events are throttled to one check per animation frame via
|
|
14
|
+
* `requestAnimationFrame`; the handler is removed on cleanup.
|
|
15
|
+
* - `ResizeObserver` keeps `documentHeight` in sync as async content renders,
|
|
16
|
+
* without triggering React renders.
|
|
17
|
+
*
|
|
18
|
+
* @param onThreshold - Called once per threshold per page with the percentage value.
|
|
19
|
+
* @param resetKey - Change this value on every navigation (e.g. page title or
|
|
20
|
+
* pathname) to reset the fired thresholds for the new page.
|
|
21
|
+
* @param thresholds - Scroll depth percentages (%) to track.
|
|
22
|
+
* Defaults to [25, 50, 75, 90, 100].
|
|
23
|
+
*/
|
|
24
|
+
declare const useScrollDepth: (onThreshold: (threshold: number) => void, resetKey?: unknown, thresholds?: number[]) => void;
|
|
25
|
+
export default useScrollDepth;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* useScrollDepth
|
|
5
|
+
*
|
|
6
|
+
* Tracks scroll depth and calls `onThreshold` once per threshold per page.
|
|
7
|
+
*
|
|
8
|
+
* Why a custom hook instead of relying on third-party scroll tracking?
|
|
9
|
+
* Most trackers capture `document.scrollHeight` once at initialisation. With
|
|
10
|
+
* client-side rendering the page height changes as content loads asynchronously,
|
|
11
|
+
* so that snapshot is too small and all percentages end up wrong.
|
|
12
|
+
*
|
|
13
|
+
* How this avoids continuous re-renders:
|
|
14
|
+
* - All mutable state lives in `useRef` — nothing in `useState`.
|
|
15
|
+
* - Scroll events are throttled to one check per animation frame via
|
|
16
|
+
* `requestAnimationFrame`; the handler is removed on cleanup.
|
|
17
|
+
* - `ResizeObserver` keeps `documentHeight` in sync as async content renders,
|
|
18
|
+
* without triggering React renders.
|
|
19
|
+
*
|
|
20
|
+
* @param onThreshold - Called once per threshold per page with the percentage value.
|
|
21
|
+
* @param resetKey - Change this value on every navigation (e.g. page title or
|
|
22
|
+
* pathname) to reset the fired thresholds for the new page.
|
|
23
|
+
* @param thresholds - Scroll depth percentages (%) to track.
|
|
24
|
+
* Defaults to [25, 50, 75, 90, 100].
|
|
25
|
+
*/
|
|
26
|
+
var useScrollDepth = function useScrollDepth(onThreshold, resetKey) {
|
|
27
|
+
var thresholds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [25, 50, 75, 90, 100];
|
|
28
|
+
// Tracks which thresholds have already fired for the current page.
|
|
29
|
+
// useRef so mutations never trigger a re-render.
|
|
30
|
+
var firedThresholds = useRef(new Set());
|
|
31
|
+
var rafId = useRef(null);
|
|
32
|
+
var documentHeight = useRef(0);
|
|
33
|
+
// Keep a ref to onThreshold so the effect never needs to re-run when the
|
|
34
|
+
// callback identity changes (e.g. inline arrow in parent), while still
|
|
35
|
+
// always calling the latest version.
|
|
36
|
+
var onThresholdRef = useRef(onThreshold);
|
|
37
|
+
onThresholdRef.current = onThreshold;
|
|
38
|
+
// Keep a ref to thresholds so the effect never needs to re-run when the
|
|
39
|
+
// array identity changes, while still always reading the latest value.
|
|
40
|
+
var thresholdsRef = useRef(thresholds);
|
|
41
|
+
thresholdsRef.current = thresholds;
|
|
42
|
+
|
|
43
|
+
// Reset fired thresholds on every page navigation.
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
firedThresholds.current.clear();
|
|
46
|
+
}, [resetKey]);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
if (typeof window === 'undefined') return undefined;
|
|
49
|
+
var updateDocumentHeight = function updateDocumentHeight() {
|
|
50
|
+
// Use Math.max to handle cross-browser quirks (body vs documentElement).
|
|
51
|
+
documentHeight.current = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
|
52
|
+
};
|
|
53
|
+
var checkScrollDepth = function checkScrollDepth() {
|
|
54
|
+
var scrollTop = window.scrollY;
|
|
55
|
+
var windowHeight = window.innerHeight;
|
|
56
|
+
var docHeight = documentHeight.current;
|
|
57
|
+
|
|
58
|
+
// Skip pages that fit entirely in the viewport — no meaningful depth to track.
|
|
59
|
+
if (docHeight <= windowHeight) return;
|
|
60
|
+
|
|
61
|
+
// scrollDepth = (scrollTop + viewportHeight) / documentHeight × 100
|
|
62
|
+
var scrollPercent = Math.round((scrollTop + windowHeight) / docHeight * 100);
|
|
63
|
+
thresholdsRef.current.forEach(function (threshold) {
|
|
64
|
+
if (scrollPercent >= threshold && !firedThresholds.current.has(threshold)) {
|
|
65
|
+
firedThresholds.current.add(threshold);
|
|
66
|
+
onThresholdRef.current(threshold);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var onScroll = function onScroll() {
|
|
71
|
+
// Gate on an active rAF so we calculate at most once per rendered frame,
|
|
72
|
+
// regardless of how fast the browser fires scroll events.
|
|
73
|
+
if (rafId.current !== null) return;
|
|
74
|
+
rafId.current = requestAnimationFrame(function () {
|
|
75
|
+
checkScrollDepth();
|
|
76
|
+
rafId.current = null;
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// ResizeObserver re-measures the document whenever content loads in,
|
|
81
|
+
// keeping the height accurate as async content renders.
|
|
82
|
+
var resizeObserver = new ResizeObserver(function () {
|
|
83
|
+
updateDocumentHeight();
|
|
84
|
+
// Re-evaluate depth after a layout change; lazily-loaded content may
|
|
85
|
+
// have already scrolled us past a threshold.
|
|
86
|
+
checkScrollDepth();
|
|
87
|
+
});
|
|
88
|
+
updateDocumentHeight();
|
|
89
|
+
resizeObserver.observe(document.body);
|
|
90
|
+
window.addEventListener('scroll', onScroll, {
|
|
91
|
+
passive: true
|
|
92
|
+
});
|
|
93
|
+
return function () {
|
|
94
|
+
window.removeEventListener('scroll', onScroll);
|
|
95
|
+
resizeObserver.disconnect();
|
|
96
|
+
if (rafId.current !== null) {
|
|
97
|
+
cancelAnimationFrame(rafId.current);
|
|
98
|
+
rafId.current = null;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}, []); // Listeners are set up once; threshold resets are handled by the resetKey effect.
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export default useScrollDepth;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useScrollDepthGTM
|
|
3
|
+
*
|
|
4
|
+
* Convenience hook that combines `useScrollDepth` with the GTM data layer.
|
|
5
|
+
* Pushes a `scroll_depth` event at each threshold — once per page — and
|
|
6
|
+
* resets on navigation when `resetKey` changes.
|
|
7
|
+
*
|
|
8
|
+
* Use this hook when you want GTM scroll-depth tracking out of the box.
|
|
9
|
+
* Use the underlying `useScrollDepth` directly if you need a different
|
|
10
|
+
* analytics integration or want full control over the callback.
|
|
11
|
+
*
|
|
12
|
+
* @param resetKey - Change on every navigation (e.g. pathname or page title)
|
|
13
|
+
* to reset the fired thresholds for the new page.
|
|
14
|
+
* @param thresholds - Scroll depth percentages (%) to track. Defaults to
|
|
15
|
+
* [25, 50, 75, 90, 100], mirroring GTM's built-in Scroll
|
|
16
|
+
* Depth trigger.
|
|
17
|
+
*/
|
|
18
|
+
declare const useScrollDepthGTM: (resetKey?: unknown, thresholds?: number[]) => void;
|
|
19
|
+
export default useScrollDepthGTM;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// gtm.js uses dynamic property assignment that TypeScript cannot infer from
|
|
2
|
+
// the source. The generated dist/helpers/gtm.d.ts contains the correct types,
|
|
3
|
+
// but during tsc compilation we cast to avoid the false-positive TS2339 error.
|
|
4
|
+
import gtmHelper from '../helpers/gtm';
|
|
5
|
+
import useScrollDepth from './useScrollDepth';
|
|
6
|
+
var gtm = gtmHelper;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* useScrollDepthGTM
|
|
10
|
+
*
|
|
11
|
+
* Convenience hook that combines `useScrollDepth` with the GTM data layer.
|
|
12
|
+
* Pushes a `scroll_depth` event at each threshold — once per page — and
|
|
13
|
+
* resets on navigation when `resetKey` changes.
|
|
14
|
+
*
|
|
15
|
+
* Use this hook when you want GTM scroll-depth tracking out of the box.
|
|
16
|
+
* Use the underlying `useScrollDepth` directly if you need a different
|
|
17
|
+
* analytics integration or want full control over the callback.
|
|
18
|
+
*
|
|
19
|
+
* @param resetKey - Change on every navigation (e.g. pathname or page title)
|
|
20
|
+
* to reset the fired thresholds for the new page.
|
|
21
|
+
* @param thresholds - Scroll depth percentages (%) to track. Defaults to
|
|
22
|
+
* [25, 50, 75, 90, 100], mirroring GTM's built-in Scroll
|
|
23
|
+
* Depth trigger.
|
|
24
|
+
*/
|
|
25
|
+
var useScrollDepthGTM = function useScrollDepthGTM(resetKey, thresholds) {
|
|
26
|
+
useScrollDepth(function (threshold) {
|
|
27
|
+
gtm.push({
|
|
28
|
+
event: 'scroll_depth',
|
|
29
|
+
percent_scrolled: threshold
|
|
30
|
+
});
|
|
31
|
+
}, resetKey, thresholds);
|
|
32
|
+
};
|
|
33
|
+
export default useScrollDepthGTM;
|
package/dist/index.d.ts
CHANGED
|
@@ -77,6 +77,8 @@ export { default as useDialogHelpers } from "./hooks/useDialogHelpers";
|
|
|
77
77
|
export { default as useEscape } from "./hooks/useEscape";
|
|
78
78
|
export { default as useOnScreen } from "./hooks/useOnScreen";
|
|
79
79
|
export { default as usePrevious } from "./hooks/usePrevious";
|
|
80
|
+
export { default as useScrollDepth } from "./hooks/useScrollDepth";
|
|
81
|
+
export { default as useScrollDepthGTM } from "./hooks/useScrollDepthGTM";
|
|
80
82
|
export { default as useScrollPosition } from "./hooks/useScrollPosition";
|
|
81
83
|
export { default as useWindowDimensions } from "./hooks/useWindowDimensions";
|
|
82
84
|
export { default as useTrapFocus } from "./hooks/useTrapFocus";
|
package/dist/index.js
CHANGED
|
@@ -90,6 +90,8 @@ export { default as useDialogHelpers } from './hooks/useDialogHelpers';
|
|
|
90
90
|
export { default as useEscape } from './hooks/useEscape';
|
|
91
91
|
export { default as useOnScreen } from './hooks/useOnScreen';
|
|
92
92
|
export { default as usePrevious } from './hooks/usePrevious';
|
|
93
|
+
export { default as useScrollDepth } from './hooks/useScrollDepth';
|
|
94
|
+
export { default as useScrollDepthGTM } from './hooks/useScrollDepthGTM';
|
|
93
95
|
export { default as useScrollPosition } from './hooks/useScrollPosition';
|
|
94
96
|
export { default as useWindowDimensions } from './hooks/useWindowDimensions';
|
|
95
97
|
export { default as useTrapFocus } from './hooks/useTrapFocus';
|