@chayns-components/core 5.0.0-beta.1045 → 5.0.0-beta.1047
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.
|
@@ -8,6 +8,16 @@ var _resizeObserver = _interopRequireDefault(require("@react-hook/resize-observe
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect;
|
|
11
|
+
class ResizeObserverPolyFill {
|
|
12
|
+
// eslint-disable-next-line class-methods-use-this
|
|
13
|
+
observe = () => {};
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line class-methods-use-this
|
|
16
|
+
unobserve = () => {};
|
|
17
|
+
}
|
|
18
|
+
const options = typeof window === 'undefined' ? {
|
|
19
|
+
polyfill: ResizeObserverPolyFill
|
|
20
|
+
} : undefined;
|
|
11
21
|
const useElementSize = (ref, {
|
|
12
22
|
shouldUseChildElement = false
|
|
13
23
|
} = {}) => {
|
|
@@ -21,7 +31,9 @@ const useElementSize = (ref, {
|
|
|
21
31
|
setSize(undefined);
|
|
22
32
|
}
|
|
23
33
|
}, [element]);
|
|
24
|
-
|
|
34
|
+
|
|
35
|
+
// TODO: Replace with ssr-compatible implementation
|
|
36
|
+
(0, _resizeObserver.default)(element, entry => setSize(entry.contentRect), options);
|
|
25
37
|
return size;
|
|
26
38
|
};
|
|
27
39
|
exports.useElementSize = useElementSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useElementSize.js","names":["_resizeObserver","_interopRequireDefault","require","_react","e","__esModule","default","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","useElementSize","ref","shouldUseChildElement","_ref$current","size","setSize","useState","element","current","firstElementChild","getBoundingClientRect","
|
|
1
|
+
{"version":3,"file":"useElementSize.js","names":["_resizeObserver","_interopRequireDefault","require","_react","e","__esModule","default","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","ResizeObserverPolyFill","observe","unobserve","options","polyfill","undefined","useElementSize","ref","shouldUseChildElement","_ref$current","size","setSize","useState","element","current","firstElementChild","getBoundingClientRect","useResizeObserver","entry","contentRect","exports"],"sources":["../../../src/hooks/useElementSize.ts"],"sourcesContent":["import useResizeObserver from '@react-hook/resize-observer';\nimport { MutableRefObject, useEffect, useLayoutEffect, useState } from 'react';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nclass ResizeObserverPolyFill {\n // eslint-disable-next-line class-methods-use-this\n observe = () => {};\n\n // eslint-disable-next-line class-methods-use-this\n unobserve = () => {};\n}\n\nconst options = typeof window === 'undefined' ? { polyfill: ResizeObserverPolyFill } : undefined;\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n}\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n const element = ((shouldUseChildElement ? ref.current?.firstElementChild : ref.current) ??\n null) as HTMLDivElement | HTMLLabelElement | null;\n\n useIsomorphicLayoutEffect(() => {\n if (element) {\n setSize(element.getBoundingClientRect());\n } else {\n setSize(undefined);\n }\n }, [element]);\n\n // TODO: Replace with ssr-compatible implementation\n useResizeObserver(element, (entry) => setSize(entry.contentRect), options);\n\n return size;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA+E,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/E,MAAMG,yBAAyB,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGC,sBAAe,GAAGC,gBAAS;AAE7F,MAAMC,sBAAsB,CAAC;EACzB;EACAC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;;EAElB;EACAC,SAAS,GAAGA,CAAA,KAAM,CAAC,CAAC;AACxB;AAEA,MAAMC,OAAO,GAAG,OAAON,MAAM,KAAK,WAAW,GAAG;EAAEO,QAAQ,EAAEJ;AAAuB,CAAC,GAAGK,SAAS;AAMzF,MAAMC,cAAc,GAAGA,CAC1BC,GAA+D,EAC/D;EAAEC,qBAAqB,GAAG;AAA6B,CAAC,GAAG,CAAC,CAAC,KAC/B;EAAA,IAAAC,YAAA;EAC9B,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAG,IAAAC,eAAQ,EAAkB,CAAC;EAEnD,MAAMC,OAAO,GAAI,CAACL,qBAAqB,IAAAC,YAAA,GAAGF,GAAG,CAACO,OAAO,cAAAL,YAAA,uBAAXA,YAAA,CAAaM,iBAAiB,GAAGR,GAAG,CAACO,OAAO,KAClF,IAAiD;EAErDlB,yBAAyB,CAAC,MAAM;IAC5B,IAAIiB,OAAO,EAAE;MACTF,OAAO,CAACE,OAAO,CAACG,qBAAqB,CAAC,CAAC,CAAC;IAC5C,CAAC,MAAM;MACHL,OAAO,CAACN,SAAS,CAAC;IACtB;EACJ,CAAC,EAAE,CAACQ,OAAO,CAAC,CAAC;;EAEb;EACA,IAAAI,uBAAiB,EAACJ,OAAO,EAAGK,KAAK,IAAKP,OAAO,CAACO,KAAK,CAACC,WAAW,CAAC,EAAEhB,OAAO,CAAC;EAE1E,OAAOO,IAAI;AACf,CAAC;AAACU,OAAA,CAAAd,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import useResizeObserver from '@react-hook/resize-observer';
|
|
2
2
|
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
3
3
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
4
|
+
class ResizeObserverPolyFill {
|
|
5
|
+
// eslint-disable-next-line class-methods-use-this
|
|
6
|
+
observe = () => {};
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line class-methods-use-this
|
|
9
|
+
unobserve = () => {};
|
|
10
|
+
}
|
|
11
|
+
const options = typeof window === 'undefined' ? {
|
|
12
|
+
polyfill: ResizeObserverPolyFill
|
|
13
|
+
} : undefined;
|
|
4
14
|
export const useElementSize = function (ref) {
|
|
5
15
|
let {
|
|
6
16
|
shouldUseChildElement = false
|
|
@@ -14,7 +24,9 @@ export const useElementSize = function (ref) {
|
|
|
14
24
|
setSize(undefined);
|
|
15
25
|
}
|
|
16
26
|
}, [element]);
|
|
17
|
-
|
|
27
|
+
|
|
28
|
+
// TODO: Replace with ssr-compatible implementation
|
|
29
|
+
useResizeObserver(element, entry => setSize(entry.contentRect), options);
|
|
18
30
|
return size;
|
|
19
31
|
};
|
|
20
32
|
//# sourceMappingURL=useElementSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useElementSize.js","names":["useResizeObserver","useEffect","useLayoutEffect","useState","useIsomorphicLayoutEffect","window","useElementSize","ref","shouldUseChildElement","arguments","length","
|
|
1
|
+
{"version":3,"file":"useElementSize.js","names":["useResizeObserver","useEffect","useLayoutEffect","useState","useIsomorphicLayoutEffect","window","ResizeObserverPolyFill","observe","unobserve","options","polyfill","undefined","useElementSize","ref","shouldUseChildElement","arguments","length","size","setSize","element","current","firstElementChild","getBoundingClientRect","entry","contentRect"],"sources":["../../../src/hooks/useElementSize.ts"],"sourcesContent":["import useResizeObserver from '@react-hook/resize-observer';\nimport { MutableRefObject, useEffect, useLayoutEffect, useState } from 'react';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nclass ResizeObserverPolyFill {\n // eslint-disable-next-line class-methods-use-this\n observe = () => {};\n\n // eslint-disable-next-line class-methods-use-this\n unobserve = () => {};\n}\n\nconst options = typeof window === 'undefined' ? { polyfill: ResizeObserverPolyFill } : undefined;\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n}\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n const element = ((shouldUseChildElement ? ref.current?.firstElementChild : ref.current) ??\n null) as HTMLDivElement | HTMLLabelElement | null;\n\n useIsomorphicLayoutEffect(() => {\n if (element) {\n setSize(element.getBoundingClientRect());\n } else {\n setSize(undefined);\n }\n }, [element]);\n\n // TODO: Replace with ssr-compatible implementation\n useResizeObserver(element, (entry) => setSize(entry.contentRect), options);\n\n return size;\n};\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,6BAA6B;AAC3D,SAA2BC,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAE9E,MAAMC,yBAAyB,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGH,eAAe,GAAGD,SAAS;AAE7F,MAAMK,sBAAsB,CAAC;EACzB;EACAC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;;EAElB;EACAC,SAAS,GAAGA,CAAA,KAAM,CAAC,CAAC;AACxB;AAEA,MAAMC,OAAO,GAAG,OAAOJ,MAAM,KAAK,WAAW,GAAG;EAAEK,QAAQ,EAAEJ;AAAuB,CAAC,GAAGK,SAAS;AAMhG,OAAO,MAAMC,cAAc,GAAG,SAAAA,CAC1BC,GAA+D,EAEjC;EAAA,IAD9B;IAAEC,qBAAqB,GAAG;EAA6B,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAJ,SAAA,GAAAI,SAAA,MAAG,CAAC,CAAC;EAE7D,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAGf,QAAQ,CAAkB,CAAC;EAEnD,MAAMgB,OAAO,GAAI,CAACL,qBAAqB,GAAGD,GAAG,CAACO,OAAO,EAAEC,iBAAiB,GAAGR,GAAG,CAACO,OAAO,KAClF,IAAiD;EAErDhB,yBAAyB,CAAC,MAAM;IAC5B,IAAIe,OAAO,EAAE;MACTD,OAAO,CAACC,OAAO,CAACG,qBAAqB,CAAC,CAAC,CAAC;IAC5C,CAAC,MAAM;MACHJ,OAAO,CAACP,SAAS,CAAC;IACtB;EACJ,CAAC,EAAE,CAACQ,OAAO,CAAC,CAAC;;EAEb;EACAnB,iBAAiB,CAACmB,OAAO,EAAGI,KAAK,IAAKL,OAAO,CAACK,KAAK,CAACC,WAAW,CAAC,EAAEf,OAAO,CAAC;EAE1E,OAAOQ,IAAI;AACf,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.1047",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "71dc69c96016c401d360e1ff527fc02329c85409"
|
|
92
92
|
}
|