@corva/ui 3.83.0-rc.0 → 3.84.0-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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),n=require("lodash"),o=require("./constants.scss.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),l=i(r);function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function d(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((function(r){s.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var c=parseInt(o.gap,10),u=parseInt(o.titleMinWidth,10)+c,y=function(e){var r;return(null===(r=e.current)||void 0===r?void 0:r.getBoundingClientRect().width)||0},f=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.filter((function(e){return!!e.current&&e.current.offsetWidth>0}));return e+o.reduce((function(e,r){return e+y(r)}),0)+(o.length>1?(o.length-1)*c:0)};exports.useResponsivity=function(e){var r=e.disabled,o=e.actionsRef,i=e.chipsRef,s=e.logoRef,a=e.rootRef,y=e.titleControlsRef,p=e.additionalControlsRef,v=e.versionRef,h=e.padModeRef,b=e.titleControlsLeft,O=t.useState({}),g=l.default(O,2),V=g[0],j=g[1],w=t.useRef(-1);return t.useEffect((function(){var e=n.throttle((function(){requestAnimationFrame((function(){var e,r=(null===(e=a.current)||void 0===e?void 0:e.offsetWidth)||0,t=function(e){var t,l=b&&f(u,s,v,i,o,y,p,h)<=r?d(d({},e),{},{root:{style:d(d({},null===(t=e.root)||void 0===t?void 0:t.style),{},{"--headerV3-responsivity-flexwrap":"nowrap"})}}):e;j((function(e){return n.isEqual(e,l)?e:l}))},l=function(){if(b){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=f.apply(void 0,[0].concat(r))+c;return{"--headerV3-responsivity-maxWidth":"calc(100% - ".concat(n,"px)")}}};f(u,s,v,i,o,y,p,h)<=r?t({title:{style:{"--headerV3-responsivity-marginRight":0}}}):f(u,s,v,i,o)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},padMode:{style:{"--headerV3-responsivity-order":120}},additionalControls:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:l(s,v,i,o)}}):!h.current&&f(u,s,v,i)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:l(s,v,i)}}):f(u,s,v,i)<=r&&f(0,y,p,h,o)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},padMode:{style:{"--headerV3-responsivity-order":130}},actions:{style:{"--headerV3-responsivity-order":140},lastInLine:!0},title:{style:l(s,v,i)}}):t({linebreaks:[{order:100},{order:200}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},padMode:{style:{"--headerV3-responsivity-order":210}},chips:{style:{"--headerV3-responsivity-order":220},lastInLine:!0},title:{style:l(s,v)}})}))}),100,{leading:!0}),t=new ResizeObserver((function(){var r,t=(null===(r=a.current)||void 0===r?void 0:r.offsetWidth)||0;t!==w.current&&e(),w.current=t})),l=new MutationObserver(e);return a.current&&!r&&(t.observe(a.current),l.observe(a.current,{childList:!0,subtree:!0,characterData:!0}),e.cancel()),function(){t.disconnect(),l.disconnect()}}),[o,i,s,a,y,p,v,h,r,b]),r?{}:V};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),n=require("lodash"),o=require("./constants.scss.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),l=i(r);function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function d(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((function(r){s.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var c=parseInt(o.gap,10),u=parseInt(o.titleMinWidth,10)+c,y=function(e){var r;return(null===(r=e.current)||void 0===r?void 0:r.getBoundingClientRect().width)||0},f=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.filter((function(e){return!!e.current&&e.current.offsetWidth>0}));return e+o.reduce((function(e,r){return e+y(r)}),0)+(o.length>1?(o.length-1)*c:0)};exports.useResponsivity=function(e){var r=e.disabled,o=e.actionsRef,i=e.chipsRef,s=e.logoRef,a=e.rootRef,y=e.titleControlsRef,p=e.additionalControlsRef,v=e.versionRef,h=e.padModeRef,b=e.titleControlsLeft,O=t.useState({}),g=l.default(O,2),V=g[0],j=g[1],w=t.useRef(-1);return t.useEffect((function(){var e=n.throttle((function(){requestAnimationFrame((function(){var e,r=(null===(e=a.current)||void 0===e?void 0:e.offsetWidth)||0,t=function(e){var t,l=b&&f(u,s,v,i,o,y,p,h)<=r?d(d({},e),{},{root:{style:d(d({},null===(t=e.root)||void 0===t?void 0:t.style),{},{"--headerV3-responsivity-flexwrap":"nowrap"})}}):e;j((function(e){return n.isEqual(e,l)?e:l}))},l=function(){if(b){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=f.apply(void 0,[0].concat(r))+c;return{"--headerV3-responsivity-maxWidth":"calc(100% - ".concat(n,"px)")}}};f(u,s,v,i,o,y,p,h)<=r?t({title:{style:{"--headerV3-responsivity-marginRight":0}}}):f(u,s,v,i,o)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},padMode:{style:{"--headerV3-responsivity-order":120}},additionalControls:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:l(s,v,i,o)}}):!h.current&&f(u,s,v,i)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:l(s,v,i)}}):f(u,s,v,i)<=r&&f(0,y,p,h,o)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},padMode:{style:{"--headerV3-responsivity-order":130}},actions:{style:{"--headerV3-responsivity-order":140},lastInLine:!0},title:{style:l(s,v,i)}}):t({linebreaks:[{order:100},{order:200}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},padMode:{style:{"--headerV3-responsivity-order":210}},chips:{style:{"--headerV3-responsivity-order":220},lastInLine:!0},title:{style:l(s,v)}})}))}),100,{leading:!0}),t=new ResizeObserver((function(){var r,t=(null===(r=a.current)||void 0===r?void 0:r.offsetWidth)||0;t!==w.current&&e(),w.current=t})),l=new MutationObserver(e);return a.current&&!r&&(t.observe(a.current),l.observe(a.current,{childList:!0,subtree:!0,characterData:!0}),e.cancel()),function(){t.disconnect(),l.disconnect(),e.cancel(),w.current=-1}}),[o,i,s,a,y,p,v,h,r,b]),r?{}:V};
2
2
  //# sourceMappingURL=useResponsivity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useResponsivity.js","sources":["../../../../../src/componentsV2/AppHeader/V3/useResponsivity.tsx"],"sourcesContent":["import { CSSProperties, RefObject, useEffect, useRef, useState } from 'react';\nimport { isEqual, throttle } from 'lodash';\n\nimport CssConstants from './constants.scss';\n\ntype Params = {\n disabled?: boolean;\n titleControlsLeft?: boolean;\n\n rootRef: RefObject<HTMLElement>;\n versionRef: RefObject<HTMLElement>;\n padModeRef: RefObject<HTMLElement>;\n additionalControlsRef: RefObject<HTMLElement>;\n titleControlsRef: RefObject<HTMLElement>;\n chipsRef: RefObject<HTMLElement>;\n logoRef: RefObject<HTMLElement>;\n actionsRef: RefObject<HTMLElement>;\n};\n\ntype ResponsivityDataItem = {\n style?: CSSProperties & Record<`--${string}`, number | string>;\n lastInLine?: boolean;\n};\n\ntype ResponsivityData = {\n root?: ResponsivityDataItem;\n padMode?: ResponsivityDataItem;\n additionalControls?: ResponsivityDataItem;\n titleControls?: ResponsivityDataItem;\n chips?: ResponsivityDataItem;\n actions?: ResponsivityDataItem;\n title?: ResponsivityDataItem;\n\n linebreaks?: CSSProperties[];\n};\n\nconst gap = parseInt(CssConstants.gap, 10);\nconst titleMinWidth = parseInt(CssConstants.titleMinWidth, 10) + gap;\n\nconst getRefWidth = (ref: RefObject<HTMLElement>) => {\n // This causes a reflow, so if it lags too much - use the `ref.current?.offsetWidth + 1`\n // `ref.current?.offsetWidth` rounds pixel fractions so it may produce incorrect results/need adjustment\n return ref.current?.getBoundingClientRect().width || 0;\n};\n\nconst sumLineWidth = (titleMinWidth: number, ...lineRefs: RefObject<HTMLElement>[]) => {\n const filteredRefs = lineRefs.filter(ref => !!ref.current && ref.current.offsetWidth > 0);\n return (\n titleMinWidth +\n filteredRefs.reduce((acc, ref) => acc + getRefWidth(ref), 0) +\n (filteredRefs.length > 1 ? (filteredRefs.length - 1) * gap : 0)\n );\n};\n\n/**\n * Detects when child elements stop fitting in a single header line and returns CSS orders, linebreaks, & other info for header elements\n *\n * There are several possible layouts:\n *\n * 1. Everything fits in one line\n * 2. 2 lines:\n * [logo] [title] [version] [asset chips] [actions]\n * [title controls] [pad mode] [additional controls]\n * and other variants that fit into 2 lines\n * 3. 3 lines:\n * [logo] [title] [version]\n * [title controls] [additional controls] [actions]\n * [pad mode] [chips]\n */\nexport const useResponsivity = ({\n disabled,\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n titleControlsLeft,\n}: Params) => {\n const [value, setValue] = useState<ResponsivityData>({});\n const previousWidthRef = useRef(-1);\n\n useEffect(() => {\n const calculateCss = throttle(\n () => {\n requestAnimationFrame(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n\n const setCss = (baseData: ResponsivityData) => {\n // We need nowrap to properly handle title when app title is very long and we have title controls to the left\n const isNowrap =\n titleControlsLeft &&\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth;\n\n const data = isNowrap\n ? {\n ...baseData,\n root: {\n style: {\n ...baseData.root?.style,\n '--headerV3-responsivity-flexwrap': 'nowrap',\n },\n },\n }\n : baseData;\n\n // Prevent unnecessary rerenders & rerender loop: recalc -> update values -> recalc -> update values to the same values\n setValue(value => (isEqual(value, data) ? value : data));\n };\n\n const getTitleMaxWidthStyle = (...refs: RefObject<HTMLElement>[]) => {\n if (!titleControlsLeft) {\n return undefined;\n }\n\n const pixels = sumLineWidth(0, ...refs) + gap;\n return { '--headerV3-responsivity-maxWidth': `calc(100% - ${pixels}px)` };\n };\n\n // Case 1 - everything fits\n if (\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth\n ) {\n setCss({\n title: { style: { '--headerV3-responsivity-marginRight': 0 } },\n });\n }\n // 2 lines\n // [logo] [title] [version] [asset chips] [actions]\n // [title controls] [pad mode] [additional controls]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef, actionsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n padMode: { style: { '--headerV3-responsivity-order': 120 } },\n additionalControls: {\n style: { '--headerV3-responsivity-order': 130 },\n lastInLine: true,\n },\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef, actionsRef) },\n });\n }\n // 2 lines - no padmode, has chips\n // [logo] [title] [version] [asset chips]\n // [title controls] [additional controls] [actions]\n else if (\n !padModeRef.current &&\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 2 lines:\n // [logo] [title] [version] [chips]\n // [title controls] [additional controls] [pad mode] [actions]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth &&\n sumLineWidth(0, titleControlsRef, additionalControlsRef, padModeRef, actionsRef) <=\n rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n padMode: { style: { '--headerV3-responsivity-order': 130 } },\n actions: { style: { '--headerV3-responsivity-order': 140 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 3 lines\n // [logo] [title] [version]\n // [title controls] [additional controls] [actions]\n // [pad mode] [chips]\n else {\n setCss({\n linebreaks: [{ order: 100 }, { order: 200 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n padMode: { style: { '--headerV3-responsivity-order': 210 } },\n chips: { style: { '--headerV3-responsivity-order': 220 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef) },\n });\n }\n });\n },\n 100,\n { leading: true }\n );\n\n const resizeObserver = new ResizeObserver(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n if (rootWidth !== previousWidthRef.current) {\n calculateCss();\n }\n previousWidthRef.current = rootWidth;\n });\n const mutationObserver = new MutationObserver(calculateCss);\n\n if (rootRef.current && !disabled) {\n resizeObserver.observe(rootRef.current);\n mutationObserver.observe(rootRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n calculateCss.cancel();\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, [\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n disabled,\n titleControlsLeft,\n ]);\n\n return disabled ? {} : value;\n};\n"],"names":["gap","parseInt","CssConstants","titleMinWidth","getRefWidth","ref","_ref$current","current","getBoundingClientRect","width","sumLineWidth","_len","arguments","length","lineRefs","Array","_key","filteredRefs","filter","offsetWidth","reduce","acc","_ref","disabled","actionsRef","chipsRef","logoRef","rootRef","titleControlsRef","additionalControlsRef","versionRef","padModeRef","titleControlsLeft","_useState","useState","_useState2","_slicedToArray","value","setValue","previousWidthRef","useRef","useEffect","calculateCss","throttle","requestAnimationFrame","_rootRef$current","rootWidth","setCss","baseData","_baseData$root","data","_objectSpread","root","style","isEqual","getTitleMaxWidthStyle","_len2","refs","_key2","pixels","apply","title","linebreaks","order","titleControls","padMode","additionalControls","lastInLine","actions","chips","leading","resizeObserver","ResizeObserver","_rootRef$current2","mutationObserver","MutationObserver","observe","childList","subtree","characterData","cancel","disconnect"],"mappings":"s5BAoCA,IAAMA,EAAMC,SAASC,EAAaF,IAAK,IACjCG,EAAgBF,SAASC,EAAaC,cAAe,IAAMH,EAE3DI,EAAc,SAACC,GAAgC,IAAAC,EAGnD,OAAkB,QAAXA,EAAAD,EAAIE,eAAO,IAAAD,OAAA,EAAXA,EAAaE,wBAAwBC,QAAS,CACvD,EAEMC,EAAe,SAACP,GAAiE,IAAA,IAAAQ,EAAAC,UAAAC,OAAvCC,EAAQ,IAAAC,MAAAJ,EAAA,EAAAA,EAAA,EAAA,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAARF,EAAQE,EAAA,GAAAJ,UAAAI,GACtD,IAAMC,EAAeH,EAASI,QAAO,SAAAb,GAAG,QAAMA,EAAIE,SAAWF,EAAIE,QAAQY,YAAc,KACvF,OACEhB,EACAc,EAAaG,QAAO,SAACC,EAAKhB,GAAG,OAAKgB,EAAMjB,EAAYC,EAAI,GAAE,IACzDY,EAAaJ,OAAS,GAAKI,EAAaJ,OAAS,GAAKb,EAAM,EAEjE,0BAiB+B,SAWjBsB,GAAA,IAVZC,IAAAA,SACAC,IAAAA,WACAC,IAAAA,SACAC,IAAAA,QACAC,IAAAA,QACAC,IAAAA,iBACAC,IAAAA,sBACAC,IAAAA,WACAC,IAAAA,WACAC,IAAAA,kBAEAC,EAA0BC,EAAQA,SAAmB,IAAGC,EAAAC,EAAAA,QAAAH,EAAA,GAAjDI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAChBI,EAAmBC,EAAAA,QAAQ,GA8KjC,OA5KAC,EAAAA,WAAU,WACR,IAAMC,EAAeC,EAAAA,UACnB,WACEC,uBAAsB,WAAM,IAAAC,EACpBC,GAAY,QAAAD,EAAAlB,EAAQpB,eAAR,IAAAsC,OAAA,EAAAA,EAAiB1B,cAAe,EAE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BrC,EAAasC,UAGR,WACLT,EAAeU,aACfP,EAAiBO,aAEpB,GAAE,CACDzD,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAR,EACAS,IAGKT,EAAW,CAAE,EAAGc,CACzB"}
