@pega/cosmos-react-core 3.0.0-dev.10.0 → 3.0.0-dev.10.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.
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoResize.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAI3D;;;;;;;GAOG;AACH,QAAA,MAAM,aAAa,kJAGmB,IAAI,CAsCzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"useAutoResize.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAI3D;;;;;;;GAOG;AACH,QAAA,MAAM,aAAa,kJAGmB,IAAI,CAqCzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -14,10 +14,11 @@ const useAutoResize = (maxHeight, minHeightProp) => {
14
14
  const autoResize = () => {
15
15
  let scrollHeightElement = element.current;
16
16
  let iframe;
17
- if (element.current?.tagName === 'IFRAME')
17
+ if (element.current && element.current instanceof HTMLIFrameElement) {
18
18
  iframe = element.current;
19
- scrollHeightElement =
20
- element.current.contentDocument?.querySelector('body') ?? element.current;
19
+ scrollHeightElement =
20
+ element.current.contentDocument?.querySelector('body') ?? element.current;
21
+ }
21
22
  if (element.current) {
22
23
  let newMinHeight = minHeight;
23
24
  if (!minHeight) {
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoResize.js","sourceRoot":"","sources":["../../src/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAoB,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,aAAa,GAAG,CACpB,SAAkB,EAClB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G,mBAAmB,CAAC,YAAY,IAAI,CAAC;gBAC3E,IAAI,MAAM;oBAAE,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,mBAAmB,CAAC,YAAY,IAAI,CAAC;aAC3E;SACF;IACH,CAAC,CAAC;IAEF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAEtD,OAAO,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { useRef, useState, MutableRefObject } from 'react';\n\nimport { debounce } from '../utils';\n\n/**\n * @example const [ref, resizeFunction] = useAutoResize();\n * maxHeight should be provided in pixels without units\n * minHeight should be provided in pixels without units\n * @returns * ref:: A reference for the element that the resize functionality should be applied to. [React RefObject](https://reactjs.org/docs/refs-and-the-dom.html)\n * * resizeFunction:: The function to call to automatically resize the element.\n * element refers to auto resizable element\n */\nconst useAutoResize = <T extends HTMLElement = HTMLElement>(\n maxHeight?: number,\n minHeightProp?: number\n): [MutableRefObject<T | null>, () => void] => {\n const element = useRef<T | null>(null);\n const [minHeight, setMinHeight] = useState(minHeightProp || 0);\n\n const autoResize = () => {\n let scrollHeightElement: HTMLElement = element.current as HTMLElement;\n let iframe: HTMLIFrameElement | undefined;\n if (element.current?.tagName === 'IFRAME')\n iframe = element.current as HTMLElement as HTMLIFrameElement;\n scrollHeightElement =\n (element.current as HTMLElement as HTMLIFrameElement).contentDocument?.querySelector(\n 'body'\n ) ?? (element.current as HTMLElement);\n if (element.current) {\n let newMinHeight = minHeight;\n if (!minHeight) {\n newMinHeight = scrollHeightElement.scrollHeight;\n setMinHeight(newMinHeight);\n }\n // Reset the heights to the base height so there is an overflow / or none to calculate the new height\n scrollHeightElement.style.height = `${newMinHeight}px`;\n\n if (maxHeight) {\n scrollHeightElement.style.overflowY =\n scrollHeightElement.scrollHeight > maxHeight ? 'auto' : 'hidden';\n const height = `${Math.min(scrollHeightElement.scrollHeight, maxHeight)}px`;\n scrollHeightElement.style.height = height;\n if (iframe) iframe.style.height = height;\n } else {\n scrollHeightElement.style.height = `${scrollHeightElement.scrollHeight}px`;\n if (iframe) iframe.style.height = `${scrollHeightElement.scrollHeight}px`;\n }\n }\n };\n\n const debouncedAutoResize = debounce(autoResize, 100);\n\n return [element, debouncedAutoResize];\n};\n\nexport default useAutoResize;\n"]}
1
+ {"version":3,"file":"useAutoResize.js","sourceRoot":"","sources":["../../src/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAoB,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,aAAa,GAAG,CACpB,SAAkB,EAClB,aAAsB,EACoB,EAAE;IAC5C,MAAM,OAAO,GAAG,MAAM,CAAW,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;IAE/D,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,IAAI,mBAAmB,GAAgB,OAAO,CAAC,OAAsB,CAAC;QACtE,IAAI,MAAqC,CAAC;QAC1C,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,YAAY,iBAAiB,EAAE;YACnE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YACzB,mBAAmB;gBACjB,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC;SAC7E;QACD,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,IAAI,YAAY,GAAG,SAAS,CAAC;YAC7B,IAAI,CAAC,SAAS,EAAE;gBACd,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;gBAChD,YAAY,CAAC,YAAY,CAAC,CAAC;aAC5B;YACD,qGAAqG;YACrG,mBAAmB,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,YAAY,IAAI,CAAC;YAEvD,IAAI,SAAS,EAAE;gBACb,mBAAmB,CAAC,KAAK,CAAC,SAAS;oBACjC,mBAAmB,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;gBACnE,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC;gBAC5E,mBAAmB,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;gBAC1C,IAAI,MAAM;oBAAE,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;aAC1C;iBAAM;gBACL,mBAAmB,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,mBAAmB,CAAC,YAAY,IAAI,CAAC;gBAC3E,IAAI,MAAM;oBAAE,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,mBAAmB,CAAC,YAAY,IAAI,CAAC;aAC3E;SACF;IACH,CAAC,CAAC;IAEF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAEtD,OAAO,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { useRef, useState, MutableRefObject } from 'react';\n\nimport { debounce } from '../utils';\n\n/**\n * @example const [ref, resizeFunction] = useAutoResize();\n * maxHeight should be provided in pixels without units\n * minHeight should be provided in pixels without units\n * @returns * ref:: A reference for the element that the resize functionality should be applied to. [React RefObject](https://reactjs.org/docs/refs-and-the-dom.html)\n * * resizeFunction:: The function to call to automatically resize the element.\n * element refers to auto resizable element\n */\nconst useAutoResize = <T extends HTMLElement = HTMLElement>(\n maxHeight?: number,\n minHeightProp?: number\n): [MutableRefObject<T | null>, () => void] => {\n const element = useRef<T | null>(null);\n const [minHeight, setMinHeight] = useState(minHeightProp || 0);\n\n const autoResize = () => {\n let scrollHeightElement: HTMLElement = element.current as HTMLElement;\n let iframe: HTMLIFrameElement | undefined;\n if (element.current && element.current instanceof HTMLIFrameElement) {\n iframe = element.current;\n scrollHeightElement =\n element.current.contentDocument?.querySelector('body') ?? element.current;\n }\n if (element.current) {\n let newMinHeight = minHeight;\n if (!minHeight) {\n newMinHeight = scrollHeightElement.scrollHeight;\n setMinHeight(newMinHeight);\n }\n // Reset the heights to the base height so there is an overflow / or none to calculate the new height\n scrollHeightElement.style.height = `${newMinHeight}px`;\n\n if (maxHeight) {\n scrollHeightElement.style.overflowY =\n scrollHeightElement.scrollHeight > maxHeight ? 'auto' : 'hidden';\n const height = `${Math.min(scrollHeightElement.scrollHeight, maxHeight)}px`;\n scrollHeightElement.style.height = height;\n if (iframe) iframe.style.height = height;\n } else {\n scrollHeightElement.style.height = `${scrollHeightElement.scrollHeight}px`;\n if (iframe) iframe.style.height = `${scrollHeightElement.scrollHeight}px`;\n }\n }\n };\n\n const debouncedAutoResize = debounce(autoResize, 100);\n\n return [element, debouncedAutoResize];\n};\n\nexport default useAutoResize;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-core",
3
- "version": "3.0.0-dev.10.0",
3
+ "version": "3.0.0-dev.10.1",
4
4
  "description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
5
5
  "author": "Pegasystems",
6
6
  "license": "SEE LICENSE IN LICENSE",