@elliemae/ds-utilities 3.11.0-next.2 → 3.11.0-next.3
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.
|
@@ -39,9 +39,12 @@ const useOnElementResize = (targetRef) => {
|
|
|
39
39
|
setHeight(targetRef.current?.offsetHeight ?? 0);
|
|
40
40
|
}
|
|
41
41
|
observer.current = new ResizeObserver(outputsize);
|
|
42
|
-
|
|
42
|
+
const el = targetRef.current;
|
|
43
|
+
if (el)
|
|
44
|
+
observer.current.observe(el);
|
|
43
45
|
return () => {
|
|
44
|
-
|
|
46
|
+
if (el)
|
|
47
|
+
observer.current?.disconnect();
|
|
45
48
|
};
|
|
46
49
|
}, [targetRef]);
|
|
47
50
|
return (0, import_react.useMemo)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useOnElementResize.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useState, useEffect, useRef, useMemo } from 'react';\n\n// Custom hook to track dimension of a component\n// Taken and modified from https://stackoverflow.com/a/60218754\nexport const useOnElementResize = <T extends HTMLElement>(\n targetRef: React.RefObject<T>,\n): Record<'width' | 'height', number> => {\n const [width, setWidth] = useState(targetRef.current?.offsetWidth ?? 0);\n const [height, setHeight] = useState(targetRef.current?.offsetHeight ?? 0);\n const observer = useRef<ResizeObserver>();\n\n useEffect(() => {\n function outputsize() {\n setWidth(targetRef.current?.offsetWidth ?? 0);\n setHeight(targetRef.current?.offsetHeight ?? 0);\n }\n\n observer.current = new ResizeObserver(outputsize);\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4D;AAIrD,MAAM,qBAAqB,CAChC,cACuC;AACvC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,UAAU,SAAS,eAAe,CAAC;AACtE,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,UAAU,SAAS,gBAAgB,CAAC;AACzE,QAAM,eAAW,qBAAuB;AAExC,8BAAU,MAAM;AACd,aAAS,aAAa;AACpB,eAAS,UAAU,SAAS,eAAe,CAAC;AAC5C,gBAAU,UAAU,SAAS,gBAAgB,CAAC;AAAA,IAChD;AAEA,aAAS,UAAU,IAAI,eAAe,UAAU;AAChD,
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect, useRef, useMemo } from 'react';\n\n// Custom hook to track dimension of a component\n// Taken and modified from https://stackoverflow.com/a/60218754\nexport const useOnElementResize = <T extends HTMLElement>(\n targetRef: React.RefObject<T>,\n): Record<'width' | 'height', number> => {\n const [width, setWidth] = useState(targetRef.current?.offsetWidth ?? 0);\n const [height, setHeight] = useState(targetRef.current?.offsetHeight ?? 0);\n const observer = useRef<ResizeObserver>();\n\n useEffect(() => {\n function outputsize() {\n setWidth(targetRef.current?.offsetWidth ?? 0);\n setHeight(targetRef.current?.offsetHeight ?? 0);\n }\n\n observer.current = new ResizeObserver(outputsize);\n const el = targetRef.current as Element | null;\n if (el) observer.current.observe(el);\n\n return () => {\n if (el) observer.current?.disconnect();\n };\n }, [targetRef]);\n\n return useMemo(\n () => ({\n width,\n height,\n }),\n [width, height],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4D;AAIrD,MAAM,qBAAqB,CAChC,cACuC;AACvC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,UAAU,SAAS,eAAe,CAAC;AACtE,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,UAAU,SAAS,gBAAgB,CAAC;AACzE,QAAM,eAAW,qBAAuB;AAExC,8BAAU,MAAM;AACd,aAAS,aAAa;AACpB,eAAS,UAAU,SAAS,eAAe,CAAC;AAC5C,gBAAU,UAAU,SAAS,gBAAgB,CAAC;AAAA,IAChD;AAEA,aAAS,UAAU,IAAI,eAAe,UAAU;AAChD,UAAM,KAAK,UAAU;AACrB,QAAI;AAAI,eAAS,QAAQ,QAAQ,EAAE;AAEnC,WAAO,MAAM;AACX,UAAI;AAAI,iBAAS,SAAS,WAAW;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,OAAO,MAAM;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,9 +10,12 @@ const useOnElementResize = (targetRef) => {
|
|
|
10
10
|
setHeight(targetRef.current?.offsetHeight ?? 0);
|
|
11
11
|
}
|
|
12
12
|
observer.current = new ResizeObserver(outputsize);
|
|
13
|
-
|
|
13
|
+
const el = targetRef.current;
|
|
14
|
+
if (el)
|
|
15
|
+
observer.current.observe(el);
|
|
14
16
|
return () => {
|
|
15
|
-
|
|
17
|
+
if (el)
|
|
18
|
+
observer.current?.disconnect();
|
|
16
19
|
};
|
|
17
20
|
}, [targetRef]);
|
|
18
21
|
return useMemo(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useOnElementResize.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect, useRef, useMemo } from 'react';\n\n// Custom hook to track dimension of a component\n// Taken and modified from https://stackoverflow.com/a/60218754\nexport const useOnElementResize = <T extends HTMLElement>(\n targetRef: React.RefObject<T>,\n): Record<'width' | 'height', number> => {\n const [width, setWidth] = useState(targetRef.current?.offsetWidth ?? 0);\n const [height, setHeight] = useState(targetRef.current?.offsetHeight ?? 0);\n const observer = useRef<ResizeObserver>();\n\n useEffect(() => {\n function outputsize() {\n setWidth(targetRef.current?.offsetWidth ?? 0);\n setHeight(targetRef.current?.offsetHeight ?? 0);\n }\n\n observer.current = new ResizeObserver(outputsize);\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,UAAU,WAAW,QAAQ,eAAe;AAIrD,MAAM,qBAAqB,CAChC,cACuC;AACvC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,UAAU,SAAS,eAAe,CAAC;AACtE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,UAAU,SAAS,gBAAgB,CAAC;AACzE,QAAM,WAAW,OAAuB;AAExC,YAAU,MAAM;AACd,aAAS,aAAa;AACpB,eAAS,UAAU,SAAS,eAAe,CAAC;AAC5C,gBAAU,UAAU,SAAS,gBAAgB,CAAC;AAAA,IAChD;AAEA,aAAS,UAAU,IAAI,eAAe,UAAU;AAChD,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect, useRef, useMemo } from 'react';\n\n// Custom hook to track dimension of a component\n// Taken and modified from https://stackoverflow.com/a/60218754\nexport const useOnElementResize = <T extends HTMLElement>(\n targetRef: React.RefObject<T>,\n): Record<'width' | 'height', number> => {\n const [width, setWidth] = useState(targetRef.current?.offsetWidth ?? 0);\n const [height, setHeight] = useState(targetRef.current?.offsetHeight ?? 0);\n const observer = useRef<ResizeObserver>();\n\n useEffect(() => {\n function outputsize() {\n setWidth(targetRef.current?.offsetWidth ?? 0);\n setHeight(targetRef.current?.offsetHeight ?? 0);\n }\n\n observer.current = new ResizeObserver(outputsize);\n const el = targetRef.current as Element | null;\n if (el) observer.current.observe(el);\n\n return () => {\n if (el) observer.current?.disconnect();\n };\n }, [targetRef]);\n\n return useMemo(\n () => ({\n width,\n height,\n }),\n [width, height],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,UAAU,WAAW,QAAQ,eAAe;AAIrD,MAAM,qBAAqB,CAChC,cACuC;AACvC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,UAAU,SAAS,eAAe,CAAC;AACtE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,UAAU,SAAS,gBAAgB,CAAC;AACzE,QAAM,WAAW,OAAuB;AAExC,YAAU,MAAM;AACd,aAAS,aAAa;AACpB,eAAS,UAAU,SAAS,eAAe,CAAC;AAC5C,gBAAU,UAAU,SAAS,gBAAgB,CAAC;AAAA,IAChD;AAEA,aAAS,UAAU,IAAI,eAAe,UAAU;AAChD,UAAM,KAAK,UAAU;AACrB,QAAI;AAAI,eAAS,QAAQ,QAAQ,EAAE;AAEnC,WAAO,MAAM;AACX,UAAI;AAAI,iBAAS,SAAS,WAAW;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,OAAO,MAAM;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-utilities",
|
|
3
|
-
"version": "3.11.0-next.
|
|
3
|
+
"version": "3.11.0-next.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Utilities",
|
|
6
6
|
"files": [
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"typeSafety": true
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
154
|
-
"@elliemae/ds-system": "3.11.0-next.
|
|
154
|
+
"@elliemae/ds-system": "3.11.0-next.3",
|
|
155
155
|
"@elliemae/pui-theme": "~2.6.0",
|
|
156
156
|
"fast-deep-equal": "~3.1.3",
|
|
157
157
|
"hotkeys-js": "~3.9.3",
|