1
+ {"version":3,"file":"useResponsivity.js","sources":["../../../../../src/componentsV2/AppHeader/V3/useResponsivity.tsx"],"sourcesContent":["import { CSSProperties, RefObject, useEffect, useRef, useState } from 'react';\nimport { isEqual, throttle } from 'lodash';\n\nimport CssConstants from './constants.scss';\n\ntype Params = {\n disabled?: boolean;\n titleControlsLeft?: boolean;\n\n rootRef: RefObject<HTMLElement>;\n versionRef: RefObject<HTMLElement>;\n padModeRef: RefObject<HTMLElement>;\n additionalControlsRef: RefObject<HTMLElement>;\n titleControlsRef: RefObject<HTMLElement>;\n chipsRef: RefObject<HTMLElement>;\n logoRef: RefObject<HTMLElement>;\n actionsRef: RefObject<HTMLElement>;\n};\n\ntype ResponsivityDataItem = {\n style?: CSSProperties & Record<`--${string}`, number | string>;\n lastInLine?: boolean;\n};\n\ntype ResponsivityData = {\n root?: ResponsivityDataItem;\n padMode?: ResponsivityDataItem;\n additionalControls?: ResponsivityDataItem;\n titleControls?: ResponsivityDataItem;\n chips?: ResponsivityDataItem;\n actions?: ResponsivityDataItem;\n title?: ResponsivityDataItem;\n\n linebreaks?: CSSProperties[];\n};\n\nconst gap = parseInt(CssConstants.gap, 10);\nconst titleMinWidth = parseInt(CssConstants.titleMinWidth, 10) + gap;\n\nconst getRefWidth = (ref: RefObject<HTMLElement>) => {\n // This causes a reflow, so if it lags too much - use the `ref.current?.offsetWidth + 1`\n // `ref.current?.offsetWidth` rounds pixel fractions so it may produce incorrect results/need adjustment\n return ref.current?.getBoundingClientRect().width || 0;\n};\n\nconst sumLineWidth = (titleMinWidth: number, ...lineRefs: RefObject<HTMLElement>[]) => {\n const filteredRefs = lineRefs.filter(ref => !!ref.current && ref.current.offsetWidth > 0);\n return (\n titleMinWidth +\n filteredRefs.reduce((acc, ref) => acc + getRefWidth(ref), 0) +\n (filteredRefs.length > 1 ? (filteredRefs.length - 1) * gap : 0)\n );\n};\n\n/**\n * Detects when child elements stop fitting in a single header line and returns CSS orders, linebreaks, & other info for header elements\n *\n * There are several possible layouts:\n *\n * 1. Everything fits in one line\n * 2. 2 lines:\n * [logo] [title] [version] [asset chips] [actions]\n * [title controls] [pad mode] [additional controls]\n * and other variants that fit into 2 lines\n * 3. 3 lines:\n * [logo] [title] [version]\n * [title controls] [additional controls] [actions]\n * [pad mode] [chips]\n */\nexport const useResponsivity = ({\n disabled,\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n titleControlsLeft,\n}: Params) => {\n const [value, setValue] = useState<ResponsivityData>({});\n const previousWidthRef = useRef(-1);\n\n useEffect(() => {\n const calculateCss = throttle(\n () => {\n requestAnimationFrame(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n\n const setCss = (baseData: ResponsivityData) => {\n // We need nowrap to properly handle title when app title is very long and we have title controls to the left\n const isNowrap =\n titleControlsLeft &&\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth;\n\n const data = isNowrap\n ? {\n ...baseData,\n root: {\n style: {\n ...baseData.root?.style,\n '--headerV3-responsivity-flexwrap': 'nowrap',\n },\n },\n }\n : baseData;\n\n // Prevent unnecessary rerenders & rerender loop: recalc -> update values -> recalc -> update values to the same values\n setValue(value => (isEqual(value, data) ? value : data));\n };\n\n const getTitleMaxWidthStyle = (...refs: RefObject<HTMLElement>[]) => {\n if (!titleControlsLeft) {\n return undefined;\n }\n\n const pixels = sumLineWidth(0, ...refs) + gap;\n return { '--headerV3-responsivity-maxWidth': `calc(100% - ${pixels}px)` };\n };\n\n // Case 1 - everything fits\n if (\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth\n ) {\n setCss({\n title: { style: { '--headerV3-responsivity-marginRight': 0 } },\n });\n }\n // 2 lines\n // [logo] [title] [version] [asset chips] [actions]\n // [title controls] [pad mode] [additional controls]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef, actionsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n padMode: { style: { '--headerV3-responsivity-order': 120 } },\n additionalControls: {\n style: { '--headerV3-responsivity-order': 130 },\n lastInLine: true,\n },\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef, actionsRef) },\n });\n }\n // 2 lines - no padmode, has chips\n // [logo] [title] [version] [asset chips]\n // [title controls] [additional controls] [actions]\n else if (\n !padModeRef.current &&\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 2 lines:\n // [logo] [title] [version] [chips]\n // [title controls] [additional controls] [pad mode] [actions]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth &&\n sumLineWidth(0, titleControlsRef, additionalControlsRef, padModeRef, actionsRef) <=\n rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n padMode: { style: { '--headerV3-responsivity-order': 130 } },\n actions: { style: { '--headerV3-responsivity-order': 140 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 3 lines\n // [logo] [title] [version]\n // [title controls] [additional controls] [actions]\n // [pad mode] [chips]\n else {\n setCss({\n linebreaks: [{ order: 100 }, { order: 200 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n padMode: { style: { '--headerV3-responsivity-order': 210 } },\n chips: { style: { '--headerV3-responsivity-order': 220 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef) },\n });\n }\n });\n },\n 100,\n { leading: true }\n );\n\n const resizeObserver = new ResizeObserver(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n if (rootWidth !== previousWidthRef.current) {\n calculateCss();\n }\n previousWidthRef.current = rootWidth;\n });\n const mutationObserver = new MutationObserver(calculateCss);\n\n if (rootRef.current && !disabled) {\n resizeObserver.observe(rootRef.current);\n mutationObserver.observe(rootRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n calculateCss.cancel();\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n calculateCss.cancel();\n previousWidthRef.current = -1;\n };\n }, [\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n disabled,\n titleControlsLeft,\n ]);\n\n return disabled ? {} : value;\n};\n"],"names":["gap","parseInt","CssConstants","titleMinWidth","getRefWidth","ref","_ref$current","current","getBoundingClientRect","width","sumLineWidth","_len","arguments","length","lineRefs","Array","_key","filteredRefs","filter","offsetWidth","reduce","acc","_ref","disabled","actionsRef","chipsRef","logoRef","rootRef","titleControlsRef","additionalControlsRef","versionRef","padModeRef","titleControlsLeft","_useState","useState","_useState2","_slicedToArray","value","setValue","previousWidthRef","useRef","useEffect","calculateCss","throttle","requestAnimationFrame","_rootRef$current","rootWidth","setCss","baseData","_baseData$root","data","_objectSpread","root","style","isEqual","getTitleMaxWidthStyle","_len2","refs","_key2","pixels","apply","title","linebreaks","order","titleControls","padMode","additionalControls","lastInLine","actions","chips","leading","resizeObserver","ResizeObserver","_rootRef$current2","mutationObserver","MutationObserver","observe","childList","subtree","characterData","cancel","disconnect"],"mappings":"s5BAoCA,IAAMA,EAAMC,SAASC,EAAaF,IAAK,IACjCG,EAAgBF,SAASC,EAAaC,cAAe,IAAMH,EAE3DI,EAAc,SAACC,GAAgC,IAAAC,EAGnD,OAAkB,QAAXA,EAAAD,EAAIE,eAAO,IAAAD,OAAA,EAAXA,EAAaE,wBAAwBC,QAAS,CACvD,EAEMC,EAAe,SAACP,GAAiE,IAAA,IAAAQ,EAAAC,UAAAC,OAAvCC,EAAQ,IAAAC,MAAAJ,EAAA,EAAAA,EAAA,EAAA,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAARF,EAAQE,EAAA,GAAAJ,UAAAI,GACtD,IAAMC,EAAeH,EAASI,QAAO,SAAAb,GAAG,QAAMA,EAAIE,SAAWF,EAAIE,QAAQY,YAAc,KACvF,OACEhB,EACAc,EAAaG,QAAO,SAACC,EAAKhB,GAAG,OAAKgB,EAAMjB,EAAYC,EAAI,GAAE,IACzDY,EAAaJ,OAAS,GAAKI,EAAaJ,OAAS,GAAKb,EAAM,EAEjE,0BAiB+B,SAWjBsB,GAAA,IAVZC,IAAAA,SACAC,IAAAA,WACAC,IAAAA,SACAC,IAAAA,QACAC,IAAAA,QACAC,IAAAA,iBACAC,IAAAA,sBACAC,IAAAA,WACAC,IAAAA,WACAC,IAAAA,kBAEAC,EAA0BC,EAAQA,SAAmB,IAAGC,EAAAC,EAAAA,QAAAH,EAAA,GAAjDI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAChBI,EAAmBC,EAAAA,QAAQ,GAgLjC,OA9KAC,EAAAA,WAAU,WACR,IAAMC,EAAeC,EAAAA,UACnB,WACEC,uBAAsB,WAAM,IAAAC,EACpBC,GAAY,QAAAD,EAAAlB,EAAQpB,eAAR,IAAAsC,OAAA,EAAAA,EAAiB1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,eAAe,IAEjBrC,EAAasC,UAGR,WACLT,EAAeU,aACfP,EAAiBO,aACjBvC,EAAasC,SACbzC,EAAiBhC,SAAW,EAE/B,GAAE,CACDiB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAR,EACAS,IAGKT,EAAW,CAAE,EAAGc,CACzB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("classnames"),r=require("react"),i=require("lodash"),n=require("../Tooltip/Tooltip.js"),s=require("./TextEndTruncated.scss.js"),u=require("react/jsx-runtime");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(e),l=a(t);exports.TextEndTruncated=function(e){var t=e.children,a=e.disableTooltip,o=e.maxLines,d=void 0===o?1:o,f=e.testId,b=e.className,v=d>1,h=r.useRef(null),m=r.useRef(v),p=r.useState(null),x=c.default(p,2),T=x[0],q=x[1],j=r.useState(!0),L=c.default(j,2),y=L[0],g=L[1];return m.current=v,r.useLayoutEffect((function(){var e=i.debounce((function(){requestAnimationFrame((function(){var e=h.current;e&&(q(e.textContent),g(e.scrollWidth<=e.clientWidth&&(e.scrollHeight<=e.clientHeight||!m.current)))}))}),200),t=new ResizeObserver(e),r=new MutationObserver(e);return h.current&&(t.observe(h.current),r.observe(h.current,{childList:!0,subtree:!0,characterData:!0})),function(){t.disconnect(),r.disconnect()}}),[]),u.jsx(n.Tooltip,{title:T,disabled:y||a,children:u.jsx("div",{className:l.default(s.root,v?s.multiLine:s.singleLine,b),style:v?{WebkitLineClamp:d}:void 0,ref:h,"data-testid":f,children:t})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("classnames"),r=require("react"),n=require("lodash"),i=require("../Tooltip/Tooltip.js"),s=require("./TextEndTruncated.scss.js"),u=require("react/jsx-runtime");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(e),l=c(t);exports.TextEndTruncated=function(e){var t=e.children,c=e.disableTooltip,o=e.maxLines,d=void 0===o?1:o,f=e.testId,b=e.className,v=d>1,h=r.useRef(null),m=r.useRef(v),p=r.useState(null),x=a.default(p,2),T=x[0],q=x[1],j=r.useState(!0),L=a.default(j,2),y=L[0],g=L[1];return m.current=v,r.useLayoutEffect((function(){var e=n.debounce((function(){requestAnimationFrame((function(){var e=h.current;e&&(q(e.textContent),g(e.scrollWidth<=e.clientWidth&&(e.scrollHeight<=e.clientHeight||!m.current)))}))}),200),t=new ResizeObserver(e),r=new MutationObserver(e);return h.current&&(t.observe(h.current),r.observe(h.current,{childList:!0,subtree:!0,characterData:!0})),function(){t.disconnect(),r.disconnect(),e.cancel()}}),[]),u.jsx(i.Tooltip,{title:T,disabled:y||c,children:u.jsx("div",{className:l.default(s.root,v?s.multiLine:s.singleLine,b),style:v?{WebkitLineClamp:d}:void 0,ref:h,"data-testid":f,children:t})})};
2
2
  //# sourceMappingURL=TextEndTruncated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextEndTruncated.js","sources":["../../../../src/componentsV2/TextEndTruncated/TextEndTruncated.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useLayoutEffect, useRef, useState } from 'react';\nimport { debounce } from 'lodash';\n\nimport { Tooltip } from '../Tooltip';\n\nimport styles from './TextEndTruncated.scss';\n\nexport type TextEndTruncatedProps = {\n /**\n * Content\n */\n children?: React.ReactNode;\n /**\n * Forces the component not to show its tooltip\n */\n disableTooltip?: boolean;\n maxLines?: number;\n\n className?: string;\n testId?: string;\n};\n\nexport const TextEndTruncated = ({\n children,\n disableTooltip,\n maxLines = 1,\n testId,\n className,\n}: TextEndTruncatedProps) => {\n const isMultiline = maxLines > 1;\n const containerRef = useRef<HTMLDivElement>(null);\n const multilineRef = useRef<boolean>(isMultiline);\n const [tooltipContent, setTooltipContent] = useState<string | null>(null);\n const [dimensionsDisabled, setDimensionsDisabled] = useState(true);\n\n multilineRef.current = isMultiline;\n\n useLayoutEffect(() => {\n const onDimensionsOrContentChange = debounce(() => {\n requestAnimationFrame(() => {\n const container = containerRef.current;\n if (container) {\n setTooltipContent(container.textContent);\n setDimensionsDisabled(\n container.scrollWidth <= container.clientWidth &&\n // multilineRef is needed to handle an edgecase when there's a `lineHeight` that's smaller than the space needed to render a font, so\n // `scrollHeight` is bigger than `clientHeight`\n (container.scrollHeight <= container.clientHeight || !multilineRef.current)\n );\n }\n });\n }, 200);\n\n const resizeObserver = new ResizeObserver(onDimensionsOrContentChange);\n const mutationObserver = new MutationObserver(onDimensionsOrContentChange);\n\n if (containerRef.current /* && innerRef.current */) {\n resizeObserver.observe(containerRef.current);\n mutationObserver.observe(containerRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n return (\n <Tooltip title={tooltipContent} disabled={dimensionsDisabled || disableTooltip}>\n <div\n className={classNames(\n styles.root,\n isMultiline ? styles.multiLine : styles.singleLine,\n className\n )}\n style={isMultiline ? { WebkitLineClamp: maxLines } : undefined}\n ref={containerRef}\n data-testid={testId}\n >\n {children}\n </div>\n </Tooltip>\n );\n};\n"],"names":["_ref","children","disableTooltip","_ref$maxLines","maxLines","testId","className","isMultiline","containerRef","useRef","multilineRef","useState","_useState2","_slicedToArray","_useState","tooltipContent","setTooltipContent","_useState4","_useState3","dimensionsDisabled","setDimensionsDisabled","current","useLayoutEffect","onDimensionsOrContentChange","debounce","requestAnimationFrame","container","textContent","scrollWidth","clientWidth","scrollHeight","clientHeight","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observe","childList","subtree","characterData","disconnect","_jsx","Tooltip","title","disabled","jsx","classNames","styles","root","multiLine","singleLine","style","WebkitLineClamp","undefined","ref"],"mappings":"sZAuBgC,SAMHA,GAAA,IAL3BC,IAAAA,SACAC,IAAAA,eAAcC,EAAAH,EACdI,SAAAA,aAAW,EAACD,EACZE,IAAAA,OACAC,IAAAA,UAEMC,EAAcH,EAAW,EACzBI,EAAeC,SAAuB,MACtCC,EAAeD,SAAgBF,GACOI,EAAAA,EAAQA,SAAgB,MAAKC,EAAAC,EAAAA,QAAAC,EAAA,GAAlEC,EAAcH,EAAA,GAAEI,EAAiBJ,EAAA,GACYD,EAAAA,EAAQA,UAAC,GAAKM,EAAAJ,EAAAA,QAAAK,EAAA,GAA3DC,EAAkBF,EAAA,GAAEG,EAAqBH,EAAA,GAsChD,OApCAP,EAAaW,QAAUd,EAEvBe,EAAAA,iBAAgB,WACd,IAAMC,EAA8BC,EAAAA,UAAS,WAC3CC,uBAAsB,WACpB,IAAMC,EAAYlB,EAAaa,QAC3BK,IACFV,EAAkBU,EAAUC,aAC5BP,EACEM,EAAUE,aAAeF,EAAUG,cAGhCH,EAAUI,cAAgBJ,EAAUK,eAAiBrB,EAAaW,UAG3E,GACD,GAAE,KAEGW,EAAiB,IAAIC,eAAeV,GACpCW,EAAmB,IAAIC,iBAAiBZ,GAW9C,OATIf,EAAaa,UACfW,EAAeI,QAAQ5B,EAAaa,SACpCa,EAAiBE,QAAQ5B,EAAaa,QAAS,CAC7CgB,WAAW,EACXC,SAAS,EACTC,eAAe,KAIZ,WACLP,EAAeQ,aACfN,EAAiBM,aAEpB,GAAE,IAGDC,EAAAA,IAACC,EAAAA,QAAO,CAACC,MAAO5B,EAAgB6B,SAAUzB,GAAsBjB,EAAeD,SAC7EwC,EAAAI,IAAA,MAAA,CACEvC,UAAWwC,EAAAA,QACTC,EAAOC,KACPzC,EAAcwC,EAAOE,UAAYF,EAAOG,WACxC5C,GAEF6C,MAAO5C,EAAc,CAAE6C,gBAAiBhD,QAAaiD,EACrDC,IAAK9C,EACL,cAAaH,EAAOJ,SAEnBA,KAIT"}
1
+ {"version":3,"file":"TextEndTruncated.js","sources":["../../../../src/componentsV2/TextEndTruncated/TextEndTruncated.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useLayoutEffect, useRef, useState } from 'react';\nimport { debounce } from 'lodash';\n\nimport { Tooltip } from '../Tooltip';\n\nimport styles from './TextEndTruncated.scss';\n\nexport type TextEndTruncatedProps = {\n /**\n * Content\n */\n children?: React.ReactNode;\n /**\n * Forces the component not to show its tooltip\n */\n disableTooltip?: boolean;\n maxLines?: number;\n\n className?: string;\n testId?: string;\n};\n\nexport const TextEndTruncated = ({\n children,\n disableTooltip,\n maxLines = 1,\n testId,\n className,\n}: TextEndTruncatedProps) => {\n const isMultiline = maxLines > 1;\n const containerRef = useRef<HTMLDivElement>(null);\n const multilineRef = useRef<boolean>(isMultiline);\n const [tooltipContent, setTooltipContent] = useState<string | null>(null);\n const [dimensionsDisabled, setDimensionsDisabled] = useState(true);\n\n multilineRef.current = isMultiline;\n\n useLayoutEffect(() => {\n const onDimensionsOrContentChange = debounce(() => {\n requestAnimationFrame(() => {\n const container = containerRef.current;\n if (container) {\n setTooltipContent(container.textContent);\n setDimensionsDisabled(\n container.scrollWidth <= container.clientWidth &&\n // multilineRef is needed to handle an edgecase when there's a `lineHeight` that's smaller than the space needed to render a font, so\n // `scrollHeight` is bigger than `clientHeight`\n (container.scrollHeight <= container.clientHeight || !multilineRef.current)\n );\n }\n });\n }, 200);\n\n const resizeObserver = new ResizeObserver(onDimensionsOrContentChange);\n const mutationObserver = new MutationObserver(onDimensionsOrContentChange);\n\n if (containerRef.current /* && innerRef.current */) {\n resizeObserver.observe(containerRef.current);\n mutationObserver.observe(containerRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n onDimensionsOrContentChange.cancel();\n };\n }, []);\n\n return (\n <Tooltip title={tooltipContent} disabled={dimensionsDisabled || disableTooltip}>\n <div\n className={classNames(\n styles.root,\n isMultiline ? styles.multiLine : styles.singleLine,\n className\n )}\n style={isMultiline ? { WebkitLineClamp: maxLines } : undefined}\n ref={containerRef}\n data-testid={testId}\n >\n {children}\n </div>\n </Tooltip>\n );\n};\n"],"names":["_ref","children","disableTooltip","_ref$maxLines","maxLines","testId","className","isMultiline","containerRef","useRef","multilineRef","useState","_useState2","_slicedToArray","_useState","tooltipContent","setTooltipContent","_useState4","_useState3","dimensionsDisabled","setDimensionsDisabled","current","useLayoutEffect","onDimensionsOrContentChange","debounce","requestAnimationFrame","container","textContent","scrollWidth","clientWidth","scrollHeight","clientHeight","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observe","childList","subtree","characterData","disconnect","cancel","_jsx","Tooltip","title","disabled","jsx","classNames","styles","root","multiLine","singleLine","style","WebkitLineClamp","undefined","ref"],"mappings":"sZAuBgC,SAMHA,GAAA,IAL3BC,IAAAA,SACAC,IAAAA,eAAcC,EAAAH,EACdI,SAAAA,aAAW,EAACD,EACZE,IAAAA,OACAC,IAAAA,UAEMC,EAAcH,EAAW,EACzBI,EAAeC,SAAuB,MACtCC,EAAeD,SAAgBF,GACOI,EAAAA,EAAQA,SAAgB,MAAKC,EAAAC,EAAAA,QAAAC,EAAA,GAAlEC,EAAcH,EAAA,GAAEI,EAAiBJ,EAAA,GACYD,EAAAA,EAAQA,UAAC,GAAKM,EAAAJ,EAAAA,QAAAK,EAAA,GAA3DC,EAAkBF,EAAA,GAAEG,EAAqBH,EAAA,GAuChD,OArCAP,EAAaW,QAAUd,EAEvBe,EAAAA,iBAAgB,WACd,IAAMC,EAA8BC,EAAAA,UAAS,WAC3CC,uBAAsB,WACpB,IAAMC,EAAYlB,EAAaa,QAC3BK,IACFV,EAAkBU,EAAUC,aAC5BP,EACEM,EAAUE,aAAeF,EAAUG,cAGhCH,EAAUI,cAAgBJ,EAAUK,eAAiBrB,EAAaW,UAG3E,GACD,GAAE,KAEGW,EAAiB,IAAIC,eAAeV,GACpCW,EAAmB,IAAIC,iBAAiBZ,GAW9C,OATIf,EAAaa,UACfW,EAAeI,QAAQ5B,EAAaa,SACpCa,EAAiBE,QAAQ5B,EAAaa,QAAS,CAC7CgB,WAAW,EACXC,SAAS,EACTC,eAAe,KAIZ,WACLP,EAAeQ,aACfN,EAAiBM,aACjBjB,EAA4BkB,SAE/B,GAAE,IAGDC,EAAAA,IAACC,EAAAA,QAAO,CAACC,MAAO7B,EAAgB8B,SAAU1B,GAAsBjB,EAAeD,SAC7EyC,EAAAI,IAAA,MAAA,CACExC,UAAWyC,EAAAA,QACTC,EAAOC,KACP1C,EAAcyC,EAAOE,UAAYF,EAAOG,WACxC7C,GAEF8C,MAAO7C,EAAc,CAAE8C,gBAAiBjD,QAAakD,EACrDC,IAAK/C,EACL,cAAaH,EAAOJ,SAEnBA,KAIT"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),r=require("lodash");module.exports=function(n){var c=n.callback,t=n.containerRef,u=n.wait,i=void 0===u?100:u;e.useEffect((function(){var e=r.debounce(c,i),n=new ResizeObserver(e);return t.current&&n.observe(t.current),function(){n.disconnect()}}),[c,t])};
1
+ "use strict";var e=require("react"),r=require("lodash");module.exports=function(c){var n=c.callback,t=c.containerRef,u=c.wait,i=void 0===u?100:u;e.useEffect((function(){var e=r.debounce(n,i),c=new ResizeObserver(e);return t.current&&c.observe(t.current),function(){c.disconnect(),e.cancel()}}),[n,t])};
2
2
  //# sourceMappingURL=useResizeObserver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useResizeObserver.js","sources":["../../../src/effects/useResizeObserver.js"],"sourcesContent":["import { useEffect } from 'react';\nimport { debounce } from 'lodash';\n\nconst DEFAULT_WAIT = 100;\n\nfunction useResizeObserver({ callback, containerRef, wait = DEFAULT_WAIT }) {\n useEffect(() => {\n const debouncedCallback = debounce(callback, wait);\n const resizeObserver = new ResizeObserver(debouncedCallback);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [callback, containerRef]);\n}\n\nexport default useResizeObserver;\n"],"names":["_ref","callback","containerRef","_ref$wait","wait","useEffect","debouncedCallback","debounce","resizeObserver","ResizeObserver","current","observe","disconnect"],"mappings":"uEAKA,SAA4EA,GAAA,IAA/CC,IAAAA,SAAUC,IAAAA,aAAYC,EAAAH,EAAEI,KAAAA,aAFhC,IAEmDD,EACtEE,EAAAA,WAAU,WACR,IAAMC,EAAoBC,EAAAA,SAASN,EAAUG,GACvCI,EAAiB,IAAIC,eAAeH,GAM1C,OAJIJ,EAAaQ,SACfF,EAAeG,QAAQT,EAAaQ,SAG/B,WACLF,EAAeI,aAEnB,GAAG,CAACX,EAAUC,GAChB"}
1
+ {"version":3,"file":"useResizeObserver.js","sources":["../../../src/effects/useResizeObserver.js"],"sourcesContent":["import { useEffect } from 'react';\nimport { debounce } from 'lodash';\n\nconst DEFAULT_WAIT = 100;\n\nfunction useResizeObserver({ callback, containerRef, wait = DEFAULT_WAIT }) {\n useEffect(() => {\n const debouncedCallback = debounce(callback, wait);\n const resizeObserver = new ResizeObserver(debouncedCallback);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n\n return () => {\n resizeObserver.disconnect();\n debouncedCallback.cancel();\n };\n }, [callback, containerRef]);\n}\n\nexport default useResizeObserver;\n"],"names":["_ref","callback","containerRef","_ref$wait","wait","useEffect","debouncedCallback","debounce","resizeObserver","ResizeObserver","current","observe","disconnect","cancel"],"mappings":"uEAKA,SAA4EA,GAAA,IAA/CC,IAAAA,SAAUC,IAAAA,aAAYC,EAAAH,EAAEI,KAAAA,aAFhC,IAEmDD,EACtEE,EAAAA,WAAU,WACR,IAAMC,EAAoBC,EAAAA,SAASN,EAAUG,GACvCI,EAAiB,IAAIC,eAAeH,GAM1C,OAJIJ,EAAaQ,SACfF,EAAeG,QAAQT,EAAaQ,SAG/B,WACLF,EAAeI,aACfN,EAAkBO,SAEtB,GAAG,CAACZ,EAAUC,GAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useResponsivity.d.ts","sourceRoot":"","sources":["../../../../src/componentsV2/AppHeader/V3/useResponsivity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAK9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";import r from"@babel/runtime/helpers/slicedToArray";import{useState as t,useRef as n,useEffect as o}from"react";import{throttle as i,isEqual as s}from"lodash";import l from"./constants.scss.js";function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function d(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var c=parseInt(l.gap,10),p=parseInt(l.titleMinWidth,10)+c,y=function(e){var r;return(null===(r=e.current)||void 0===r?void 0:r.getBoundingClientRect().width)||0},u=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.filter((function(e){return!!e.current&&e.current.offsetWidth>0}));return e+o.reduce((function(e,r){return e+y(r)}),0)+(o.length>1?(o.length-1)*c:0)},f=function(e){var l=e.disabled,a=e.actionsRef,y=e.chipsRef,f=e.logoRef,v=e.rootRef,h=e.titleControlsRef,b=e.additionalControlsRef,m=e.versionRef,O=e.padModeRef,g=e.titleControlsLeft,V=t({}),w=r(V,2),j=w[0],C=w[1],R=n(-1);return o((function(){var e=i((function(){requestAnimationFrame((function(){var e,r=(null===(e=v.current)||void 0===e?void 0:e.offsetWidth)||0,t=function(e){var t,n=g&&u(p,f,m,y,a,h,b,O)<=r?d(d({},e),{},{root:{style:d(d({},null===(t=e.root)||void 0===t?void 0:t.style),{},{"--headerV3-responsivity-flexwrap":"nowrap"})}}):e;C((function(e){return s(e,n)?e:n}))},n=function(){if(g){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=u.apply(void 0,[0].concat(r))+c;return{"--headerV3-responsivity-maxWidth":"calc(100% - ".concat(n,"px)")}}};u(p,f,m,y,a,h,b,O)<=r?t({title:{style:{"--headerV3-responsivity-marginRight":0}}}):u(p,f,m,y,a)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},padMode:{style:{"--headerV3-responsivity-order":120}},additionalControls:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:n(f,m,y,a)}}):!O.current&&u(p,f,m,y)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:n(f,m,y)}}):u(p,f,m,y)<=r&&u(0,h,b,O,a)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},padMode:{style:{"--headerV3-responsivity-order":130}},actions:{style:{"--headerV3-responsivity-order":140},lastInLine:!0},title:{style:n(f,m,y)}}):t({linebreaks:[{order:100},{order:200}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},padMode:{style:{"--headerV3-responsivity-order":210}},chips:{style:{"--headerV3-responsivity-order":220},lastInLine:!0},title:{style:n(f,m)}})}))}),100,{leading:!0}),r=new ResizeObserver((function(){var r,t=(null===(r=v.current)||void 0===r?void 0:r.offsetWidth)||0;t!==R.current&&e(),R.current=t})),t=new MutationObserver(e);return v.current&&!l&&(r.observe(v.current),t.observe(v.current,{childList:!0,subtree:!0,characterData:!0}),e.cancel()),function(){r.disconnect(),t.disconnect()}}),[a,y,f,v,h,b,m,O,l,g]),l?{}:j};export{f as useResponsivity};
1
+ import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{useState as t,useRef as n,useEffect as o}from"react";import{throttle as i,isEqual as s}from"lodash";import l from"./constants.scss.js";function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function d(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var c=parseInt(l.gap,10),p=parseInt(l.titleMinWidth,10)+c,y=function(e){var r;return(null===(r=e.current)||void 0===r?void 0:r.getBoundingClientRect().width)||0},u=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.filter((function(e){return!!e.current&&e.current.offsetWidth>0}));return e+o.reduce((function(e,r){return e+y(r)}),0)+(o.length>1?(o.length-1)*c:0)},f=function(e){var l=e.disabled,a=e.actionsRef,y=e.chipsRef,f=e.logoRef,v=e.rootRef,h=e.titleControlsRef,b=e.additionalControlsRef,m=e.versionRef,O=e.padModeRef,g=e.titleControlsLeft,V=t({}),w=r(V,2),j=w[0],C=w[1],R=n(-1);return o((function(){var e=i((function(){requestAnimationFrame((function(){var e,r=(null===(e=v.current)||void 0===e?void 0:e.offsetWidth)||0,t=function(e){var t,n=g&&u(p,f,m,y,a,h,b,O)<=r?d(d({},e),{},{root:{style:d(d({},null===(t=e.root)||void 0===t?void 0:t.style),{},{"--headerV3-responsivity-flexwrap":"nowrap"})}}):e;C((function(e){return s(e,n)?e:n}))},n=function(){if(g){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=u.apply(void 0,[0].concat(r))+c;return{"--headerV3-responsivity-maxWidth":"calc(100% - ".concat(n,"px)")}}};u(p,f,m,y,a,h,b,O)<=r?t({title:{style:{"--headerV3-responsivity-marginRight":0}}}):u(p,f,m,y,a)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},padMode:{style:{"--headerV3-responsivity-order":120}},additionalControls:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:n(f,m,y,a)}}):!O.current&&u(p,f,m,y)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},title:{style:n(f,m,y)}}):u(p,f,m,y)<=r&&u(0,h,b,O,a)<=r?t({linebreaks:[{order:100}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},padMode:{style:{"--headerV3-responsivity-order":130}},actions:{style:{"--headerV3-responsivity-order":140},lastInLine:!0},title:{style:n(f,m,y)}}):t({linebreaks:[{order:100},{order:200}],titleControls:{style:{"--headerV3-responsivity-order":110}},additionalControls:{style:{"--headerV3-responsivity-order":120}},actions:{style:{"--headerV3-responsivity-order":130},lastInLine:!0},padMode:{style:{"--headerV3-responsivity-order":210}},chips:{style:{"--headerV3-responsivity-order":220},lastInLine:!0},title:{style:n(f,m)}})}))}),100,{leading:!0}),r=new ResizeObserver((function(){var r,t=(null===(r=v.current)||void 0===r?void 0:r.offsetWidth)||0;t!==R.current&&e(),R.current=t})),t=new MutationObserver(e);return v.current&&!l&&(r.observe(v.current),t.observe(v.current,{childList:!0,subtree:!0,characterData:!0}),e.cancel()),function(){r.disconnect(),t.disconnect(),e.cancel(),R.current=-1}}),[a,y,f,v,h,b,m,O,l,g]),l?{}:j};export{f as useResponsivity};
2
2
  //# sourceMappingURL=useResponsivity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useResponsivity.js","sources":["../../../../src/componentsV2/AppHeader/V3/useResponsivity.tsx"],"sourcesContent":["import { CSSProperties, RefObject, useEffect, useRef, useState } from 'react';\nimport { isEqual, throttle } from 'lodash';\n\nimport CssConstants from './constants.scss';\n\ntype Params = {\n disabled?: boolean;\n titleControlsLeft?: boolean;\n\n rootRef: RefObject<HTMLElement>;\n versionRef: RefObject<HTMLElement>;\n padModeRef: RefObject<HTMLElement>;\n additionalControlsRef: RefObject<HTMLElement>;\n titleControlsRef: RefObject<HTMLElement>;\n chipsRef: RefObject<HTMLElement>;\n logoRef: RefObject<HTMLElement>;\n actionsRef: RefObject<HTMLElement>;\n};\n\ntype ResponsivityDataItem = {\n style?: CSSProperties & Record<`--${string}`, number | string>;\n lastInLine?: boolean;\n};\n\ntype ResponsivityData = {\n root?: ResponsivityDataItem;\n padMode?: ResponsivityDataItem;\n additionalControls?: ResponsivityDataItem;\n titleControls?: ResponsivityDataItem;\n chips?: ResponsivityDataItem;\n actions?: ResponsivityDataItem;\n title?: ResponsivityDataItem;\n\n linebreaks?: CSSProperties[];\n};\n\nconst gap = parseInt(CssConstants.gap, 10);\nconst titleMinWidth = parseInt(CssConstants.titleMinWidth, 10) + gap;\n\nconst getRefWidth = (ref: RefObject<HTMLElement>) => {\n // This causes a reflow, so if it lags too much - use the `ref.current?.offsetWidth + 1`\n // `ref.current?.offsetWidth` rounds pixel fractions so it may produce incorrect results/need adjustment\n return ref.current?.getBoundingClientRect().width || 0;\n};\n\nconst sumLineWidth = (titleMinWidth: number, ...lineRefs: RefObject<HTMLElement>[]) => {\n const filteredRefs = lineRefs.filter(ref => !!ref.current && ref.current.offsetWidth > 0);\n return (\n titleMinWidth +\n filteredRefs.reduce((acc, ref) => acc + getRefWidth(ref), 0) +\n (filteredRefs.length > 1 ? (filteredRefs.length - 1) * gap : 0)\n );\n};\n\n/**\n * Detects when child elements stop fitting in a single header line and returns CSS orders, linebreaks, & other info for header elements\n *\n * There are several possible layouts:\n *\n * 1. Everything fits in one line\n * 2. 2 lines:\n * [logo] [title] [version] [asset chips] [actions]\n * [title controls] [pad mode] [additional controls]\n * and other variants that fit into 2 lines\n * 3. 3 lines:\n * [logo] [title] [version]\n * [title controls] [additional controls] [actions]\n * [pad mode] [chips]\n */\nexport const useResponsivity = ({\n disabled,\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n titleControlsLeft,\n}: Params) => {\n const [value, setValue] = useState<ResponsivityData>({});\n const previousWidthRef = useRef(-1);\n\n useEffect(() => {\n const calculateCss = throttle(\n () => {\n requestAnimationFrame(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n\n const setCss = (baseData: ResponsivityData) => {\n // We need nowrap to properly handle title when app title is very long and we have title controls to the left\n const isNowrap =\n titleControlsLeft &&\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth;\n\n const data = isNowrap\n ? {\n ...baseData,\n root: {\n style: {\n ...baseData.root?.style,\n '--headerV3-responsivity-flexwrap': 'nowrap',\n },\n },\n }\n : baseData;\n\n // Prevent unnecessary rerenders & rerender loop: recalc -> update values -> recalc -> update values to the same values\n setValue(value => (isEqual(value, data) ? value : data));\n };\n\n const getTitleMaxWidthStyle = (...refs: RefObject<HTMLElement>[]) => {\n if (!titleControlsLeft) {\n return undefined;\n }\n\n const pixels = sumLineWidth(0, ...refs) + gap;\n return { '--headerV3-responsivity-maxWidth': `calc(100% - ${pixels}px)` };\n };\n\n // Case 1 - everything fits\n if (\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth\n ) {\n setCss({\n title: { style: { '--headerV3-responsivity-marginRight': 0 } },\n });\n }\n // 2 lines\n // [logo] [title] [version] [asset chips] [actions]\n // [title controls] [pad mode] [additional controls]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef, actionsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n padMode: { style: { '--headerV3-responsivity-order': 120 } },\n additionalControls: {\n style: { '--headerV3-responsivity-order': 130 },\n lastInLine: true,\n },\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef, actionsRef) },\n });\n }\n // 2 lines - no padmode, has chips\n // [logo] [title] [version] [asset chips]\n // [title controls] [additional controls] [actions]\n else if (\n !padModeRef.current &&\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 2 lines:\n // [logo] [title] [version] [chips]\n // [title controls] [additional controls] [pad mode] [actions]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth &&\n sumLineWidth(0, titleControlsRef, additionalControlsRef, padModeRef, actionsRef) <=\n rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n padMode: { style: { '--headerV3-responsivity-order': 130 } },\n actions: { style: { '--headerV3-responsivity-order': 140 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 3 lines\n // [logo] [title] [version]\n // [title controls] [additional controls] [actions]\n // [pad mode] [chips]\n else {\n setCss({\n linebreaks: [{ order: 100 }, { order: 200 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n padMode: { style: { '--headerV3-responsivity-order': 210 } },\n chips: { style: { '--headerV3-responsivity-order': 220 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef) },\n });\n }\n });\n },\n 100,\n { leading: true }\n );\n\n const resizeObserver = new ResizeObserver(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n if (rootWidth !== previousWidthRef.current) {\n calculateCss();\n }\n previousWidthRef.current = rootWidth;\n });\n const mutationObserver = new MutationObserver(calculateCss);\n\n if (rootRef.current && !disabled) {\n resizeObserver.observe(rootRef.current);\n mutationObserver.observe(rootRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n calculateCss.cancel();\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, [\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n disabled,\n titleControlsLeft,\n ]);\n\n return disabled ? {} : value;\n};\n"],"names":["gap","parseInt","CssConstants","titleMinWidth","getRefWidth","ref","_ref$current","current","getBoundingClientRect","width","sumLineWidth","_len","arguments","length","lineRefs","Array","_key","filteredRefs","filter","offsetWidth","reduce","acc","useResponsivity","_ref","disabled","actionsRef","chipsRef","logoRef","rootRef","titleControlsRef","additionalControlsRef","versionRef","padModeRef","titleControlsLeft","_useState","useState","_useState2","_slicedToArray","value","setValue","previousWidthRef","useRef","useEffect","calculateCss","throttle","requestAnimationFrame","_rootRef$current","rootWidth","setCss","baseData","_baseData$root","data","_objectSpread","root","style","isEqual","getTitleMaxWidthStyle","_len2","refs","_key2","pixels","apply","title","linebreaks","order","titleControls","padMode","additionalControls","lastInLine","actions","chips","leading","resizeObserver","ResizeObserver","_rootRef$current2","mutationObserver","MutationObserver","observe","childList","subtree","characterData","cancel","disconnect"],"mappings":"szBAoCA,IAAMA,EAAMC,SAASC,EAAaF,IAAK,IACjCG,EAAgBF,SAASC,EAAaC,cAAe,IAAMH,EAE3DI,EAAc,SAACC,GAAgC,IAAAC,EAGnD,OAAkB,QAAXA,EAAAD,EAAIE,eAAO,IAAAD,OAAA,EAAXA,EAAaE,wBAAwBC,QAAS,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C,MACrDe,QAAS,CAAEf,MAAO,CAAE,gCAAiC,KAAOc,YAAY,GAExEN,MAAO,CAAER,MAAOE,EAAsB7B,EAASI,EAAYL,MAQ7DsB,EAAO,CACLe,WAAY,CAAC,CAAEC,MAAO,KAAO,CAAEA,MAAO,MACtCC,cAAe,CAAEX,MAAO,CAAE,gCAAiC,MAC3Da,mBAAoB,CAAEb,MAAO,CAAE,gCAAiC,MAChEe,QAAS,CAAEf,MAAO,CAAE,gCAAiC,KAAOc,YAAY,GACxEF,QAAS,CAAEZ,MAAO,CAAE,gCAAiC,MACrDgB,MAAO,CAAEhB,MAAO,CAAE,gCAAiC,KAAOc,YAAY,GAEtEN,MAAO,CAAER,MAAOE,EAAsB7B,EAASI,KAGrD,GACD,GACD,IACA,CAAEwC,SAAS,IAGPC,EAAiB,IAAIC,gBAAe,WAAM,IAAAC,EACxC3B,GAAY,QAAA2B,EAAA9C,EAAQrB,eAAR,IAAAmE,OAAA,EAAAA,EAAiBvD,cAAe,EAC9C4B,IAAcP,EAAiBjC,SACjCoC,IAEFH,EAAiBjC,QAAUwC,CAC7B,IACM4B,EAAmB,IAAIC,iBAAiBjC,GAY9C,OAVIf,EAAQrB,UAAYiB,IACtBgD,EAAeK,QAAQjD,EAAQrB,SAC/BoE,EAAiBE,QAAQjD,EAAQrB,QAAS,CACxCuE,WAAW,EACXC,SAAS,EACTC,eAAe,IAEjBrC,EAAasC,UAGR,WACLT,EAAeU,aACfP,EAAiBO,aAEpB,GAAE,CACDzD,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAR,EACAS,IAGKT,EAAW,CAAE,EAAGc,CACzB"}
