@tellescope/react-components 1.187.0 → 1.188.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/CMS/ContentViewer.d.ts +19 -0
- package/lib/cjs/CMS/ContentViewer.d.ts.map +1 -1
- package/lib/cjs/CMS/ContentViewer.js +57 -1
- package/lib/cjs/CMS/ContentViewer.js.map +1 -1
- package/lib/cjs/state.js +1 -1
- package/lib/esm/CMS/ContentViewer.d.ts +19 -0
- package/lib/esm/CMS/ContentViewer.d.ts.map +1 -1
- package/lib/esm/CMS/ContentViewer.js +55 -0
- package/lib/esm/CMS/ContentViewer.js.map +1 -1
- package/lib/esm/CMS/components.d.ts +1 -0
- package/lib/esm/CMS/components.d.ts.map +1 -1
- package/lib/esm/Forms/forms.d.ts +3 -3
- package/lib/esm/Forms/inputs.d.ts +1 -1
- package/lib/esm/controls.d.ts +2 -2
- package/lib/esm/inputs.d.ts +1 -1
- package/lib/esm/layout.d.ts +1 -1
- package/lib/esm/state.d.ts +286 -286
- package/lib/esm/state.js +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/CMS/ContentViewer.tsx +84 -0
- package/src/state.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.188.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"@reduxjs/toolkit": "^1.6.2",
|
|
48
48
|
"@stripe/react-stripe-js": "^2.9.0",
|
|
49
49
|
"@stripe/stripe-js": "^1.52.1",
|
|
50
|
-
"@tellescope/constants": "^1.
|
|
51
|
-
"@tellescope/sdk": "^1.
|
|
52
|
-
"@tellescope/types-client": "^1.
|
|
53
|
-
"@tellescope/types-models": "^1.
|
|
54
|
-
"@tellescope/types-utilities": "^1.
|
|
55
|
-
"@tellescope/utilities": "^1.
|
|
56
|
-
"@tellescope/validation": "^1.
|
|
50
|
+
"@tellescope/constants": "^1.188.0",
|
|
51
|
+
"@tellescope/sdk": "^1.188.0",
|
|
52
|
+
"@tellescope/types-client": "^1.188.0",
|
|
53
|
+
"@tellescope/types-models": "^1.188.0",
|
|
54
|
+
"@tellescope/types-utilities": "^1.188.0",
|
|
55
|
+
"@tellescope/utilities": "^1.188.0",
|
|
56
|
+
"@tellescope/validation": "^1.188.0",
|
|
57
57
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
58
58
|
"@typescript-eslint/parser": "^4.33.0",
|
|
59
59
|
"css-to-react-native": "^3.0.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
85
85
|
"react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "53980cf431ca6a0961fe95d3e6ec24115e31c136",
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
}
|
|
@@ -6,6 +6,90 @@ import { PDFBlockUI } from "./components"
|
|
|
6
6
|
import { css } from "@emotion/css"
|
|
7
7
|
import { useManagedContentRecords } from "../state"
|
|
8
8
|
|
|
9
|
+
interface UseContentHeightOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Debounce time in milliseconds for resize observation
|
|
12
|
+
* @default 100
|
|
13
|
+
*/
|
|
14
|
+
debounceTime?: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* CSS selector for the element to observe
|
|
18
|
+
* @default 'body'
|
|
19
|
+
*/
|
|
20
|
+
targetSelector?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A hook that tracks the height of page content and updates when content changes.
|
|
25
|
+
* @param options - Configuration options
|
|
26
|
+
* @returns Current content height in pixels
|
|
27
|
+
*/
|
|
28
|
+
export const usePageContentHeight = (options: UseContentHeightOptions = {}): number => {
|
|
29
|
+
const {
|
|
30
|
+
debounceTime = 100,
|
|
31
|
+
targetSelector = 'body'
|
|
32
|
+
} = options;
|
|
33
|
+
|
|
34
|
+
const [contentHeight, setContentHeight] = useState<number>(0);
|
|
35
|
+
const debounceTimerRef = useRef<NodeJS.Timeout | null>(null);
|
|
36
|
+
const observerRef = useRef<MutationObserver | null>(null);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
// Function to measure content height
|
|
40
|
+
const updateContentHeight = (): void => {
|
|
41
|
+
const targetElement = document.querySelector(targetSelector);
|
|
42
|
+
|
|
43
|
+
if (targetElement) {
|
|
44
|
+
// Use scrollHeight to get the total height including overflow content
|
|
45
|
+
const height = targetElement.scrollHeight;
|
|
46
|
+
setContentHeight(height);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Debounced update function
|
|
51
|
+
const debouncedUpdate = (): void => {
|
|
52
|
+
if (debounceTimerRef.current) {
|
|
53
|
+
clearTimeout(debounceTimerRef.current);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
debounceTimerRef.current = setTimeout(() => {
|
|
57
|
+
updateContentHeight();
|
|
58
|
+
}, debounceTime);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Initial measurement
|
|
62
|
+
updateContentHeight();
|
|
63
|
+
|
|
64
|
+
// Set up mutation observer to detect content changes
|
|
65
|
+
observerRef.current = new MutationObserver(debouncedUpdate);
|
|
66
|
+
|
|
67
|
+
const targetElement = document.querySelector(targetSelector);
|
|
68
|
+
if (targetElement) {
|
|
69
|
+
observerRef.current.observe(targetElement, {
|
|
70
|
+
childList: true, // Watch for changes in direct children
|
|
71
|
+
subtree: true, // Watch for changes in the entire subtree
|
|
72
|
+
characterData: true, // Watch for changes in text content
|
|
73
|
+
attributes: true // Watch for changes in attributes (may affect layout)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Cleanup
|
|
78
|
+
return () => {
|
|
79
|
+
if (observerRef.current) {
|
|
80
|
+
observerRef.current.disconnect();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (debounceTimerRef.current) {
|
|
84
|
+
clearTimeout(debounceTimerRef.current);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, [debounceTime, targetSelector]);
|
|
88
|
+
|
|
89
|
+
return contentHeight;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
9
93
|
export const usePageHeight = () => {
|
|
10
94
|
const [height, setHeight] = useState(window.innerHeight)
|
|
11
95
|
|
package/src/state.tsx
CHANGED
|
@@ -597,7 +597,7 @@ export const useDataSync____internal = () => {
|
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
// ensure we don't miss updates due to latency
|
|
600
|
-
const from = new Date(lastFetch.current.getTime() -
|
|
600
|
+
const from = new Date(lastFetch.current.getTime() - 3000) // large leeway could result in same data being fetched twice, but helps ensure nothing is dropped
|
|
601
601
|
lastFetch.current = new Date() // update before syncing, not after it returns
|
|
602
602
|
|
|
603
603
|
session
|