1
+ {"version":3,"file":"useResponsivity.js","sources":["../../../../src/componentsV2/AppHeader/V3/useResponsivity.tsx"],"sourcesContent":["import { CSSProperties, RefObject, useEffect, useRef, useState } from 'react';\nimport { isEqual, throttle } from 'lodash';\n\nimport CssConstants from './constants.scss';\n\ntype Params = {\n disabled?: boolean;\n titleControlsLeft?: boolean;\n\n rootRef: RefObject<HTMLElement>;\n versionRef: RefObject<HTMLElement>;\n padModeRef: RefObject<HTMLElement>;\n additionalControlsRef: RefObject<HTMLElement>;\n titleControlsRef: RefObject<HTMLElement>;\n chipsRef: RefObject<HTMLElement>;\n logoRef: RefObject<HTMLElement>;\n actionsRef: RefObject<HTMLElement>;\n};\n\ntype ResponsivityDataItem = {\n style?: CSSProperties & Record<`--${string}`, number | string>;\n lastInLine?: boolean;\n};\n\ntype ResponsivityData = {\n root?: ResponsivityDataItem;\n padMode?: ResponsivityDataItem;\n additionalControls?: ResponsivityDataItem;\n titleControls?: ResponsivityDataItem;\n chips?: ResponsivityDataItem;\n actions?: ResponsivityDataItem;\n title?: ResponsivityDataItem;\n\n linebreaks?: CSSProperties[];\n};\n\nconst gap = parseInt(CssConstants.gap, 10);\nconst titleMinWidth = parseInt(CssConstants.titleMinWidth, 10) + gap;\n\nconst getRefWidth = (ref: RefObject<HTMLElement>) => {\n // This causes a reflow, so if it lags too much - use the `ref.current?.offsetWidth + 1`\n // `ref.current?.offsetWidth` rounds pixel fractions so it may produce incorrect results/need adjustment\n return ref.current?.getBoundingClientRect().width || 0;\n};\n\nconst sumLineWidth = (titleMinWidth: number, ...lineRefs: RefObject<HTMLElement>[]) => {\n const filteredRefs = lineRefs.filter(ref => !!ref.current && ref.current.offsetWidth > 0);\n return (\n titleMinWidth +\n filteredRefs.reduce((acc, ref) => acc + getRefWidth(ref), 0) +\n (filteredRefs.length > 1 ? (filteredRefs.length - 1) * gap : 0)\n );\n};\n\n/**\n * Detects when child elements stop fitting in a single header line and returns CSS orders, linebreaks, & other info for header elements\n *\n * There are several possible layouts:\n *\n * 1. Everything fits in one line\n * 2. 2 lines:\n * [logo] [title] [version] [asset chips] [actions]\n * [title controls] [pad mode] [additional controls]\n * and other variants that fit into 2 lines\n * 3. 3 lines:\n * [logo] [title] [version]\n * [title controls] [additional controls] [actions]\n * [pad mode] [chips]\n */\nexport const useResponsivity = ({\n disabled,\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n titleControlsLeft,\n}: Params) => {\n const [value, setValue] = useState<ResponsivityData>({});\n const previousWidthRef = useRef(-1);\n\n useEffect(() => {\n const calculateCss = throttle(\n () => {\n requestAnimationFrame(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n\n const setCss = (baseData: ResponsivityData) => {\n // We need nowrap to properly handle title when app title is very long and we have title controls to the left\n const isNowrap =\n titleControlsLeft &&\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth;\n\n const data = isNowrap\n ? {\n ...baseData,\n root: {\n style: {\n ...baseData.root?.style,\n '--headerV3-responsivity-flexwrap': 'nowrap',\n },\n },\n }\n : baseData;\n\n // Prevent unnecessary rerenders & rerender loop: recalc -> update values -> recalc -> update values to the same values\n setValue(value => (isEqual(value, data) ? value : data));\n };\n\n const getTitleMaxWidthStyle = (...refs: RefObject<HTMLElement>[]) => {\n if (!titleControlsLeft) {\n return undefined;\n }\n\n const pixels = sumLineWidth(0, ...refs) + gap;\n return { '--headerV3-responsivity-maxWidth': `calc(100% - ${pixels}px)` };\n };\n\n // Case 1 - everything fits\n if (\n sumLineWidth(\n titleMinWidth,\n logoRef,\n versionRef,\n chipsRef,\n actionsRef,\n titleControlsRef,\n additionalControlsRef,\n padModeRef\n ) <= rootWidth\n ) {\n setCss({\n title: { style: { '--headerV3-responsivity-marginRight': 0 } },\n });\n }\n // 2 lines\n // [logo] [title] [version] [asset chips] [actions]\n // [title controls] [pad mode] [additional controls]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef, actionsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n padMode: { style: { '--headerV3-responsivity-order': 120 } },\n additionalControls: {\n style: { '--headerV3-responsivity-order': 130 },\n lastInLine: true,\n },\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef, actionsRef) },\n });\n }\n // 2 lines - no padmode, has chips\n // [logo] [title] [version] [asset chips]\n // [title controls] [additional controls] [actions]\n else if (\n !padModeRef.current &&\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 2 lines:\n // [logo] [title] [version] [chips]\n // [title controls] [additional controls] [pad mode] [actions]\n else if (\n sumLineWidth(titleMinWidth, logoRef, versionRef, chipsRef) <= rootWidth &&\n sumLineWidth(0, titleControlsRef, additionalControlsRef, padModeRef, actionsRef) <=\n rootWidth\n ) {\n setCss({\n linebreaks: [{ order: 100 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n padMode: { style: { '--headerV3-responsivity-order': 130 } },\n actions: { style: { '--headerV3-responsivity-order': 140 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef, chipsRef) },\n });\n }\n // 3 lines\n // [logo] [title] [version]\n // [title controls] [additional controls] [actions]\n // [pad mode] [chips]\n else {\n setCss({\n linebreaks: [{ order: 100 }, { order: 200 }],\n titleControls: { style: { '--headerV3-responsivity-order': 110 } },\n additionalControls: { style: { '--headerV3-responsivity-order': 120 } },\n actions: { style: { '--headerV3-responsivity-order': 130 }, lastInLine: true },\n padMode: { style: { '--headerV3-responsivity-order': 210 } },\n chips: { style: { '--headerV3-responsivity-order': 220 }, lastInLine: true },\n\n title: { style: getTitleMaxWidthStyle(logoRef, versionRef) },\n });\n }\n });\n },\n 100,\n { leading: true }\n );\n\n const resizeObserver = new ResizeObserver(() => {\n const rootWidth = rootRef.current?.offsetWidth || 0;\n if (rootWidth !== previousWidthRef.current) {\n calculateCss();\n }\n previousWidthRef.current = rootWidth;\n });\n const mutationObserver = new MutationObserver(calculateCss);\n\n if (rootRef.current && !disabled) {\n resizeObserver.observe(rootRef.current);\n mutationObserver.observe(rootRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n calculateCss.cancel();\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n calculateCss.cancel();\n previousWidthRef.current = -1;\n };\n }, [\n actionsRef,\n chipsRef,\n logoRef,\n rootRef,\n titleControlsRef,\n additionalControlsRef,\n versionRef,\n padModeRef,\n disabled,\n titleControlsLeft,\n ]);\n\n return disabled ? {} : value;\n};\n"],"names":["gap","parseInt","CssConstants","titleMinWidth","getRefWidth","ref","_ref$current","current","getBoundingClientRect","width","sumLineWidth","_len","arguments","length","lineRefs","Array","_key","filteredRefs","filter","offsetWidth","reduce","acc","useResponsivity","_ref","disabled","actionsRef","chipsRef","logoRef","rootRef","titleControlsRef","additionalControlsRef","versionRef","padModeRef","titleControlsLeft","_useState","useState","_useState2","_slicedToArray","value","setValue","previousWidthRef","useRef","useEffect","calculateCss","throttle","requestAnimationFrame","_rootRef$current","rootWidth","setCss","baseData","_baseData$root","data","_objectSpread","root","style","isEqual","getTitleMaxWidthStyle","_len2","refs","_key2","pixels","apply","title","linebreaks","order","titleControls","padMode","additionalControls","lastInLine","actions","chips","leading","resizeObserver","ResizeObserver","_rootRef$current2","mutationObserver","MutationObserver","observe","childList","subtree","characterData","cancel","disconnect"],"mappings":"szBAoCA,IAAMA,EAAMC,SAASC,EAAaF,IAAK,IACjCG,EAAgBF,SAASC,EAAaC,cAAe,IAAMH,EAE3DI,EAAc,SAACC,GAAgC,IAAAC,EAGnD,OAAkB,QAAXA,EAAAD,EAAIE,eAAO,IAAAD,OAAA,EAAXA,EAAaE,wBAAwBC,QAAS,CACvD,EAEMC,EAAe,S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f,MAAO,CAAE,gCAAiC,KAAOc,YAAY,GAExEN,MAAO,CAAER,MAAOE,EAAsB7B,EAASI,EAAYL,MAQ7DsB,EAAO,CACLe,WAAY,CAAC,CAAEC,MAAO,KAAO,CAAEA,MAAO,MACtCC,cAAe,CAAEX,MAAO,CAAE,gCAAiC,MAC3Da,mBAAoB,CAAEb,MAAO,CAAE,gCAAiC,MAChEe,QAAS,CAAEf,MAAO,CAAE,gCAAiC,KAAOc,YAAY,GACxEF,QAAS,CAAEZ,MAAO,CAAE,gCAAiC,MACrDgB,MAAO,CAAEhB,MAAO,CAAE,gCAAiC,KAAOc,YAAY,GAEtEN,MAAO,CAAER,MAAOE,EAAsB7B,EAASI,KAGrD,GACD,GACD,IACA,CAAEwC,SAAS,IAGPC,EAAiB,IAAIC,gBAAe,WAAM,IAAAC,EACxC3B,GAAY,QAAA2B,EAAA9C,EAAQrB,eAAR,IAAAmE,OAAA,EAAAA,EAAiBvD,cAAe,EAC9C4B,IAAcP,EAAiBjC,SACjCoC,IAEFH,EAAiBjC,QAAUwC,CAC7B,IACM4B,EAAmB,IAAIC,iBAAiBjC,GAY9C,OAVIf,EAAQrB,UAAYiB,IACtBgD,EAAeK,QAAQjD,EAAQrB,SAC/BoE,EAAiBE,QAAQjD,EAAQrB,QAAS,CACxCuE,WAAW,EACXC,SAAS,EACTC,eAAe,IAEjBrC,EAAasC,UAGR,WACLT,EAAeU,aACfP,EAAiBO,aACjBvC,EAAasC,SACbzC,EAAiBjC,SAAW,EAE/B,GAAE,CACDkB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAR,EACAS,IAGKT,EAAW,CAAE,EAAGc,CACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextEndTruncated.d.ts","sourceRoot":"","sources":["../../../src/componentsV2/TextEndTruncated/TextEndTruncated.tsx"],"names":[],"mappings":"AAQA,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+DAM1B,qBAAqB,4CA2DvB,CAAC"}
1
+ {"version":3,"file":"TextEndTruncated.d.ts","sourceRoot":"","sources":["../../../src/componentsV2/TextEndTruncated/TextEndTruncated.tsx"],"names":[],"mappings":"AAQA,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,+DAM1B,qBAAqB,4CA4DvB,CAAC"}
@@ -1,2 +1,2 @@
1
- import e from"@babel/runtime/helpers/slicedToArray";import r from"classnames";import{useRef as t,useState as i,useLayoutEffect as n}from"react";import{debounce as o}from"lodash";import{Tooltip as s}from"../Tooltip/Tooltip.js";import c from"./TextEndTruncated.scss.js";import{jsx as l}from"react/jsx-runtime";var a=function(a){var m=a.children,u=a.disableTooltip,d=a.maxLines,f=void 0===d?1:d,p=a.testId,h=a.className,v=f>1,b=t(null),T=t(v),x=i(null),L=e(x,2),g=L[0],j=L[1],W=i(!0),w=e(W,2),y=w[0],A=w[1];return T.current=v,n((function(){var e=o((function(){requestAnimationFrame((function(){var e=b.current;e&&(j(e.textContent),A(e.scrollWidth<=e.clientWidth&&(e.scrollHeight<=e.clientHeight||!T.current)))}))}),200),r=new ResizeObserver(e),t=new MutationObserver(e);return b.current&&(r.observe(b.current),t.observe(b.current,{childList:!0,subtree:!0,characterData:!0})),function(){r.disconnect(),t.disconnect()}}),[]),l(s,{title:g,disabled:y||u,children:l("div",{className:r(c.root,v?c.multiLine:c.singleLine,h),style:v?{WebkitLineClamp:f}:void 0,ref:b,"data-testid":p,children:m})})};export{a as TextEndTruncated};
1
+ import e from"@babel/runtime/helpers/slicedToArray";import r from"classnames";import{useRef as t,useState as i,useLayoutEffect as n}from"react";import{debounce as o}from"lodash";import{Tooltip as c}from"../Tooltip/Tooltip.js";import s from"./TextEndTruncated.scss.js";import{jsx as l}from"react/jsx-runtime";var a=function(a){var m=a.children,u=a.disableTooltip,d=a.maxLines,f=void 0===d?1:d,p=a.testId,h=a.className,v=f>1,b=t(null),T=t(v),x=i(null),L=e(x,2),g=L[0],j=L[1],W=i(!0),w=e(W,2),y=w[0],A=w[1];return T.current=v,n((function(){var e=o((function(){requestAnimationFrame((function(){var e=b.current;e&&(j(e.textContent),A(e.scrollWidth<=e.clientWidth&&(e.scrollHeight<=e.clientHeight||!T.current)))}))}),200),r=new ResizeObserver(e),t=new MutationObserver(e);return b.current&&(r.observe(b.current),t.observe(b.current,{childList:!0,subtree:!0,characterData:!0})),function(){r.disconnect(),t.disconnect(),e.cancel()}}),[]),l(c,{title:g,disabled:y||u,children:l("div",{className:r(s.root,v?s.multiLine:s.singleLine,h),style:v?{WebkitLineClamp:f}:void 0,ref:b,"data-testid":p,children:m})})};export{a as TextEndTruncated};
2
2
  //# sourceMappingURL=TextEndTruncated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextEndTruncated.js","sources":["../../../src/componentsV2/TextEndTruncated/TextEndTruncated.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useLayoutEffect, useRef, useState } from 'react';\nimport { debounce } from 'lodash';\n\nimport { Tooltip } from '../Tooltip';\n\nimport styles from './TextEndTruncated.scss';\n\nexport type TextEndTruncatedProps = {\n /**\n * Content\n */\n children?: React.ReactNode;\n /**\n * Forces the component not to show its tooltip\n */\n disableTooltip?: boolean;\n maxLines?: number;\n\n className?: string;\n testId?: string;\n};\n\nexport const TextEndTruncated = ({\n children,\n disableTooltip,\n maxLines = 1,\n testId,\n className,\n}: TextEndTruncatedProps) => {\n const isMultiline = maxLines > 1;\n const containerRef = useRef<HTMLDivElement>(null);\n const multilineRef = useRef<boolean>(isMultiline);\n const [tooltipContent, setTooltipContent] = useState<string | null>(null);\n const [dimensionsDisabled, setDimensionsDisabled] = useState(true);\n\n multilineRef.current = isMultiline;\n\n useLayoutEffect(() => {\n const onDimensionsOrContentChange = debounce(() => {\n requestAnimationFrame(() => {\n const container = containerRef.current;\n if (container) {\n setTooltipContent(container.textContent);\n setDimensionsDisabled(\n container.scrollWidth <= container.clientWidth &&\n // multilineRef is needed to handle an edgecase when there's a `lineHeight` that's smaller than the space needed to render a font, so\n // `scrollHeight` is bigger than `clientHeight`\n (container.scrollHeight <= container.clientHeight || !multilineRef.current)\n );\n }\n });\n }, 200);\n\n const resizeObserver = new ResizeObserver(onDimensionsOrContentChange);\n const mutationObserver = new MutationObserver(onDimensionsOrContentChange);\n\n if (containerRef.current /* && innerRef.current */) {\n resizeObserver.observe(containerRef.current);\n mutationObserver.observe(containerRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n }, []);\n\n return (\n <Tooltip title={tooltipContent} disabled={dimensionsDisabled || disableTooltip}>\n <div\n className={classNames(\n styles.root,\n isMultiline ? styles.multiLine : styles.singleLine,\n className\n )}\n style={isMultiline ? { WebkitLineClamp: maxLines } : undefined}\n ref={containerRef}\n data-testid={testId}\n >\n {children}\n </div>\n </Tooltip>\n );\n};\n"],"names":["TextEndTruncated","_ref","children","disableTooltip","_ref$maxLines","maxLines","testId","className","isMultiline","containerRef","useRef","multilineRef","useState","_useState2","_slicedToArray","_useState","tooltipContent","setTooltipContent","_useState4","_useState3","dimensionsDisabled","setDimensionsDisabled","current","useLayoutEffect","onDimensionsOrContentChange","debounce","requestAnimationFrame","container","textContent","scrollWidth","clientWidth","scrollHeight","clientHeight","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observe","childList","subtree","characterData","disconnect","_jsx","Tooltip","title","disabled","classNames","styles","root","multiLine","singleLine","style","WebkitLineClamp","undefined","ref"],"mappings":"oTAuBaA,IAAAA,EAAmB,SAMHC,GAAA,IAL3BC,IAAAA,SACAC,IAAAA,eAAcC,EAAAH,EACdI,SAAAA,aAAW,EAACD,EACZE,IAAAA,OACAC,IAAAA,UAEMC,EAAcH,EAAW,EACzBI,EAAeC,EAAuB,MACtCC,EAAeD,EAAgBF,GACOI,EAAAA,EAAwB,MAAKC,EAAAC,EAAAC,EAAA,GAAlEC,EAAcH,EAAA,GAAEI,EAAiBJ,EAAA,GACYD,EAAAA,GAAS,GAAKM,EAAAJ,EAAAK,EAAA,GAA3DC,EAAkBF,EAAA,GAAEG,EAAqBH,EAAA,GAsChD,OApCAP,EAAaW,QAAUd,EAEvBe,GAAgB,WACd,IAAMC,EAA8BC,GAAS,WAC3CC,uBAAsB,WACpB,IAAMC,EAAYlB,EAAaa,QAC3BK,IACFV,EAAkBU,EAAUC,aAC5BP,EACEM,EAAUE,aAAeF,EAAUG,cAGhCH,EAAUI,cAAgBJ,EAAUK,eAAiBrB,EAAaW,UAG3E,GACD,GAAE,KAEGW,EAAiB,IAAIC,eAAeV,GACpCW,EAAmB,IAAIC,iBAAiBZ,GAW9C,OATIf,EAAaa,UACfW,EAAeI,QAAQ5B,EAAaa,SACpCa,EAAiBE,QAAQ5B,EAAaa,QAAS,CAC7CgB,WAAW,EACXC,SAAS,EACTC,eAAe,KAIZ,WACLP,EAAeQ,aACfN,EAAiBM,aAEpB,GAAE,IAGDC,EAACC,EAAO,CAACC,MAAO5B,EAAgB6B,SAAUzB,GAAsBjB,EAAeD,SAC7EwC,EAAA,MAAA,CACEnC,UAAWuC,EACTC,EAAOC,KACPxC,EAAcuC,EAAOE,UAAYF,EAAOG,WACxC3C,GAEF4C,MAAO3C,EAAc,CAAE4C,gBAAiB/C,QAAagD,EACrDC,IAAK7C,EACL,cAAaH,EAAOJ,SAEnBA,KAIT"}
1
+ {"version":3,"file":"TextEndTruncated.js","sources":["../../../src/componentsV2/TextEndTruncated/TextEndTruncated.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useLayoutEffect, useRef, useState } from 'react';\nimport { debounce } from 'lodash';\n\nimport { Tooltip } from '../Tooltip';\n\nimport styles from './TextEndTruncated.scss';\n\nexport type TextEndTruncatedProps = {\n /**\n * Content\n */\n children?: React.ReactNode;\n /**\n * Forces the component not to show its tooltip\n */\n disableTooltip?: boolean;\n maxLines?: number;\n\n className?: string;\n testId?: string;\n};\n\nexport const TextEndTruncated = ({\n children,\n disableTooltip,\n maxLines = 1,\n testId,\n className,\n}: TextEndTruncatedProps) => {\n const isMultiline = maxLines > 1;\n const containerRef = useRef<HTMLDivElement>(null);\n const multilineRef = useRef<boolean>(isMultiline);\n const [tooltipContent, setTooltipContent] = useState<string | null>(null);\n const [dimensionsDisabled, setDimensionsDisabled] = useState(true);\n\n multilineRef.current = isMultiline;\n\n useLayoutEffect(() => {\n const onDimensionsOrContentChange = debounce(() => {\n requestAnimationFrame(() => {\n const container = containerRef.current;\n if (container) {\n setTooltipContent(container.textContent);\n setDimensionsDisabled(\n container.scrollWidth <= container.clientWidth &&\n // multilineRef is needed to handle an edgecase when there's a `lineHeight` that's smaller than the space needed to render a font, so\n // `scrollHeight` is bigger than `clientHeight`\n (container.scrollHeight <= container.clientHeight || !multilineRef.current)\n );\n }\n });\n }, 200);\n\n const resizeObserver = new ResizeObserver(onDimensionsOrContentChange);\n const mutationObserver = new MutationObserver(onDimensionsOrContentChange);\n\n if (containerRef.current /* && innerRef.current */) {\n resizeObserver.observe(containerRef.current);\n mutationObserver.observe(containerRef.current, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n onDimensionsOrContentChange.cancel();\n };\n }, []);\n\n return (\n <Tooltip title={tooltipContent} disabled={dimensionsDisabled || disableTooltip}>\n <div\n className={classNames(\n styles.root,\n isMultiline ? styles.multiLine : styles.singleLine,\n className\n )}\n style={isMultiline ? { WebkitLineClamp: maxLines } : undefined}\n ref={containerRef}\n data-testid={testId}\n >\n {children}\n </div>\n </Tooltip>\n );\n};\n"],"names":["TextEndTruncated","_ref","children","disableTooltip","_ref$maxLines","maxLines","testId","className","isMultiline","containerRef","useRef","multilineRef","useState","_useState2","_slicedToArray","_useState","tooltipContent","setTooltipContent","_useState4","_useState3","dimensionsDisabled","setDimensionsDisabled","current","useLayoutEffect","onDimensionsOrContentChange","debounce","requestAnimationFrame","container","textContent","scrollWidth","clientWidth","scrollHeight","clientHeight","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observe","childList","subtree","characterData","disconnect","cancel","_jsx","Tooltip","title","disabled","classNames","styles","root","multiLine","singleLine","style","WebkitLineClamp","undefined","ref"],"mappings":"oTAuBaA,IAAAA,EAAmB,SAMHC,GAAA,IAL3BC,IAAAA,SACAC,IAAAA,eAAcC,EAAAH,EACdI,SAAAA,aAAW,EAACD,EACZE,IAAAA,OACAC,IAAAA,UAEMC,EAAcH,EAAW,EACzBI,EAAeC,EAAuB,MACtCC,EAAeD,EAAgBF,GACOI,EAAAA,EAAwB,MAAKC,EAAAC,EAAAC,EAAA,GAAlEC,EAAcH,EAAA,GAAEI,EAAiBJ,EAAA,GACYD,EAAAA,GAAS,GAAKM,EAAAJ,EAAAK,EAAA,GAA3DC,EAAkBF,EAAA,GAAEG,EAAqBH,EAAA,GAuChD,OArCAP,EAAaW,QAAUd,EAEvBe,GAAgB,WACd,IAAMC,EAA8BC,GAAS,WAC3CC,uBAAsB,WACpB,IAAMC,EAAYlB,EAAaa,QAC3BK,IACFV,EAAkBU,EAAUC,aAC5BP,EACEM,EAAUE,aAAeF,EAAUG,cAGhCH,EAAUI,cAAgBJ,EAAUK,eAAiBrB,EAAaW,UAG3E,GACD,GAAE,KAEGW,EAAiB,IAAIC,eAAeV,GACpCW,EAAmB,IAAIC,iBAAiBZ,GAW9C,OATIf,EAAaa,UACfW,EAAeI,QAAQ5B,EAAaa,SACpCa,EAAiBE,QAAQ5B,EAAaa,QAAS,CAC7CgB,WAAW,EACXC,SAAS,EACTC,eAAe,KAIZ,WACLP,EAAeQ,aACfN,EAAiBM,aACjBjB,EAA4BkB,SAE/B,GAAE,IAGDC,EAACC,EAAO,CAACC,MAAO7B,EAAgB8B,SAAU1B,GAAsBjB,EAAeD,SAC7EyC,EAAA,MAAA,CACEpC,UAAWwC,EACTC,EAAOC,KACPzC,EAAcwC,EAAOE,UAAYF,EAAOG,WACxC5C,GAEF6C,MAAO5C,EAAc,CAAE6C,gBAAiBhD,QAAaiD,EACrDC,IAAK9C,EACL,cAAaH,EAAOJ,SAEnBA,KAIT"}
@@ -1 +1 @@
1
- {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../src/effects/useResizeObserver.js"],"names":[],"mappings":"AAKA,iBAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAmB,EAAE;;;;CAAA,QAazE;eAEc,iBAAiB"}
1
+ {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../src/effects/useResizeObserver.js"],"names":[],"mappings":"AAKA,iBAAS,iBAAiB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAmB,EAAE;;;;CAAA,QAczE;eAEc,iBAAiB"}
@@ -1,2 +1,2 @@
1
- import{useEffect as r}from"react";import{debounce as e}from"lodash";function n(n){var t=n.callback,o=n.containerRef,c=n.wait,a=void 0===c?100:c;r((function(){var r=e(t,a),n=new ResizeObserver(r);return o.current&&n.observe(o.current),function(){n.disconnect()}}),[t,o])}export{n as default};
1
+ import{useEffect as r}from"react";import{debounce as e}from"lodash";function n(n){var t=n.callback,c=n.containerRef,o=n.wait,a=void 0===o?100:o;r((function(){var r=e(t,a),n=new ResizeObserver(r);return c.current&&n.observe(c.current),function(){n.disconnect(),r.cancel()}}),[t,c])}export{n as default};
2
2
  //# sourceMappingURL=useResizeObserver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useResizeObserver.js","sources":["../../src/effects/useResizeObserver.js"],"sourcesContent":["import { useEffect } from 'react';\nimport { debounce } from 'lodash';\n\nconst DEFAULT_WAIT = 100;\n\nfunction useResizeObserver({ callback, containerRef, wait = DEFAULT_WAIT }) {\n useEffect(() => {\n const debouncedCallback = debounce(callback, wait);\n const resizeObserver = new ResizeObserver(debouncedCallback);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [callback, containerRef]);\n}\n\nexport default useResizeObserver;\n"],"names":["useResizeObserver","_ref","callback","containerRef","_ref$wait","wait","useEffect","debouncedCallback","debounce","resizeObserver","ResizeObserver","current","observe","disconnect"],"mappings":"oEAKA,SAASA,EAAmEC,GAAA,IAA/CC,IAAAA,SAAUC,IAAAA,aAAYC,EAAAH,EAAEI,KAAAA,aAFhC,IAEmDD,EACtEE,GAAU,WACR,IAAMC,EAAoBC,EAASN,EAAUG,GACvCI,EAAiB,IAAIC,eAAeH,GAM1C,OAJIJ,EAAaQ,SACfF,EAAeG,QAAQT,EAAaQ,SAG/B,WACLF,EAAeI,aAEnB,GAAG,CAACX,EAAUC,GAChB"}
1
+ {"version":3,"file":"useResizeObserver.js","sources":["../../src/effects/useResizeObserver.js"],"sourcesContent":["import { useEffect } from 'react';\nimport { debounce } from 'lodash';\n\nconst DEFAULT_WAIT = 100;\n\nfunction useResizeObserver({ callback, containerRef, wait = DEFAULT_WAIT }) {\n useEffect(() => {\n const debouncedCallback = debounce(callback, wait);\n const resizeObserver = new ResizeObserver(debouncedCallback);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n\n return () => {\n resizeObserver.disconnect();\n debouncedCallback.cancel();\n };\n }, [callback, containerRef]);\n}\n\nexport default useResizeObserver;\n"],"names":["useResizeObserver","_ref","callback","containerRef","_ref$wait","wait","useEffect","debouncedCallback","debounce","resizeObserver","ResizeObserver","current","observe","disconnect","cancel"],"mappings":"oEAKA,SAASA,EAAmEC,GAAA,IAA/CC,IAAAA,SAAUC,IAAAA,aAAYC,EAAAH,EAAEI,KAAAA,aAFhC,IAEmDD,EACtEE,GAAU,WACR,IAAMC,EAAoBC,EAASN,EAAUG,GACvCI,EAAiB,IAAIC,eAAeH,GAM1C,OAJIJ,EAAaQ,SACfF,EAAeG,QAAQT,EAAaQ,SAG/B,WACLF,EAAeI,aACfN,EAAkBO,SAEtB,GAAG,CAACZ,EAAUC,GAChB"}