@hitachivantara/uikit-react-core 3.73.0 → 3.74.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.
Files changed (43) hide show
  1. package/dist/Banner/BannerContent/BannerContent.d.ts +2 -2
  2. package/dist/BaseSwitch/BaseSwitch.d.ts +1 -1
  3. package/dist/BaseSwitch/BaseSwitch.js +6 -1
  4. package/dist/BaseSwitch/BaseSwitch.js.map +1 -1
  5. package/dist/BaseSwitch/styles.js +5 -1
  6. package/dist/BaseSwitch/styles.js.map +1 -1
  7. package/dist/ScrollTo/useScrollTo.js +2 -1
  8. package/dist/ScrollTo/useScrollTo.js.map +1 -1
  9. package/dist/ScrollTo/utils.js +39 -6
  10. package/dist/ScrollTo/utils.js.map +1 -1
  11. package/dist/Tag/Tag.js +1 -12
  12. package/dist/Tag/Tag.js.map +1 -1
  13. package/dist/Tag/styles.js +5 -3
  14. package/dist/Tag/styles.js.map +1 -1
  15. package/dist/legacy/Banner/BannerContent/BannerContent.d.ts +2 -2
  16. package/dist/legacy/BaseSwitch/BaseSwitch.d.ts +1 -1
  17. package/dist/legacy/BaseSwitch/BaseSwitch.js +6 -1
  18. package/dist/legacy/BaseSwitch/BaseSwitch.js.map +1 -1
  19. package/dist/legacy/BaseSwitch/styles.js +5 -1
  20. package/dist/legacy/BaseSwitch/styles.js.map +1 -1
  21. package/dist/legacy/ScrollTo/useScrollTo.js +2 -1
  22. package/dist/legacy/ScrollTo/useScrollTo.js.map +1 -1
  23. package/dist/legacy/ScrollTo/utils.js +35 -5
  24. package/dist/legacy/ScrollTo/utils.js.map +1 -1
  25. package/dist/legacy/Tag/Tag.js +3 -14
  26. package/dist/legacy/Tag/Tag.js.map +1 -1
  27. package/dist/legacy/Tag/styles.js +5 -3
  28. package/dist/legacy/Tag/styles.js.map +1 -1
  29. package/dist/modern/Banner/BannerContent/BannerContent.d.ts +2 -2
  30. package/dist/modern/BaseSwitch/BaseSwitch.d.ts +1 -1
  31. package/dist/modern/BaseSwitch/BaseSwitch.js +6 -1
  32. package/dist/modern/BaseSwitch/BaseSwitch.js.map +1 -1
  33. package/dist/modern/BaseSwitch/styles.js +5 -1
  34. package/dist/modern/BaseSwitch/styles.js.map +1 -1
  35. package/dist/modern/ScrollTo/useScrollTo.js +2 -2
  36. package/dist/modern/ScrollTo/useScrollTo.js.map +1 -1
  37. package/dist/modern/ScrollTo/utils.js +32 -6
  38. package/dist/modern/ScrollTo/utils.js.map +1 -1
  39. package/dist/modern/Tag/Tag.js +3 -14
  40. package/dist/modern/Tag/Tag.js.map +1 -1
  41. package/dist/modern/Tag/styles.js +5 -3
  42. package/dist/modern/Tag/styles.js.map +1 -1
  43. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","names":["outlineStyles","switchWidth","thumbPosition","position","left","width","height","styles","theme","root","padding","cursor","switch","switchBase","backgroundColor","transform","opacity","hv","palette","accent","acce1","track","borderRadius","border","atmosphere","atmo2","thumb","atmo1","marginLeft","marginTop","checked","disabled","atmo3","atmo5","focusVisible"],"sources":["../../../src/BaseSwitch/styles.js"],"sourcesContent":["import { outlineStyles } from \"../Focus/styles\";\n\nconst switchWidth = 32;\n\nconst thumbPosition = {\n position: \"relative\",\n left: -9,\n width: 12,\n height: 12,\n};\n\nconst styles = (theme) => ({\n root: {\n padding: 0,\n cursor: \"pointer\",\n },\n\n switch: {\n padding: 0,\n width: switchWidth,\n height: 16,\n },\n\n switchBase: {\n width: switchWidth,\n height: 16,\n padding: 0,\n\n // increase CSS specificity\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n \"&$checked\": {\n transform: \"translateX(16px)\",\n \"& + $track\": {\n opacity: 1,\n backgroundColor: theme.hv.palette.accent.acce1,\n },\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n },\n },\n\n track: {\n opacity: 1,\n borderRadius: 15,\n left: 17,\n height: 16,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo2,\n },\n\n thumb: {\n ...thumbPosition,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo1,\n marginLeft: 2,\n marginTop: 0,\n },\n\n checked: {},\n\n disabled: {\n cursor: \"not-allowed\",\n\n \"& $switch\": {\n cursor: \"not-allowed\",\n },\n\n \"& $thumb\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n },\n\n \"& $switchBase + $track\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n opacity: 1,\n },\n },\n\n focusVisible: {\n borderRadius: \"8px\",\n ...outlineStyles,\n },\n});\n\nexport default styles;\n"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,aAAT,QAA8B,iBAA9B;AAEA,IAAMC,WAAW,GAAG,EAApB;AAEA,IAAMC,aAAa,GAAG;EACpBC,QAAQ,EAAE,UADU;EAEpBC,IAAI,EAAE,CAAC,CAFa;EAGpBC,KAAK,EAAE,EAHa;EAIpBC,MAAM,EAAE;AAJY,CAAtB;;AAOA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;EAAA,OAAY;IACzBC,IAAI,EAAE;MACJC,OAAO,EAAE,CADL;MAEJC,MAAM,EAAE;IAFJ,CADmB;IAMzBC,MAAM,EAAE;MACNF,OAAO,EAAE,CADH;MAENL,KAAK,EAAEJ,WAFD;MAGNK,MAAM,EAAE;IAHF,CANiB;IAYzBO,UAAU,EAAE;MACVR,KAAK,EAAEJ,WADG;MAEVK,MAAM,EAAE,EAFE;MAGVI,OAAO,EAAE,CAHC;MAKV;MACA,WAAW;QACTI,eAAe,EAAE;MADR,CAND;MASV,aAAa;QACXC,SAAS,EAAE,kBADA;QAEX,cAAc;UACZC,OAAO,EAAE,CADG;UAEZF,eAAe,EAAEN,KAAK,CAACS,EAAN,CAASC,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J,GAEPtB,aAFO;EAvEa,CAAZ;AAAA,CAAf;;AA6EA,eAAeO,MAAf"}
1
+ {"version":3,"file":"styles.js","names":["outlineStyles","switchWidth","thumbPosition","position","left","width","height","styles","theme","root","padding","cursor","switch","switchBase","backgroundColor","transform","opacity","hv","palette","accent","acce1","track","borderRadius","border","atmosphere","atmo2","thumb","atmo1","marginLeft","marginTop","checked","disabled","atmo3","atmo5","readOnly","focusVisible"],"sources":["../../../src/BaseSwitch/styles.js"],"sourcesContent":["import { outlineStyles } from \"../Focus/styles\";\n\nconst switchWidth = 32;\n\nconst thumbPosition = {\n position: \"relative\",\n left: -9,\n width: 12,\n height: 12,\n};\n\nconst styles = (theme) => ({\n root: {\n padding: 0,\n cursor: \"pointer\",\n },\n\n switch: {\n padding: 0,\n width: switchWidth,\n height: 16,\n\n \"&$readOnly $switchBase\": {\n cursor: \"default\",\n },\n },\n\n switchBase: {\n width: switchWidth,\n height: 16,\n padding: 0,\n\n // increase CSS specificity\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n \"&$checked\": {\n transform: \"translateX(16px)\",\n \"& + $track\": {\n opacity: 1,\n backgroundColor: theme.hv.palette.accent.acce1,\n },\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n },\n },\n\n track: {\n opacity: 1,\n borderRadius: 15,\n left: 17,\n height: 16,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo2,\n },\n\n thumb: {\n ...thumbPosition,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo1,\n marginLeft: 2,\n marginTop: 0,\n },\n\n checked: {},\n\n disabled: {\n cursor: \"not-allowed\",\n\n \"& $switch\": {\n cursor: \"not-allowed\",\n },\n\n \"& $thumb\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n },\n\n \"& $switchBase + $track\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n opacity: 1,\n },\n },\n\n readOnly: {},\n\n focusVisible: {\n borderRadius: \"8px\",\n ...outlineStyles,\n },\n});\n\nexport default styles;\n"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,aAAT,QAA8B,iBAA9B;AAEA,IAAMC,WAAW,GAAG,EAApB;AAEA,IAAMC,aAAa,GAAG;EACpBC,QAAQ,EAAE,UADU;EAEpBC,IAAI,EAAE,CAAC,CAFa;EAGpBC,KAAK,EAAE,EAHa;EAIpBC,MAAM,EAAE;AAJY,CAAtB;;AAOA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;EAAA,OAAY;IACzBC,IAAI,EAAE;MACJC,OAAO,EAAE,CADL;MAEJC,MAAM,EAAE;IAFJ,CADmB;IAMzBC,MAAM,EAAE;MACNF,OAAO,EAAE,CADH;MAENL,KAAK,EAAEJ,WAFD;MAGNK,MAAM,EAAE,EAHF;MAKN,0BAA0B;QACxBK,MAAM,EAAE;MADgB;IALpB,CANiB;IAgBzBE,UAAU,EAAE;MACVR,KAAK,EAAEJ,WADG;MAEVK,MAAM,EAAE,EAFE;MAGVI,OAAO,EAAE,CAHC;MAKV;MACA,WAAW;QACTI,eAAe,EAAE;MADR,CAND;MASV,aAAa;QACXC,SAAS,EAAE,kBADA;QAEX,cAAc;UACZC,OAAO,EAAE,CADG;UAEZF,eAAe,EAAEN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBC,MAAjB,CAAwBC;QAF7B,CAFH;QAMX,WAAW;UACTN,eAAe,EAAE;QADR;MANA;IATH,CAhBa;IAqCzBO,KAAK,EAAE;MACLL,OAAO,EAAE,CADJ;MAELM,YAAY,EAAE,EAFT;MAGLlB,IAAI,EAAE,EAHD;MAILE,MAAM,EAAE,EAJH;MAKLiB,MAAM,sBAAef,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBC,MAAjB,CAAwBC,KAAvC,CALD;MAMLN,eAAe,EAAEN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BC;IANxC,CArCkB;IA8CzBC,KAAK,kCACAxB,aADA;MAEHqB,MAAM,sBAAef,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBC,MAAjB,CAAwBC,KAAvC,CAFH;MAGHN,eAAe,EAAEN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BG,KAH1C;MAIHC,UAAU,EAAE,CAJT;MAKHC,SAAS,EAAE;IALR,EA9CoB;IAsDzBC,OAAO,EAAE,EAtDgB;IAwDzBC,QAAQ,EAAE;MACRpB,MAAM,EAAE,aADA;MAGR,aAAa;QACXA,MAAM,EAAE;MADG,CAHL;MAOR,YAAY;QACVG,eAAe,YAAKN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BQ,KAAjC,CADL;QAEVT,MAAM,sBAAef,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BS,KAA3C;MAFI,CAPJ;MAYR,0BAA0B;QACxBnB,eAAe,YAAKN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BQ,KAAjC,CADS;QAExBT,MAAM,sBAAef,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BS,KAA3C,CAFkB;QAGxBjB,OAAO,EAAE;MAHe;IAZlB,CAxDe;IA2EzBkB,QAAQ,EAAE,EA3Ee;IA6EzBC,YAAY;MACVb,YAAY,EAAE;IADJ,GAEPtB,aAFO;EA7Ea,CAAZ;AAAA,CAAf;;AAmFA,eAAeO,MAAf"}
@@ -13,6 +13,7 @@ var useScrollTo = function useScrollTo() {
13
13
  var offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
14
14
  var options = arguments.length > 4 ? arguments[4] : undefined;
15
15
  var onChange = arguments.length > 5 ? arguments[5] : undefined;
16
+ var direction = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : "column";
16
17
  var RETRY_MAX = 5;
17
18
 
18
19
  var _useState = useState(selectedIndexProp),
@@ -133,7 +134,7 @@ var useScrollTo = function useScrollTo() {
133
134
  var ele = document.getElementById(id);
134
135
 
135
136
  if (ele) {
136
- scrollElement(ele, scrollEle.current, option.offset || offset);
137
+ scrollElement(ele, scrollEle.current, option.offset || offset, direction);
137
138
  }
138
139
 
139
140
  if (href) {
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollTo.js","names":["useEffect","useRef","useState","useCallback","verticalScrollOffset","findFirstVisibleElement","isScrolledToTheBottom","getScrollTop","scrollElement","useScrollTo","selectedIndexProp","scrollElementId","href","offset","options","onChange","RETRY_MAX","selectedIndex","setSelectedIndex","scrollEle","requestedAnimationFrame","lastContainerScrollTop","selectedIndexRef","current","document","getElementById","window","checkScroll","event","requestAnimationFrame","firstVisibleElementIndex","newSelectedIndex","length","containerScrollTop","isScrollingDown","addEventListener","removeEventListener","cancelAnimationFrame","checkRenderedInterval","hashValue","location","hash","split","option","find","o","value","retry","setInterval","ele","clearInterval","setScrollTo","id","index","wrappedOnChange","history","pushState"],"sources":["../../../src/ScrollTo/useScrollTo.js"],"sourcesContent":["import { useEffect, useRef, useState, useCallback } from \"react\";\nimport {\n verticalScrollOffset,\n findFirstVisibleElement,\n isScrolledToTheBottom,\n getScrollTop,\n scrollElement,\n} from \"./utils\";\n\nconst useScrollTo = (\n selectedIndexProp = 0,\n scrollElementId,\n href,\n offset = 0,\n options,\n onChange\n) => {\n const RETRY_MAX = 5;\n const [selectedIndex, setSelectedIndex] = useState(selectedIndexProp);\n\n const scrollEle = useRef();\n const requestedAnimationFrame = useRef(0);\n const lastContainerScrollTop = useRef();\n\n // ref to use a often-changing value in useCallback, as recommended in\n // https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n const selectedIndexRef = useRef(selectedIndex);\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n scrollEle.current = (scrollElementId && document.getElementById(scrollElementId)) || window;\n lastContainerScrollTop.current = verticalScrollOffset(scrollEle.current);\n }, [scrollElementId]);\n\n const checkScroll = useCallback(\n (event) => {\n if (requestedAnimationFrame.current === 0 && window?.requestAnimationFrame) {\n requestedAnimationFrame.current = window.requestAnimationFrame(() => {\n requestedAnimationFrame.current = 0;\n\n const firstVisibleElementIndex = findFirstVisibleElement(\n scrollEle.current,\n options,\n offset\n );\n\n let newSelectedIndex = firstVisibleElementIndex;\n\n // select the first element when all elements are bellow the container's top\n if (firstVisibleElementIndex < 0) {\n newSelectedIndex = 0;\n }\n\n // if the user has reached the bottom of the container, select the first nav item still visible\n // (usually this selects the last nav item, when it can't reach the top the container)\n // in theory only needed when scrolling down, but no... because of the Safari bouncing behaviour\n if (newSelectedIndex < options.length - 1 && isScrolledToTheBottom(scrollEle.current)) {\n newSelectedIndex += 1;\n }\n\n const containerScrollTop = getScrollTop(scrollEle.current);\n const isScrollingDown = containerScrollTop > lastContainerScrollTop.current;\n lastContainerScrollTop.current = containerScrollTop;\n\n // only update the selected item if the scroll direction is moving away from it\n if (isScrollingDown) {\n if (newSelectedIndex < selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n } else if (newSelectedIndex > selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n\n setSelectedIndex(newSelectedIndex);\n onChange?.(event, newSelectedIndex);\n });\n }\n },\n [offset, options, onChange]\n );\n\n // registers and unregisters the scroll listener\n useEffect(() => {\n if (scrollEle.current) {\n scrollEle.current.addEventListener(\"scroll\", checkScroll, false);\n }\n\n return () => {\n if (scrollEle.current) {\n scrollEle.current.removeEventListener(\"scroll\", checkScroll);\n }\n\n if (requestedAnimationFrame.current !== 0) {\n window.cancelAnimationFrame(requestedAnimationFrame.current);\n requestedAnimationFrame.current = 0;\n }\n };\n }, [checkScroll]);\n\n // waits for the elements to be rendered and scrolls to the one referenced\n // in the URL hash, if any\n useEffect(() => {\n let checkRenderedInterval;\n\n if (href) {\n const hashValue = document.location.hash.split(\"#\")[1] || \"\";\n\n const option = options.find((o) => o.value === hashValue);\n\n if (option) {\n let retry = 0;\n checkRenderedInterval = setInterval(() => {\n const ele = document.getElementById(option.value);\n\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n clearInterval(checkRenderedInterval);\n } else {\n retry += 1;\n if (retry === RETRY_MAX) {\n clearInterval(checkRenderedInterval);\n }\n }\n }, 1000);\n }\n }\n\n return () => {\n clearInterval(checkRenderedInterval);\n };\n\n // we really want to run this just in the first load\n // in fact this doesn't even belong here, the logic should be external\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const setScrollTo = (event, id, index, wrappedOnChange) => {\n const option = options.find((o) => o.value === id);\n\n if (option) {\n const ele = document.getElementById(id);\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n }\n\n if (href) {\n window.history.pushState({}, \"\", `#${options[index].value}`);\n }\n\n setSelectedIndex(index);\n wrappedOnChange?.(index);\n\n // Safari scrolls immediately (no smooth scroll support),\n // so this ref value must be updated asap\n selectedIndexRef.current = index;\n }\n };\n\n return [selectedIndex, setScrollTo];\n};\n\nexport default useScrollTo;\n"],"mappings":";;;;;AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,EAAsCC,WAAtC,QAAyD,OAAzD;AACA,SACEC,oBADF,EAEEC,uBAFF,EAGEC,qBAHF,EAIEC,YAJF,EAKEC,aALF,QAMO,SANP;;AAQA,IAAMC,WAAW,GAAG,SAAdA,WAAc,GAOf;EAAA,IANHC,iBAMG,uEANiB,CAMjB;EAAA,IALHC,eAKG;EAAA,IAJHC,IAIG;EAAA,IAHHC,MAGG,uEAHM,CAGN;EAAA,IAFHC,OAEG;EAAA,IADHC,QACG;EACH,IAAMC,SAAS,GAAG,CAAlB;;EACA,gBAA0Cd,QAAQ,CAACQ,iBAAD,CAAlD;EAAA;EAAA,IAAOO,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AAf;;IAEA,IAAIT,MAAJ,EAAY;MACV,IAAMM,GAAG,GAAGzB,QAAQ,CAACC,cAAT,CAAwB2B,EAAxB,CAAZ;;MACA,IAAIH,GAAJ,EAAS;QACPzC,aAAa,CAACyC,GAAD,EAAM9B,SAAS,CAACI,OAAhB,EAAyBoB,MAAM,CAAC9B,MAAP,IAAiBA,MAA1C,CAAb;MACD;;MAED,IAAID,IAAJ,EAAU;QACRc,MAAM,CAAC6B,OAAP,CAAeC,SAAf,CAAyB,EAAzB,EAA6B,EAA7B,aAAqC1C,OAAO,CAACuC,KAAD,CAAP,CAAeP,KAApD;MACD;;MAED5B,gBAAgB,CAACmC,KAAD,CAAhB;MACAC,eAAe,SAAf,IAAAA,eAAe,WAAf,YAAAA,eAAe,CAAGD,KAAH,CAAf,CAXU,CAaV;MACA;;MACA/B,gBAAgB,CAACC,OAAjB,GAA2B8B,KAA3B;IACD;EACF,CApBD;;EAsBA,OAAO,CAACpC,aAAD,EAAgBkC,WAAhB,CAAP;AACD,CAxJD;;AA0JA,eAAe1C,WAAf"}
1
+ {"version":3,"file":"useScrollTo.js","names":["useEffect","useRef","useState","useCallback","verticalScrollOffset","findFirstVisibleElement","isScrolledToTheBottom","getScrollTop","scrollElement","useScrollTo","selectedIndexProp","scrollElementId","href","offset","options","onChange","direction","RETRY_MAX","selectedIndex","setSelectedIndex","scrollEle","requestedAnimationFrame","lastContainerScrollTop","selectedIndexRef","current","document","getElementById","window","checkScroll","event","requestAnimationFrame","firstVisibleElementIndex","newSelectedIndex","length","containerScrollTop","isScrollingDown","addEventListener","removeEventListener","cancelAnimationFrame","checkRenderedInterval","hashValue","location","hash","split","option","find","o","value","retry","setInterval","ele","clearInterval","setScrollTo","id","index","wrappedOnChange","history","pushState"],"sources":["../../../src/ScrollTo/useScrollTo.js"],"sourcesContent":["import { useEffect, useRef, useState, useCallback } from \"react\";\nimport {\n verticalScrollOffset,\n findFirstVisibleElement,\n isScrolledToTheBottom,\n getScrollTop,\n scrollElement,\n} from \"./utils\";\n\nconst useScrollTo = (\n selectedIndexProp = 0,\n scrollElementId,\n href,\n offset = 0,\n options,\n onChange,\n direction = \"column\"\n) => {\n const RETRY_MAX = 5;\n const [selectedIndex, setSelectedIndex] = useState(selectedIndexProp);\n\n const scrollEle = useRef();\n const requestedAnimationFrame = useRef(0);\n const lastContainerScrollTop = useRef();\n\n // ref to use a often-changing value in useCallback, as recommended in\n // https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n const selectedIndexRef = useRef(selectedIndex);\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n scrollEle.current = (scrollElementId && document.getElementById(scrollElementId)) || window;\n lastContainerScrollTop.current = verticalScrollOffset(scrollEle.current);\n }, [scrollElementId]);\n\n const checkScroll = useCallback(\n (event) => {\n if (requestedAnimationFrame.current === 0 && window?.requestAnimationFrame) {\n requestedAnimationFrame.current = window.requestAnimationFrame(() => {\n requestedAnimationFrame.current = 0;\n\n const firstVisibleElementIndex = findFirstVisibleElement(\n scrollEle.current,\n options,\n offset\n );\n\n let newSelectedIndex = firstVisibleElementIndex;\n\n // select the first element when all elements are bellow the container's top\n if (firstVisibleElementIndex < 0) {\n newSelectedIndex = 0;\n }\n\n // if the user has reached the bottom of the container, select the first nav item still visible\n // (usually this selects the last nav item, when it can't reach the top the container)\n // in theory only needed when scrolling down, but no... because of the Safari bouncing behaviour\n if (newSelectedIndex < options.length - 1 && isScrolledToTheBottom(scrollEle.current)) {\n newSelectedIndex += 1;\n }\n\n const containerScrollTop = getScrollTop(scrollEle.current);\n const isScrollingDown = containerScrollTop > lastContainerScrollTop.current;\n lastContainerScrollTop.current = containerScrollTop;\n\n // only update the selected item if the scroll direction is moving away from it\n if (isScrollingDown) {\n if (newSelectedIndex < selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n } else if (newSelectedIndex > selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n\n setSelectedIndex(newSelectedIndex);\n onChange?.(event, newSelectedIndex);\n });\n }\n },\n [offset, options, onChange]\n );\n\n // registers and unregisters the scroll listener\n useEffect(() => {\n if (scrollEle.current) {\n scrollEle.current.addEventListener(\"scroll\", checkScroll, false);\n }\n\n return () => {\n if (scrollEle.current) {\n scrollEle.current.removeEventListener(\"scroll\", checkScroll);\n }\n\n if (requestedAnimationFrame.current !== 0) {\n window.cancelAnimationFrame(requestedAnimationFrame.current);\n requestedAnimationFrame.current = 0;\n }\n };\n }, [checkScroll]);\n\n // waits for the elements to be rendered and scrolls to the one referenced\n // in the URL hash, if any\n useEffect(() => {\n let checkRenderedInterval;\n\n if (href) {\n const hashValue = document.location.hash.split(\"#\")[1] || \"\";\n\n const option = options.find((o) => o.value === hashValue);\n\n if (option) {\n let retry = 0;\n checkRenderedInterval = setInterval(() => {\n const ele = document.getElementById(option.value);\n\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n clearInterval(checkRenderedInterval);\n } else {\n retry += 1;\n if (retry === RETRY_MAX) {\n clearInterval(checkRenderedInterval);\n }\n }\n }, 1000);\n }\n }\n\n return () => {\n clearInterval(checkRenderedInterval);\n };\n\n // we really want to run this just in the first load\n // in fact this doesn't even belong here, the logic should be external\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const setScrollTo = (event, id, index, wrappedOnChange) => {\n const option = options.find((o) => o.value === id);\n\n if (option) {\n const ele = document.getElementById(id);\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset, direction);\n }\n\n if (href) {\n window.history.pushState({}, \"\", `#${options[index].value}`);\n }\n\n setSelectedIndex(index);\n wrappedOnChange?.(index);\n\n // Safari scrolls immediately (no smooth scroll support),\n // so this ref value must be updated asap\n selectedIndexRef.current = index;\n }\n };\n\n return [selectedIndex, setScrollTo];\n};\n\nexport default useScrollTo;\n"],"mappings":";;;;;AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,EAAsC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,qBAAD,CAAb;YACD;UACF;QACF,CAZkC,EAYhC,IAZgC,CAAnC;MAaD;IACF;;IAED,OAAO,YAAM;MACXY,aAAa,CAACZ,qBAAD,CAAb;IACD,CAFD,CA1Bc,CA8Bd;IACA;IACA;EACD,CAjCQ,EAiCN,EAjCM,CAAT;;EAmCA,IAAMa,WAAW,GAAG,SAAdA,WAAc,CAACvB,KAAD,EAAQwB,EAAR,EAAYC,KAAZ,EAAmBC,eAAnB,EAAuC;IACzD,IAAMX,MAAM,GAAG9B,OAAO,CAAC+B,IAAR,CAAa,UAACC,CAAD;MAAA,OAAOA,CAAC,CAACC,KAAF,KAAYM,EAAnB;IAAA,CAAb,CAAf;;IAEA,IAAIT,MAAJ,EAAY;MACV,IAAMM,GAAG,GAAGzB,QAAQ,CAACC,cAAT,CAAwB2B,EAAxB,CAAZ;;MACA,IAAIH,GAAJ,EAAS;QACP1C,aAAa,CAAC0C,GAAD,EAAM9B,SAAS,CAACI,OAAhB,EAAyBoB,MAAM,CAAC/B,MAAP,IAAiBA,MAA1C,EAAkDG,SAAlD,CAAb;MACD;;MAED,IAAIJ,IAAJ,EAAU;QACRe,MAAM,CAAC6B,OAAP,CAAeC,SAAf,CAAyB,EAAzB,EAA6B,EAA7B,aAAqC3C,OAAO,CAACwC,KAAD,CAAP,CAAeP,KAApD;MACD;;MAED5B,gBAAgB,CAACmC,KAAD,CAAhB;MACAC,eAAe,SAAf,IAAAA,eAAe,WAAf,YAAAA,eAAe,CAAGD,KAAH,CAAf,CAXU,CAaV;MACA;;MACA/B,gBAAgB,CAACC,OAAjB,GAA2B8B,KAA3B;IACD;EACF,CApBD;;EAsBA,OAAO,CAACpC,aAAD,EAAgBkC,WAAhB,CAAP;AACD,CAzJD;;AA2JA,eAAe3C,WAAf"}
@@ -22,13 +22,43 @@ export var verticalScrollOffset = function verticalScrollOffset(t) {
22
22
 
23
23
  return t.offsetTop - c.offsetTop;
24
24
  };
25
+ export var horizontalScrollOffset = function horizontalScrollOffset(t) {
26
+ var c = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
27
+
28
+ if (c === window) {
29
+ var _t$getBoundingClientR2;
30
+
31
+ return ((t === null || t === void 0 ? void 0 : (_t$getBoundingClientR2 = t.getBoundingClientRect) === null || _t$getBoundingClientR2 === void 0 ? void 0 : _t$getBoundingClientR2.call(t).left) || 0) + (window.scrollX || window.pageXOffset);
32
+ }
33
+
34
+ if (getComputedStyle(c).position !== "static") {
35
+ return t.offsetLeft;
36
+ }
37
+
38
+ return t.offsetLeft - c.offsetLeft;
39
+ };
25
40
  export var scrollElement = function scrollElement(element, container) {
26
41
  var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
27
- var elemTop = verticalScrollOffset(element, container);
28
- container.scrollTo({
29
- top: elemTop - offset,
30
- behavior: "smooth"
31
- });
42
+ var direction = arguments.length > 3 ? arguments[3] : undefined;
43
+
44
+ if (direction === "row") {
45
+ var _container$scrollTo;
46
+
47
+ var elemLeft = horizontalScrollOffset(element, container);
48
+ container === null || container === void 0 ? void 0 : (_container$scrollTo = container.scrollTo) === null || _container$scrollTo === void 0 ? void 0 : _container$scrollTo.call(container, {
49
+ left: elemLeft - offset,
50
+ behavior: "smooth"
51
+ });
52
+ } else {
53
+ var _container$scrollTo2;
54
+
55
+ var elemTop = verticalScrollOffset(element, container);
56
+ container === null || container === void 0 ? void 0 : (_container$scrollTo2 = container.scrollTo) === null || _container$scrollTo2 === void 0 ? void 0 : _container$scrollTo2.call(container, {
57
+ top: elemTop - offset,
58
+ behavior: "smooth"
59
+ });
60
+ }
61
+
32
62
  element.focus({
33
63
  preventScroll: true
34
64
  });
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["getScrollTop","c","window","scrollY","pageYOffset","document","documentElement","scrollTop","body","verticalScrollOffset","t","getBoundingClientRect","top","getComputedStyle","position","offsetTop","scrollElement","element","container","offset","elemTop","scrollTo","behavior","focus","preventScroll","isScrolledToTheBottom","containerScrollTop","scrollHeight","innerHeight","offsetHeight","findFirstVisibleElement","options","boundsTop","i","length","ele","getElementById","value"],"sources":["../../../src/ScrollTo/utils.js"],"sourcesContent":["export const getScrollTop = (c = window) => {\n if (c === window) {\n return (\n window.scrollY ||\n window.pageYOffset ||\n (document.documentElement && document.documentElement.scrollTop) ||\n document.body.scrollTop\n );\n }\n\n return c.scrollTop;\n};\n\nexport const verticalScrollOffset = (t, c = window) => {\n if (c === window) {\n return (t?.getBoundingClientRect?.().top || 0) + (window.scrollY || window.pageYOffset);\n }\n if (getComputedStyle(c).position !== \"static\") {\n return t.offsetTop;\n }\n\n return t.offsetTop - c.offsetTop;\n};\n\nexport const scrollElement = (element, container, offset = 0) => {\n const elemTop = verticalScrollOffset(element, container);\n container.scrollTo({\n top: elemTop - offset,\n behavior: \"smooth\",\n });\n element.focus({ preventScroll: true });\n};\n\nexport const isScrolledToTheBottom = (container) => {\n const containerScrollTop = getScrollTop(container);\n\n if (container === window) {\n // accounting for cases where html/body are set to height:100%\n const scrollHeight =\n (document.documentElement && document.documentElement.scrollHeight) ||\n document.body.scrollHeight;\n\n return containerScrollTop + window.innerHeight >= scrollHeight;\n }\n\n return containerScrollTop + container.offsetHeight >= container.scrollHeight;\n};\n\nexport const findFirstVisibleElement = (container, options, offset) => {\n const boundsTop = verticalScrollOffset(container);\n\n let i = 0;\n // find index of first element whose top is still visible inside the container\n for (; i < options.length; i += 1) {\n const ele = document.getElementById(options[i].value);\n\n if (ele) {\n const elemTop = verticalScrollOffset(ele) - (options[i].offset || offset);\n\n if (elemTop > boundsTop) {\n break;\n }\n }\n }\n\n // return the previous index, the element that last scrolled past the top\n return i - 1;\n};\n"],"mappings":"AAAA,OAAO,IAAMA,YAAY,GAAG,SAAfA,YAAe,GAAgB;EAAA,IAAfC,CAAe,uEAAXC,MAAW;;EAC1C,IAAID,CAAC,KAAKC,MAAV,EAAkB;IAChB,OACEA,MAAM,CAACC,OAAP,IACAD,MAAM,CAACE,WADP,IAECC,QAAQ,CAACC,eAAT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eAAT,IAA4BD,QAAQ,CAACC,eAAT,CAAyBqB,YAAtD,IACAtB,QAAQ,CAACG,IAAT,CAAcmB,YAFhB;IAIA,OAAOD,kBAAkB,GAAGxB,MAAM,CAAC0B,WAA5B,IAA2CD,YAAlD;EACD;;EAED,OAAOD,kBAAkB,GAAGR,SAAS,CAACW,YAA/B,IAA+CX,SAAS,CAACS,YAAhE;AACD,CAbM;AAeP,OAAO,IAAMG,uBAAuB,GAAG,SAA1BA,uBAA0B,CAACZ,SAAD,EAAYa,OAAZ,EAAqBZ,MAArB,EAAgC;EACrE,IAAMa,SAAS,GAAGvB,oBAAoB,CAACS,SAAD,CAAtC;EAEA,IAAIe,CAAC,GAAG,CAAR,CAHqE,CAIrE;;EACA,OAAOA,CAAC,GAAGF,OAAO,CAACG,MAAnB,EAA2BD,CAAC,IAAI,CAAhC,EAAmC;IACjC,IAAME,GAAG,GAAG9B,QAAQ,CAAC+B,cAAT,CAAwBL,OAAO,CAACE,CAAD,CAAP,CAAWI,KAAnC,CAAZ;;IAEA,IAAIF,GAAJ,EAAS;MACP,IAAMf,OAAO,GAAGX,oBAAoB,CAAC0B,GAAD,CAApB,IAA6BJ,OAAO,CAACE,CAAD,CAAP,CAAWd,MAAX,IAAqBA,MAAlD,CAAhB;;MAEA,IAAIC,OAAO,GAAGY,SAAd,EAAyB;QACvB;MACD;IACF;EACF,CAfoE,CAiBrE;;;EACA,OAAOC,CAAC,GAAG,CAAX;AACD,CAnBM"}
1
+ {"version":3,"file":"utils.js","names":["getScrollTop","c","window","scrollY","pageYOffset","document","documentElement","scrollTop","body","verticalScrollOffset","t","getBoundingClientRect","top","getComputedStyle","position","offsetTop","horizontalScrollOffset","left","scrollX","pageXOffset","offsetLeft","scrollElement","element","container","offset","direction","elemLeft","scrollTo","behavior","elemTop","focus","preventScroll","isScrolledToTheBottom","containerScrollTop","scrollHeight","innerHeight","offsetHeight","findFirstVisibleElement","options","boundsTop","i","length","ele","getElementById","value"],"sources":["../../../src/ScrollTo/utils.js"],"sourcesContent":["export const getScrollTop = (c = window) => {\n if (c === window) {\n return (\n window.scrollY ||\n window.pageYOffset ||\n (document.documentElement && document.documentElement.scrollTop) ||\n document.body.scrollTop\n );\n }\n\n return c.scrollTop;\n};\n\nexport const verticalScrollOffset = (t, c = window) => {\n if (c === window) {\n return (t?.getBoundingClientRect?.().top || 0) + (window.scrollY || window.pageYOffset);\n }\n if (getComputedStyle(c).position !== \"static\") {\n return t.offsetTop;\n }\n\n return t.offsetTop - c.offsetTop;\n};\n\nexport const horizontalScrollOffset = (t, c = window) => {\n if (c === window) {\n return (t?.getBoundingClientRect?.().left || 0) + (window.scrollX || window.pageXOffset);\n }\n if (getComputedStyle(c).position !== \"static\") {\n return t.offsetLeft;\n }\n\n return t.offsetLeft - c.offsetLeft;\n};\n\nexport const scrollElement = (element, container, offset = 0, direction) => {\n if (direction === \"row\") {\n const elemLeft = horizontalScrollOffset(element, container);\n container?.scrollTo?.({\n left: elemLeft - offset,\n behavior: \"smooth\",\n });\n } else {\n const elemTop = verticalScrollOffset(element, container);\n container?.scrollTo?.({\n top: elemTop - offset,\n behavior: \"smooth\",\n });\n }\n element.focus({ preventScroll: true });\n};\n\nexport const isScrolledToTheBottom = (container) => {\n const containerScrollTop = getScrollTop(container);\n\n if (container === window) {\n // accounting for cases where html/body are set to height:100%\n const scrollHeight =\n (document.documentElement && document.documentElement.scrollHeight) ||\n document.body.scrollHeight;\n\n return containerScrollTop + window.innerHeight >= scrollHeight;\n }\n\n return containerScrollTop + container.offsetHeight >= container.scrollHeight;\n};\n\nexport const findFirstVisibleElement = (container, options, offset) => {\n const boundsTop = verticalScrollOffset(container);\n\n let i = 0;\n // find index of first element whose top is still visible inside the container\n for (; i < options.length; i += 1) {\n const ele = document.getElementById(options[i].value);\n\n if (ele) {\n const elemTop = verticalScrollOffset(ele) - (options[i].offset || offset);\n\n if (elemTop > boundsTop) {\n break;\n }\n }\n }\n\n // return the previous index, the element that last scrolled past the top\n return i - 1;\n};\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FhB;IAIA,OAAOD,kBAAkB,GAAG/B,MAAM,CAACiC,WAA5B,IAA2CD,YAAlD;EACD;;EAED,OAAOD,kBAAkB,GAAGV,SAAS,CAACa,YAA/B,IAA+Cb,SAAS,CAACW,YAAhE;AACD,CAbM;AAeP,OAAO,IAAMG,uBAAuB,GAAG,SAA1BA,uBAA0B,CAACd,SAAD,EAAYe,OAAZ,EAAqBd,MAArB,EAAgC;EACrE,IAAMe,SAAS,GAAG9B,oBAAoB,CAACc,SAAD,CAAtC;EAEA,IAAIiB,CAAC,GAAG,CAAR,CAHqE,CAIrE;;EACA,OAAOA,CAAC,GAAGF,OAAO,CAACG,MAAnB,EAA2BD,CAAC,IAAI,CAAhC,EAAmC;IACjC,IAAME,GAAG,GAAGrC,QAAQ,CAACsC,cAAT,CAAwBL,OAAO,CAACE,CAAD,CAAP,CAAWI,KAAnC,CAAZ;;IAEA,IAAIF,GAAJ,EAAS;MACP,IAAMb,OAAO,GAAGpB,oBAAoB,CAACiC,GAAD,CAApB,IAA6BJ,OAAO,CAACE,CAAD,CAAP,CAAWhB,MAAX,IAAqBA,MAAlD,CAAhB;;MAEA,IAAIK,OAAO,GAAGU,SAAd,EAAyB;QACvB;MACD;IACF;EACF,CAfoE,CAiBrE;;;EACA,OAAOC,CAAC,GAAG,CAAX;AACD,CAnBM"}
@@ -15,13 +15,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
15
15
 
16
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
17
 
18
- import React, { useMemo, useState } from "react";
18
+ import React, { useState } from "react";
19
19
  import { Chip, withStyles, useTheme } from "@material-ui/core";
20
20
  import PropTypes from "prop-types";
21
21
  import clsx from "clsx";
22
22
  import { CloseXS } from "@hitachivantara/uikit-react-icons";
23
23
  import fade from "../utils/hexToRgbA";
24
- import { HvButton, HvTypography } from "..";
24
+ import { HvButton } from "..";
25
25
  import styles from "./styles";
26
26
  import { getOnDeleteCallback, hasDeleteAction, hasClickAction } from "./utils";
27
27
 
@@ -51,8 +51,6 @@ var getColor = function getColor(theme, customColor, type) {
51
51
 
52
52
 
53
53
  var HvTag = function HvTag(props) {
54
- var _HvTypography;
55
-
56
54
  var classes = props.classes,
57
55
  style = props.style,
58
56
  className = props.className,
@@ -112,17 +110,8 @@ var HvTag = function HvTag(props) {
112
110
  hover = _useState2[0],
113
111
  setHover = _useState2[1];
114
112
 
115
- var chipLabel = useMemo(function () {
116
- if (typeof label === "string") {
117
- return _HvTypography || (_HvTypography = /*#__PURE__*/React.createElement(HvTypography, {
118
- variant: "normalText"
119
- }, label));
120
- }
121
-
122
- return label;
123
- }, [label]);
124
113
  return /*#__PURE__*/React.createElement(Chip, _extends({
125
- label: chipLabel,
114
+ label: label,
126
115
  className: clsx(classes.root, className),
127
116
  onMouseEnter: function onMouseEnter() {
128
117
  setHover(!!onClick);
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.js","names":["React","useMemo","useState","Chip","withStyles","useTheme","PropTypes","clsx","CloseXS","fade","HvButton","HvTypography","styles","getOnDeleteCallback","hasDeleteAction","hasClickAction","getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","inlineStyle","categoricalBackgroundColor","hover","setHover","chipLabel","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","propTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","name"],"sources":["../../../src/Tag/Tag.js"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\n\nimport { Chip, withStyles, useTheme } from \"@material-ui/core\";\n\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport fade from \"../utils/hexToRgbA\";\n\nimport { HvButton, HvTypography } from \"..\";\n\nimport styles from \"./styles\";\n\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\n\n return backgroundColor;\n};\n\n/**\n * A Tag is one word that describes a specific aspect of an asset. A single asset can have\n * multiple tags.\n * Use tags to highlight an item's status for quick recognition and navigation\n * Use color to indicate meanings that users can learn and recognize across products\n *\n * It leverages the Chip component from Material UI\n */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\n label,\n disabled,\n type = \"semantic\",\n color,\n deleteIcon,\n onDelete,\n onClick,\n role,\n deleteButtonArialLabel = \"Delete tag\",\n deleteButtonProps = {},\n ...others\n } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n const chipLabel = useMemo(() => {\n if (typeof label === \"string\") {\n return <HvTypography variant=\"normalText\">{label}</HvTypography>;\n }\n\n return label;\n }, [label]);\n\n return (\n <Chip\n label={chipLabel}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: !!onClick,\n [classes.categorical]: type === \"categorical\",\n [classes.categoricalFocus]: type === \"categorical\" && !disabled,\n [classes.categoricalDisabled]: type === \"categorical\" && disabled,\n }),\n label: classes.label,\n deleteIcon: clsx(classes.deleteIcon, {\n [classes.disabledDeleteIcon]: disabled,\n }),\n }}\n deleteIcon={(hasDeleteAction(onDelete) && deleteIcon) || getDeleteIcon()}\n onDelete={getOnDeleteCallback(disabled, onDelete)}\n onClick={disabled ? undefined : onClick}\n role={role || (hasClickAction(onClick) ? \"button\" : undefined)}\n tabIndex={hasDeleteAction(onDelete) ? undefined : 0}\n {...others}\n />\n );\n};\n\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,QAAzB,QAAyC,OAAzC;AAEA,SAASC,IAAT,EAAeC,UAAf,EAA2BC,QAA3B,QAA2C,mBAA3C;AAEA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,OAAT,QAAwB,mCAAxB;AACA,OAAOC,IAAP,MAAiB,oBAAjB;AAEA,SAASC,QAAT,EAAmBC,YAAnB,QAAuC,IAAvC;AAEA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,SAASC,mBAAT,EAA8BC,eAA9B,EAA+CC,cAA/C,QAAqE,SAArE;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAQC,WAAR,EAAqBC,IAArB,EAA8B;EAC7C,IAAMC,oBAAoB,GAAGH,KAAK,CAACI,EAAN,CAASC,OAAT,CAAiBC,QAAjB,CAA0BC,KAAvD;EACA,IAAMC,uBAAuB,GAAGR,KAAK,CAACI,EAAN,CAASK,GAAT,CAAaJ,OAAb,CAAqBK,WAArB,CAAiCC,KAAjE;EAEA,IAAIC,eAAJ;;EAEA,IAAIV,IAAI,KAAK,UAAb,EAAyB;IACvBU,eAAe,GAAGZ,KAAK,CAACK,OAAN,CAAcJ,WAAd,KAA8BA,WAA9B,IAA6CE,oBAA/D;EACD;;EACD,IAAID,IAAI,KAAK,aAAb,EAA4B;IAC1BU,eAAe,GACbZ,KAAK,CAACI,EAAN,CAASK,GAAT,CAAaJ,OAAb,CAAqBK,WAArB,CAAiCT,WAAjC,KAAiDA,WAAjD,IAAgEO,uBADlE;EAED;;EAED,OAAOI,eAAP;AACD,CAfD;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMC,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ACF;AACA;AACA;AACA;EACE5D,IAAI,EAAEb,SAAS,CAAC0E,KAAV,CAAgB,CAAC,UAAD,EAAa,aAAb,CAAhB,CArGU;;EAuGhB;AACF;AACA;EACE3C,KAAK,EAAE/B,SAAS,CAACgE,MA1GD;;EA2GhB;AACF;AACA;EACEhC,UAAU,EAAEhC,SAAS,CAACwE,IA9GN;;EAgHhB;AACF;AACA;AACA;AACA;EACEvC,QAAQ,EAAEjC,SAAS,CAAC2E,IArHJ;;EAsHhB;AACF;AACA;EACEzC,OAAO,EAAElC,SAAS,CAAC2E,IAzHH;;EA2HhB;AACF;AACA;EACExC,IAAI,EAAEnC,SAAS,CAACgE,MA9HA;;EA+HhB;AACF;AACA;EACE5B,sBAAsB,EAAEpC,SAAS,CAACgE,MAlIlB;;EAmIhB;AACF;AACA;EACE3B,iBAAiB,EAAErC,SAAS,CAACsE,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;AAyIA,eAAezE,UAAU,CAACQ,MAAD,EAAS;EAAEsE,IAAI,EAAE;AAAR,CAAT,CAAV,CAAsCpD,KAAtC,CAAf"}
1
+ {"version":3,"file":"Tag.js","names":["React","useState","Chip","withStyles","useTheme","PropTypes","clsx","CloseXS","fade","HvButton","styles","getOnDeleteCallback","hasDeleteAction","hasClickAction","getColor","theme","customColor","type","defaultSemanticColor","hv","palette","semantic","sema7","defaultCategoricalColor","viz","categorical","cviz1","backgroundColor","HvTag","props","classes","style","className","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","getDeleteIcon","disabledSemanticColor","tabIndex","startIcon","tagButton","focusVisible","primary","primaryButton","cursor","undefined","height","inlineStyle","categoricalBackgroundColor","hover","setHover","root","boxShadow","chipRoot","clickable","categoricalDisabled","categoricalFocus","disabledDeleteIcon","propTypes","shape","string","titleOverflow","semanticTextColor","categoricalTextColor","deletable","isRequired","instanceOf","Object","node","bool","oneOf","func","name"],"sources":["../../../src/Tag/Tag.js"],"sourcesContent":["import React, { useState } from \"react\";\n\nimport { Chip, withStyles, useTheme } from \"@material-ui/core\";\n\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport fade from \"../utils/hexToRgbA\";\n\nimport { HvButton } from \"..\";\n\nimport styles from \"./styles\";\n\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nconst getColor = (theme, customColor, type) => {\n const defaultSemanticColor = theme.hv.palette.semantic.sema7;\n const defaultCategoricalColor = theme.hv.viz.palette.categorical.cviz1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor = theme.palette[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n theme.hv.viz.palette.categorical[customColor] || customColor || defaultCategoricalColor;\n }\n\n return backgroundColor;\n};\n\n/**\n * A Tag is one word that describes a specific aspect of an asset. A single asset can have\n * multiple tags.\n * Use tags to highlight an item's status for quick recognition and navigation\n * Use color to indicate meanings that users can learn and recognize across products\n *\n * It leverages the Chip component from Material UI\n */\nconst HvTag = (props) => {\n const {\n classes,\n style,\n className,\n label,\n disabled,\n type = \"semantic\",\n color,\n deleteIcon,\n onDelete,\n onClick,\n role,\n deleteButtonArialLabel = \"Delete tag\",\n deleteButtonProps = {},\n ...others\n } = props;\n\n const getDeleteIcon = () => {\n const disabledSemanticColor = type === \"semantic\" ? \"atmo5\" : \"base2\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n primary: classes.primaryButton,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n style={{\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n }}\n color={disabled ? disabledSemanticColor : \"base2\"}\n />\n </HvButton>\n );\n };\n\n const theme = useTheme();\n\n const inlineStyle = {\n ...style,\n };\n\n let categoricalBackgroundColor;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(theme, color, type);\n } else if (type === \"categorical\") {\n categoricalBackgroundColor = getColor(theme, color, type);\n\n inlineStyle.backgroundColor = fade(categoricalBackgroundColor, 0.3);\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={clsx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` } : null),\n }}\n classes={{\n root: clsx(classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: !!onClick,\n [classes.categorical]: type === \"categorical\",\n [classes.categoricalFocus]: type === \"categorical\" && !disabled,\n [classes.categoricalDisabled]: type === \"categorical\" && disabled,\n }),\n label: classes.label,\n deleteIcon: clsx(classes.deleteIcon, {\n [classes.disabledDeleteIcon]: disabled,\n }),\n }}\n deleteIcon={(hasDeleteAction(onDelete) && deleteIcon) || getDeleteIcon()}\n onDelete={getOnDeleteCallback(disabled, onDelete)}\n onClick={disabled ? undefined : onClick}\n role={role || (hasClickAction(onClick) ? \"button\" : undefined)}\n tabIndex={hasDeleteAction(onDelete) ? undefined : 0}\n {...others}\n />\n );\n};\n\nHvTag.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n chipRoot: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n tagButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabledDeleteIcon: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n titleOverflow: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categorical: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalDisabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n semanticTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalTextColor: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n deletable: PropTypes.string,\n /**\n * Styles applied to the component if has onClick.\n */\n clickable: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n focusVisible: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n primaryButton: PropTypes.string,\n /**\n * Styles applied to the component.\n */\n categoricalFocus: PropTypes.string,\n }).isRequired,\n\n /**\n * Inline styles to be applied to the root element.\n */\n style: PropTypes.instanceOf(Object),\n\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n\n /**\n * The label of the tag element.\n *\n */\n label: PropTypes.node,\n\n /**\n * Indicates that the form element is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * The type of the tag element.\n *\n * A tag can be of semantic or categoric type\n */\n type: PropTypes.oneOf([\"semantic\", \"categorical\"]),\n\n /**\n * Background color to be applied to the tag\n */\n color: PropTypes.string,\n /**\n * Icon used to customize the delete icon in the Chip element\n */\n deleteIcon: PropTypes.node,\n\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component,\n * in order to render the delete icon\n */\n onDelete: PropTypes.func,\n /**\n * Callback triggered when any item is clicked.\n */\n onClick: PropTypes.func,\n\n /**\n * The role of the element with an attributed event.\n */\n role: PropTypes.string,\n /**\n * Aria properties to apply to delete button in tag\n */\n deleteButtonArialLabel: PropTypes.string,\n /**\n * Props to apply to delete button\n */\n deleteButtonProps: PropTypes.instanceOf(Object),\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AAEA,SAASC,IAAT,EAAeC,UAAf,EAA2BC,QAA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IlB;;EAmIhB;AACF;AACA;EACE1B,iBAAiB,EAAEpC,SAAS,CAACoE,UAAV,CAAqBC,MAArB;AAtIH,CAAlB;AAyIA,eAAevE,UAAU,CAACO,MAAD,EAAS;EAAEqE,IAAI,EAAE;AAAR,CAAT,CAAV,CAAsCnD,KAAtC,CAAf"}
@@ -29,13 +29,15 @@ var styles = function styles(theme) {
29
29
  primaryButton: {
30
30
  background: "transparent"
31
31
  },
32
- label: {
32
+ label: _objectSpread(_objectSpread({
33
33
  paddingLeft: theme.hv.spacing.xs,
34
- paddingRight: theme.hv.spacing.xs,
34
+ paddingRight: theme.hv.spacing.xs
35
+ }, theme.hv.typography.normalText), {}, {
36
+ color: theme.palette.base2,
35
37
  "& p": {
36
38
  color: theme.hv.palette.base.base2
37
39
  }
38
- },
40
+ }),
39
41
  tagButton: {
40
42
  width: 16,
41
43
  height: 16,
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","names":["fade","outlineStyles","styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","color","base","base2","tagButton","width","minWidth","minHeight","padding","margin","deleteIcon","marginRight","outline","boxShadow","disabledDeleteIcon","atmosphere","atmo3","outlineOffset","titleOverflow","whiteSpace","overflow","textOverflow","categorical","cursor","accent","acce1","clickable","categoricalFocus","disabled","atmo5","categoricalDisabled","semanticTextColor","categoricalTextColor"],"sources":["../../../src/Tag/styles.js"],"sourcesContent":["import fade from \"../utils/hexToRgbA\";\nimport { outlineStyles } from \"../Focus/styles\";\n\nconst styles = (theme) => ({\n root: {},\n\n chipRoot: {\n height: 16,\n borderRadius: 0,\n maxWidth: 180,\n \"& $focusVisible\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n },\n\n focusVisible: {},\n\n primaryButton: {\n background: \"transparent\",\n },\n\n label: {\n paddingLeft: theme.hv.spacing.xs,\n paddingRight: theme.hv.spacing.xs,\n \"& p\": {\n color: theme.hv.palette.base.base2,\n },\n },\n\n tagButton: {\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n margin: 0,\n },\n\n deleteIcon: {\n marginRight: 0,\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n \"&:hover\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n \"&:focus\": {\n ...outlineStyles,\n borderRadius: 0,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n disabledDeleteIcon: {\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n outline: \"none\",\n boxShadow: \"none\",\n outlineOffset: 0,\n },\n },\n titleOverflow: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n categorical: {\n borderRadius: 8,\n \"&$clickable\": {\n cursor: \"pointer\",\n },\n \"&:hover\": {\n borderRadius: 8,\n },\n \"& $label > p\": {\n color: theme.hv.palette.accent.acce1,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n clickable: {},\n\n categoricalFocus: {\n \"&:focus\": {\n ...outlineStyles,\n },\n },\n\n disabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n },\n\n categoricalDisabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n outline: \"none\",\n },\n },\n\n semanticTextColor: {\n color: theme.hv.palette.base.base2,\n },\n categoricalTextColor: {\n color: theme.hv.palette.accent.acce1,\n },\n});\n\nexport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BO,MAAM,EAAE,aAFW;MAGnB,gBAAgB;QACdtB,KAAK,EAAElB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiByB,UAAjB,CAA4Bc;MADrB,CAHG;MAMnB,WAAW;QACTxC,eAAe,EAAEN,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiByB,UAAjB,CAA4BC;MADpC,CANQ;MASnB,WAAW;QACTJ,OAAO,EAAE;MADA;IATQ,CAtGI;IAoHzBmB,iBAAiB,EAAE;MACjB9B,KAAK,EAAElB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiBY,IAAjB,CAAsBC;IADZ,CApHM;IAuHzB6B,oBAAoB,EAAE;MACpB/B,KAAK,EAAElB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiBkC,MAAjB,CAAwBC;IADX;EAvHG,CAAZ;AAAA,CAAf;;AA4HA,eAAe3C,MAAf"}
1
+ {"version":3,"file":"styles.js","names":["fade","outlineStyles","styles","theme","root","chipRoot","height","borderRadius","maxWidth","backgroundColor","palette","base1","focusVisible","primaryButton","background","label","paddingLeft","hv","spacing","xs","paddingRight","typography","normalText","color","base2","base","tagButton","width","minWidth","minHeight","padding","margin","deleteIcon","marginRight","outline","boxShadow","disabledDeleteIcon","atmosphere","atmo3","outlineOffset","titleOverflow","whiteSpace","overflow","textOverflow","categorical","cursor","accent","acce1","clickable","categoricalFocus","disabled","atmo5","categoricalDisabled","semanticTextColor","categoricalTextColor"],"sources":["../../../src/Tag/styles.js"],"sourcesContent":["import fade from \"../utils/hexToRgbA\";\nimport { outlineStyles } from \"../Focus/styles\";\n\nconst styles = (theme) => ({\n root: {},\n\n chipRoot: {\n height: 16,\n borderRadius: 0,\n maxWidth: 180,\n \"& $focusVisible\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n },\n\n focusVisible: {},\n\n primaryButton: {\n background: \"transparent\",\n },\n\n label: {\n paddingLeft: theme.hv.spacing.xs,\n paddingRight: theme.hv.spacing.xs,\n ...theme.hv.typography.normalText,\n color: theme.palette.base2,\n \"& p\": {\n color: theme.hv.palette.base.base2,\n },\n },\n\n tagButton: {\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n margin: 0,\n },\n\n deleteIcon: {\n marginRight: 0,\n width: 16,\n height: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n \"&:hover\": {\n backgroundColor: fade(theme.palette.base1, 0.3),\n },\n \"&:focus\": {\n ...outlineStyles,\n borderRadius: 0,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n disabledDeleteIcon: {\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n outline: \"none\",\n boxShadow: \"none\",\n outlineOffset: 0,\n },\n },\n titleOverflow: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n categorical: {\n borderRadius: 8,\n \"&$clickable\": {\n cursor: \"pointer\",\n },\n \"&:hover\": {\n borderRadius: 8,\n },\n \"& $label > p\": {\n color: theme.hv.palette.accent.acce1,\n },\n \"&:focus:not(:focus-visible)\": {\n outline: \"0 !important\",\n boxShadow: \"none !important\",\n },\n },\n clickable: {},\n\n categoricalFocus: {\n \"&:focus\": {\n ...outlineStyles,\n },\n },\n\n disabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n },\n\n categoricalDisabled: {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n cursor: \"not-allowed\",\n \"& $label > p\": {\n color: theme.hv.palette.atmosphere.atmo5,\n },\n \"&:hover\": {\n backgroundColor: theme.hv.palette.atmosphere.atmo3,\n },\n \"&:focus\": {\n outline: \"none\",\n },\n },\n\n semanticTextColor: {\n color: theme.hv.palette.base.base2,\n },\n categoricalTextColor: {\n color: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UAAjB,CAA4Bc;MADrB;IAHR,CAhGe;IAwGzBC,mBAAmB,EAAE;MACnB3C,eAAe,EAAEN,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiB2B,UAAjB,CAA4BC,KAD1B;MAEnBO,MAAM,EAAE,aAFW;MAGnB,gBAAgB;QACdtB,KAAK,EAAEpB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiB2B,UAAjB,CAA4Bc;MADrB,CAHG;MAMnB,WAAW;QACT1C,eAAe,EAAEN,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiB2B,UAAjB,CAA4BC;MADpC,CANQ;MASnB,WAAW;QACTJ,OAAO,EAAE;MADA;IATQ,CAxGI;IAsHzBmB,iBAAiB,EAAE;MACjB9B,KAAK,EAAEpB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiBe,IAAjB,CAAsBD;IADZ,CAtHM;IAyHzB8B,oBAAoB,EAAE;MACpB/B,KAAK,EAAEpB,KAAK,CAACc,EAAN,CAASP,OAAT,CAAiBoC,MAAjB,CAAwBC;IADX;EAzHG,CAAZ;AAAA,CAAf;;AA8HA,eAAe7C,MAAf"}
@@ -17,9 +17,9 @@ export type HvBannerContentClassKey =
17
17
  | SemanticVariantTypes;
18
18
 
19
19
  export interface HvBannerContentProps
20
- extends StandardProps<SnackbarContentProps, HvBannerContentClassKey>,
20
+ extends StandardProps<SnackbarContentProps, HvBannerContentClassKey, "variant">,
21
21
  HvActionsGenericCommonProps,
22
- Pick<NotificationsCommonProps, "showIcon" | "customIcon"> {
22
+ Pick<NotificationsCommonProps, "showIcon" | "customIcon" | "variant"> {
23
23
  /**
24
24
  * The position property of the header.
25
25
  */
@@ -1,6 +1,6 @@
1
1
  import { StandardProps, SwitchProps } from "@material-ui/core";
2
2
 
3
- export type HvBaseSwitchClassKey = "root" | "disabled";
3
+ export type HvBaseSwitchClassKey = "root" | "disabled" | "readOnly";
4
4
 
5
5
  export interface HvBaseSwitchProps
6
6
  extends StandardProps<SwitchProps, HvBaseSwitchClassKey, "onChange"> {
@@ -52,7 +52,7 @@ const HvBaseSwitch = props => {
52
52
  return /*#__PURE__*/React.createElement(Switch, _extends({
53
53
  id: id,
54
54
  name: name,
55
- className: clsx(className, classes.root, disabled && classes.disabled, focusVisible && classes.focusVisible),
55
+ className: clsx(className, classes.root, disabled && classes.disabled, readOnly && classes.readOnly, focusVisible && classes.focusVisible),
56
56
  color: "default",
57
57
  disabled: disabled,
58
58
  required: required,
@@ -96,6 +96,11 @@ process.env.NODE_ENV !== "production" ? HvBaseSwitch.propTypes = {
96
96
  */
97
97
  disabled: PropTypes.string,
98
98
 
99
+ /**
100
+ * Styles applied to the switch when it is in read only mode.
101
+ */
102
+ readOnly: PropTypes.string,
103
+
99
104
  /**
100
105
  * Styles applied to the internal Switch component's root class.
101
106
  */
@@ -1 +1 @@
1
- {"version":3,"file":"BaseSwitch.js","names":["React","useState","useCallback","PropTypes","clsx","Switch","withStyles","styles","HvBaseSwitch","props","classes","className","id","name","value","required","readOnly","disabled","checked","defaultChecked","onChange","inputProps","onFocusVisible","onBlur","others","focusVisible","setFocusVisible","onFocusVisibleCallback","evt","onBlurCallback","onLocalChange","target","root","switch","switchBase","track","thumb","propTypes","string","shape","isRequired","any","bool","func","instanceOf","Object"],"sources":["../../../src/BaseSwitch/BaseSwitch.js"],"sourcesContent":["import React, { useState, useCallback } from \"react\";\n\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\n\nimport { Switch, withStyles } from \"@material-ui/core\";\n\nimport styles from \"./styles\";\n\n/**\n * A Switch is <b>binary</b> and work as a digital on/off button.\n *\n * The Base Switch is a building block of the Switch form element. Don't use unless\n * implementing a custom use case not covered by the Switch form element.\n */\nconst HvBaseSwitch = (props) => {\n const {\n classes,\n className,\n\n id,\n name,\n value = \"on\",\n\n required = false,\n readOnly = false,\n disabled = false,\n\n checked,\n defaultChecked,\n\n onChange,\n\n inputProps,\n\n onFocusVisible,\n onBlur,\n\n ...others\n } = props;\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const onLocalChange = useCallback(\n (evt) => {\n if (readOnly) {\n return;\n }\n\n onChange?.(evt, evt.target.checked, value);\n },\n [onChange, readOnly, value]\n );\n\n return (\n <Switch\n id={id}\n name={name}\n className={clsx(className, classes.root, {\n [classes.disabled]: disabled,\n [classes.focusVisible]: focusVisible,\n })}\n color=\"default\"\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n disableRipple\n onChange={onLocalChange}\n value={value}\n checked={checked}\n defaultChecked={defaultChecked}\n classes={{\n root: classes.switch,\n switchBase: classes.switchBase,\n checked: classes.checked,\n track: classes.track,\n thumb: classes.thumb,\n disabled: classes.disabled,\n }}\n inputProps={inputProps}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n};\n\nHvBaseSwitch.propTypes = {\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied to the switch.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the switch when it is disabled.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the internal Switch component's root class.\n */\n switch: PropTypes.string,\n /**\n * Styles applied to the internal SwitchBase component's root class.\n */\n switchBase: PropTypes.string,\n /**\n * Pseudo-class applied to the internal SwitchBase component's checked class.\n */\n checked: PropTypes.string,\n /**\n * Styles applied to the track element.\n */\n track: PropTypes.string,\n /**\n * Styles used to create the thumb passed to the internal SwitchBase component icon prop.\n */\n thumb: PropTypes.string,\n /**\n * Class applied to the root element if keyboard focused.\n */\n focusVisible: PropTypes.string,\n }).isRequired,\n\n /**\n * Id to be applied to the root node.\n */\n id: PropTypes.string,\n\n /**\n * The input name.\n */\n name: PropTypes.string,\n /**\n * The value of the input.\n *\n * Is up to the application's logic when to consider the submission of this value.\n * Generally it should be used only when the switch is neither unchecked nor indeterminate.\n *\n * The default value is \"on\".\n */\n // eslint-disable-next-line react/forbid-prop-types\n value: PropTypes.any,\n\n /**\n * Indicates that user input is required.\n */\n required: PropTypes.bool,\n /**\n * Indicates that the input is not editable.\n */\n readOnly: PropTypes.bool,\n /**\n * Indicates that the input is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * If `true` the switch is selected, if set to `false` the switch is not selected.\n *\n * When defined the switch state becomes controlled.\n */\n checked: PropTypes.bool,\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked: PropTypes.bool,\n\n /**\n * The callback fired when the switch is pressed.\n */\n onChange: PropTypes.func,\n\n /**\n * Properties passed on to the input element.\n */\n inputProps: PropTypes.instanceOf(Object),\n\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible: PropTypes.func,\n /**\n * @ignore\n */\n onBlur: PropTypes.func,\n};\n\nexport default withStyles(styles, { name: \"HvBaseSwitch\" })(HvBaseSwitch);\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,WAA1B,QAA6C,OAA7C;AAEA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AAEA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,mBAAnC;AAEA,OAAOC,MAAP,MAAmB,UAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAIC,KAAD,IAAW;EAC9B,MAAM;IACJC,OADI;IAEJC,SAFI;IAIJC,EAJI;IAKJC,IALI;IAMJC,KAAK,GAAG,IANJ;IAQJC,QAAQ,GAAG,KARP;IASJC,QAAQ,GAAG,KATP;IAUJC,QAAQ,GAAG,KAVP;IAYJC,OAZI;IAaJC,cAbI;IAeJC,QAfI;IAiBJC,UAjBI;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SAAS,CAACmC,MAnDO;;EAoDvB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE;EACAxB,KAAK,EAAEX,SAAS,CAACsC,GA7DM;;EA+DvB;AACF;AACA;EACE1B,QAAQ,EAAEZ,SAAS,CAACuC,IAlEG;;EAmEvB;AACF;AACA;EACE1B,QAAQ,EAAEb,SAAS,CAACuC,IAtEG;;EAuEvB;AACF;AACA;EACEzB,QAAQ,EAAEd,SAAS,CAACuC,IA1EG;;EA4EvB;AACF;AACA;AACA;AACA;EACExB,OAAO,EAAEf,SAAS,CAACuC,IAjFI;;EAkFvB;AACF;AACA;EACEvB,cAAc,EAAEhB,SAAS,CAACuC,IArFH;;EAuFvB;AACF;AACA;EACEtB,QAAQ,EAAEjB,SAAS,CAACwC,IA1FG;;EA4FvB;AACF;AACA;EACEtB,UAAU,EAAElB,SAAS,CAACyC,UAAV,CAAqBC,MAArB,CA/FW;;EAiGvB;AACF;AACA;AACA;EACEvB,cAAc,EAAEnB,SAAS,CAACwC,IArGH;;EAsGvB;AACF;AACA;EACEpB,MAAM,EAAEpB,SAAS,CAACwC;AAzGK,CAAzB;AA4GA,eAAerC,UAAU,CAACC,MAAD,EAAS;EAAEM,IAAI,EAAE;AAAR,CAAT,CAAV,CAA6CL,YAA7C,CAAf"}
1
+ {"version":3,"file":"BaseSwitch.js","names":["React","useState","useCallback","PropTypes","clsx","Switch","withStyles","styles","HvBaseSwitch","props","classes","className","id","name","value","required","readOnly","disabled","checked","defaultChecked","onChange","inputProps","onFocusVisible","onBlur","others","focusVisible","setFocusVisible","onFocusVisibleCallback","evt","onBlurCallback","onLocalChange","target","root","switch","switchBase","track","thumb","propTypes","string","shape","isRequired","any","bool","func","instanceOf","Object"],"sources":["../../../src/BaseSwitch/BaseSwitch.js"],"sourcesContent":["import React, { useState, useCallback } from \"react\";\n\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\n\nimport { Switch, withStyles } from \"@material-ui/core\";\n\nimport styles from \"./styles\";\n\n/**\n * A Switch is <b>binary</b> and work as a digital on/off button.\n *\n * The Base Switch is a building block of the Switch form element. Don't use unless\n * implementing a custom use case not covered by the Switch form element.\n */\nconst HvBaseSwitch = (props) => {\n const {\n classes,\n className,\n\n id,\n name,\n value = \"on\",\n\n required = false,\n readOnly = false,\n disabled = false,\n\n checked,\n defaultChecked,\n\n onChange,\n\n inputProps,\n\n onFocusVisible,\n onBlur,\n\n ...others\n } = props;\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const onLocalChange = useCallback(\n (evt) => {\n if (readOnly) {\n return;\n }\n\n onChange?.(evt, evt.target.checked, value);\n },\n [onChange, readOnly, value]\n );\n\n return (\n <Switch\n id={id}\n name={name}\n className={clsx(className, classes.root, {\n [classes.disabled]: disabled,\n [classes.readOnly]: readOnly,\n [classes.focusVisible]: focusVisible,\n })}\n color=\"default\"\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n disableRipple\n onChange={onLocalChange}\n value={value}\n checked={checked}\n defaultChecked={defaultChecked}\n classes={{\n root: classes.switch,\n switchBase: classes.switchBase,\n checked: classes.checked,\n track: classes.track,\n thumb: classes.thumb,\n disabled: classes.disabled,\n }}\n inputProps={inputProps}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n};\n\nHvBaseSwitch.propTypes = {\n /**\n * Class names to be applied.\n */\n className: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied to the switch.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the switch when it is disabled.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the switch when it is in read only mode.\n */\n readOnly: PropTypes.string,\n /**\n * Styles applied to the internal Switch component's root class.\n */\n switch: PropTypes.string,\n /**\n * Styles applied to the internal SwitchBase component's root class.\n */\n switchBase: PropTypes.string,\n /**\n * Pseudo-class applied to the internal SwitchBase component's checked class.\n */\n checked: PropTypes.string,\n /**\n * Styles applied to the track element.\n */\n track: PropTypes.string,\n /**\n * Styles used to create the thumb passed to the internal SwitchBase component icon prop.\n */\n thumb: PropTypes.string,\n /**\n * Class applied to the root element if keyboard focused.\n */\n focusVisible: PropTypes.string,\n }).isRequired,\n\n /**\n * Id to be applied to the root node.\n */\n id: PropTypes.string,\n\n /**\n * The input name.\n */\n name: PropTypes.string,\n /**\n * The value of the input.\n *\n * Is up to the application's logic when to consider the submission of this value.\n * Generally it should be used only when the switch is neither unchecked nor indeterminate.\n *\n * The default value is \"on\".\n */\n // eslint-disable-next-line react/forbid-prop-types\n value: PropTypes.any,\n\n /**\n * Indicates that user input is required.\n */\n required: PropTypes.bool,\n /**\n * Indicates that the input is not editable.\n */\n readOnly: PropTypes.bool,\n /**\n * Indicates that the input is disabled.\n */\n disabled: PropTypes.bool,\n\n /**\n * If `true` the switch is selected, if set to `false` the switch is not selected.\n *\n * When defined the switch state becomes controlled.\n */\n checked: PropTypes.bool,\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked: PropTypes.bool,\n\n /**\n * The callback fired when the switch is pressed.\n */\n onChange: PropTypes.func,\n\n /**\n * Properties passed on to the input element.\n */\n inputProps: PropTypes.instanceOf(Object),\n\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible: PropTypes.func,\n /**\n * @ignore\n */\n onBlur: PropTypes.func,\n};\n\nexport default withStyles(styles, { name: \"HvBaseSwitch\" })(HvBaseSwitch);\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,WAA1B,QAA6C,OAA7C;AAEA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AAEA,SAASC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CAAV,CAA6CL,YAA7C,CAAf"}
@@ -21,7 +21,10 @@ const styles = theme => ({
21
21
  switch: {
22
22
  padding: 0,
23
23
  width: switchWidth,
24
- height: 16
24
+ height: 16,
25
+ "&$readOnly $switchBase": {
26
+ cursor: "default"
27
+ }
25
28
  },
26
29
  switchBase: {
27
30
  width: switchWidth,
@@ -72,6 +75,7 @@ const styles = theme => ({
72
75
  opacity: 1
73
76
  }
74
77
  },
78
+ readOnly: {},
75
79
  focusVisible: _objectSpread({
76
80
  borderRadius: "8px"
77
81
  }, outlineStyles)
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","names":["outlineStyles","switchWidth","thumbPosition","position","left","width","height","styles","theme","root","padding","cursor","switch","switchBase","backgroundColor","transform","opacity","hv","palette","accent","acce1","track","borderRadius","border","atmosphere","atmo2","thumb","atmo1","marginLeft","marginTop","checked","disabled","atmo3","atmo5","focusVisible"],"sources":["../../../src/BaseSwitch/styles.js"],"sourcesContent":["import { outlineStyles } from \"../Focus/styles\";\n\nconst switchWidth = 32;\n\nconst thumbPosition = {\n position: \"relative\",\n left: -9,\n width: 12,\n height: 12,\n};\n\nconst styles = (theme) => ({\n root: {\n padding: 0,\n cursor: \"pointer\",\n },\n\n switch: {\n padding: 0,\n width: switchWidth,\n height: 16,\n },\n\n switchBase: {\n width: switchWidth,\n height: 16,\n padding: 0,\n\n // increase CSS specificity\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n \"&$checked\": {\n transform: \"translateX(16px)\",\n \"& + $track\": {\n opacity: 1,\n backgroundColor: theme.hv.palette.accent.acce1,\n },\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n },\n },\n\n track: {\n opacity: 1,\n borderRadius: 15,\n left: 17,\n height: 16,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo2,\n },\n\n thumb: {\n ...thumbPosition,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo1,\n marginLeft: 2,\n marginTop: 0,\n },\n\n checked: {},\n\n disabled: {\n cursor: \"not-allowed\",\n\n \"& $switch\": {\n cursor: \"not-allowed\",\n },\n\n \"& $thumb\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n },\n\n \"& $switchBase + $track\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n opacity: 1,\n },\n },\n\n focusVisible: {\n borderRadius: \"8px\",\n ...outlineStyles,\n },\n});\n\nexport default styles;\n"],"mappings":";;;;;;AAAA,SAASA,aAAT,QAA8B,iBAA9B;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEA,MAAMC,aAAa,GAAG;EACpBC,QAAQ,EAAE,UADU;EAEpBC,IAAI,EAAE,CAAC,CAFa;EAGpBC,KAAK,EAAE,EAHa;EAIpBC,MAAM,EAAE;AAJY,CAAtB;;AAOA,MAAMC,MAAM,GAAIC,KAAD,KAAY;EACzBC,IAAI,EAAE;IACJC,OAAO,EAAE,CADL;IAEJC,MAAM,EAAE;EAFJ,CADmB;EAMzBC,MAAM,EAAE;IACNF,OAAO,EAAE,CADH;IAENL,KAAK,EAAEJ,WAFD;IAGNK,MAAM,EAAE;EAHF,CANiB;EAYzBO,UAAU,EAAE;IACVR,KAAK,EAAEJ,WADG;IAEVK,MAAM,EAAE,EAFE;IAGVI,OAAO,EAAE,CAHC;IAKV;IACA,WAAW;MACTI,eAAe,EAAE;IADR,CAND;IASV,aAAa;MACXC,SAAS,EAAE,kBADA;MAEX,cAAc;QACZC,OAAO,EAAE,CADG;QAEZF,eAAe,EAAEN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBC,MAAjB,CAAwBC;MAF7B,CAFH;MAMX,WAAW;QACTN,eAAe,EAAE;MADR;IANA;EATH,CAZa;EAiCzBO,KAAK,EAAE;IACLL,OAAO,EAAE,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les","switchWidth","thumbPosition","position","left","width","height","styles","theme","root","padding","cursor","switch","switchBase","backgroundColor","transform","opacity","hv","palette","accent","acce1","track","borderRadius","border","atmosphere","atmo2","thumb","atmo1","marginLeft","marginTop","checked","disabled","atmo3","atmo5","readOnly","focusVisible"],"sources":["../../../src/BaseSwitch/styles.js"],"sourcesContent":["import { outlineStyles } from \"../Focus/styles\";\n\nconst switchWidth = 32;\n\nconst thumbPosition = {\n position: \"relative\",\n left: -9,\n width: 12,\n height: 12,\n};\n\nconst styles = (theme) => ({\n root: {\n padding: 0,\n cursor: \"pointer\",\n },\n\n switch: {\n padding: 0,\n width: switchWidth,\n height: 16,\n\n \"&$readOnly $switchBase\": {\n cursor: \"default\",\n },\n },\n\n switchBase: {\n width: switchWidth,\n height: 16,\n padding: 0,\n\n // increase CSS specificity\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n \"&$checked\": {\n transform: \"translateX(16px)\",\n \"& + $track\": {\n opacity: 1,\n backgroundColor: theme.hv.palette.accent.acce1,\n },\n \"&:hover\": {\n backgroundColor: \"transparent\",\n },\n },\n },\n\n track: {\n opacity: 1,\n borderRadius: 15,\n left: 17,\n height: 16,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo2,\n },\n\n thumb: {\n ...thumbPosition,\n border: `solid 1px ${theme.hv.palette.accent.acce1}`,\n backgroundColor: theme.hv.palette.atmosphere.atmo1,\n marginLeft: 2,\n marginTop: 0,\n },\n\n checked: {},\n\n disabled: {\n cursor: \"not-allowed\",\n\n \"& $switch\": {\n cursor: \"not-allowed\",\n },\n\n \"& $thumb\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n },\n\n \"& $switchBase + $track\": {\n backgroundColor: `${theme.hv.palette.atmosphere.atmo3}`,\n border: `solid 1px ${theme.hv.palette.atmosphere.atmo5}`,\n opacity: 1,\n },\n },\n\n readO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B,aADA;IAEHqB,MAAM,EAAG,aAAYf,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBC,MAAjB,CAAwBC,KAAM,EAFhD;IAGHN,eAAe,EAAEN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BG,KAH1C;IAIHC,UAAU,EAAE,CAJT;IAKHC,SAAS,EAAE;EALR,EA9CoB;EAsDzBC,OAAO,EAAE,EAtDgB;EAwDzBC,QAAQ,EAAE;IACRpB,MAAM,EAAE,aADA;IAGR,aAAa;MACXA,MAAM,EAAE;IADG,CAHL;IAOR,YAAY;MACVG,eAAe,EAAG,GAAEN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BQ,KAAM,EAD5C;MAEVT,MAAM,EAAG,aAAYf,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BS,KAAM;IAF7C,CAPJ;IAYR,0BAA0B;MACxBnB,eAAe,EAAG,GAAEN,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BQ,KAAM,EAD9B;MAExBT,MAAM,EAAG,aAAYf,KAAK,CAACS,EAAN,CAASC,OAAT,CAAiBM,UAAjB,CAA4BS,KAAM,EAF/B;MAGxBjB,OAAO,EAAE;IAHe;EAZlB,CAxDe;EA2EzBkB,QAAQ,EAAE,EA3Ee;EA6EzBC,YAAY;IACVb,YAAY,EAAE;EADJ,GAEPtB,aAFO;AA7Ea,CAAZ,CAAf;;AAmFA,eAAeO,MAAf"}
@@ -2,7 +2,7 @@ import "core-js/modules/web.dom-collections.iterator.js";
2
2
  import { useEffect, useRef, useState, useCallback } from "react";
3
3
  import { verticalScrollOffset, findFirstVisibleElement, isScrolledToTheBottom, getScrollTop, scrollElement } from "./utils";
4
4
 
5
- const useScrollTo = (selectedIndexProp = 0, scrollElementId, href, offset = 0, options, onChange) => {
5
+ const useScrollTo = (selectedIndexProp = 0, scrollElementId, href, offset = 0, options, onChange, direction = "column") => {
6
6
  const RETRY_MAX = 5;
7
7
  const [selectedIndex, setSelectedIndex] = useState(selectedIndexProp);
8
8
  const scrollEle = useRef();
@@ -114,7 +114,7 @@ const useScrollTo = (selectedIndexProp = 0, scrollElementId, href, offset = 0, o
114
114
  const ele = document.getElementById(id);
115
115
 
116
116
  if (ele) {
117
- scrollElement(ele, scrollEle.current, option.offset || offset);
117
+ scrollElement(ele, scrollEle.current, option.offset || offset, direction);
118
118
  }
119
119
 
120
120
  if (href) {
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollTo.js","names":["useEffect","useRef","useState","useCallback","verticalScrollOffset","findFirstVisibleElement","isScrolledToTheBottom","getScrollTop","scrollElement","useScrollTo","selectedIndexProp","scrollElementId","href","offset","options","onChange","RETRY_MAX","selectedIndex","setSelectedIndex","scrollEle","requestedAnimationFrame","lastContainerScrollTop","selectedIndexRef","current","document","getElementById","window","checkScroll","event","requestAnimationFrame","firstVisibleElementIndex","newSelectedIndex","length","containerScrollTop","isScrollingDown","addEventListener","removeEventListener","cancelAnimationFrame","checkRenderedInterval","hashValue","location","hash","split","option","find","o","value","retry","setInterval","ele","clearInterval","setScrollTo","id","index","wrappedOnChange","history","pushState"],"sources":["../../../src/ScrollTo/useScrollTo.js"],"sourcesContent":["import { useEffect, useRef, useState, useCallback } from \"react\";\nimport {\n verticalScrollOffset,\n findFirstVisibleElement,\n isScrolledToTheBottom,\n getScrollTop,\n scrollElement,\n} from \"./utils\";\n\nconst useScrollTo = (\n selectedIndexProp = 0,\n scrollElementId,\n href,\n offset = 0,\n options,\n onChange\n) => {\n const RETRY_MAX = 5;\n const [selectedIndex, setSelectedIndex] = useState(selectedIndexProp);\n\n const scrollEle = useRef();\n const requestedAnimationFrame = useRef(0);\n const lastContainerScrollTop = useRef();\n\n // ref to use a often-changing value in useCallback, as recommended in\n // https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n const selectedIndexRef = useRef(selectedIndex);\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n scrollEle.current = (scrollElementId && document.getElementById(scrollElementId)) || window;\n lastContainerScrollTop.current = verticalScrollOffset(scrollEle.current);\n }, [scrollElementId]);\n\n const checkScroll = useCallback(\n (event) => {\n if (requestedAnimationFrame.current === 0 && window?.requestAnimationFrame) {\n requestedAnimationFrame.current = window.requestAnimationFrame(() => {\n requestedAnimationFrame.current = 0;\n\n const firstVisibleElementIndex = findFirstVisibleElement(\n scrollEle.current,\n options,\n offset\n );\n\n let newSelectedIndex = firstVisibleElementIndex;\n\n // select the first element when all elements are bellow the container's top\n if (firstVisibleElementIndex < 0) {\n newSelectedIndex = 0;\n }\n\n // if the user has reached the bottom of the container, select the first nav item still visible\n // (usually this selects the last nav item, when it can't reach the top the container)\n // in theory only needed when scrolling down, but no... because of the Safari bouncing behaviour\n if (newSelectedIndex < options.length - 1 && isScrolledToTheBottom(scrollEle.current)) {\n newSelectedIndex += 1;\n }\n\n const containerScrollTop = getScrollTop(scrollEle.current);\n const isScrollingDown = containerScrollTop > lastContainerScrollTop.current;\n lastContainerScrollTop.current = containerScrollTop;\n\n // only update the selected item if the scroll direction is moving away from it\n if (isScrollingDown) {\n if (newSelectedIndex < selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n } else if (newSelectedIndex > selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n\n setSelectedIndex(newSelectedIndex);\n onChange?.(event, newSelectedIndex);\n });\n }\n },\n [offset, options, onChange]\n );\n\n // registers and unregisters the scroll listener\n useEffect(() => {\n if (scrollEle.current) {\n scrollEle.current.addEventListener(\"scroll\", checkScroll, false);\n }\n\n return () => {\n if (scrollEle.current) {\n scrollEle.current.removeEventListener(\"scroll\", checkScroll);\n }\n\n if (requestedAnimationFrame.current !== 0) {\n window.cancelAnimationFrame(requestedAnimationFrame.current);\n requestedAnimationFrame.current = 0;\n }\n };\n }, [checkScroll]);\n\n // waits for the elements to be rendered and scrolls to the one referenced\n // in the URL hash, if any\n useEffect(() => {\n let checkRenderedInterval;\n\n if (href) {\n const hashValue = document.location.hash.split(\"#\")[1] || \"\";\n\n const option = options.find((o) => o.value === hashValue);\n\n if (option) {\n let retry = 0;\n checkRenderedInterval = setInterval(() => {\n const ele = document.getElementById(option.value);\n\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n clearInterval(checkRenderedInterval);\n } else {\n retry += 1;\n if (retry === RETRY_MAX) {\n clearInterval(checkRenderedInterval);\n }\n }\n }, 1000);\n }\n }\n\n return () => {\n clearInterval(checkRenderedInterval);\n };\n\n // we really want to run this just in the first load\n // in fact this doesn't even belong here, the logic should be external\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const setScrollTo = (event, id, index, wrappedOnChange) => {\n const option = options.find((o) => o.value === id);\n\n if (option) {\n const ele = document.getElementById(id);\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n }\n\n if (href) {\n window.history.pushState({}, \"\", `#${options[index].value}`);\n }\n\n setSelectedIndex(index);\n wrappedOnChange?.(index);\n\n // Safari scrolls immediately (no smooth scroll support),\n // so this ref value must be updated asap\n selectedIndexRef.current = index;\n }\n };\n\n return [selectedIndex, setScrollTo];\n};\n\nexport default useScrollTo;\n"],"mappings":";AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,EAAsCC,WAAtC,QAAyD,OAAzD;AACA,SACEC,oBADF,EAEEC,uBAFF,EAGEC,qBAHF,EAIEC,YAJF,EAKEC,aALF,QAMO,SANP;;AAQA,MAAMC,WAAW,GAAG,CAClBC,iBAAiB,GAAG,CADF,EAElBC,eAFkB,EAGlBC,IAHkB,EAIlBC,MAAM,GAAG,CAJS,EAKlBC,OALkB,EAMlBC,QANkB,KAOf;EACH,MAAMC,SAAS,GAAG,CAAlB;EACA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoChB,QAAQ,CAACQ,iBAAD,CAAlD;EAEA,MAAMS,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,IAAIH,GAAJ,EAAS;QACPzC,aAAa,CAACyC,GAAD,EAAM9B,SAAS,CAACI,OAAhB,EAAyBoB,MAAM,CAAC9B,MAAP,IAAiBA,MAA1C,CAAb;MACD;;MAED,IAAID,IAAJ,EAAU;QACRc,MAAM,CAAC6B,OAAP,CAAeC,SAAf,CAAyB,EAAzB,EAA6B,EAA7B,EAAkC,IAAG1C,OAAO,CAACuC,KAAD,CAAP,CAAeP,KAAM,EAA1D;MACD;;MAED5B,gBAAgB,CAACmC,KAAD,CAAhB;MACAC,eAAe,SAAf,IAAAA,eAAe,WAAf,YAAAA,eAAe,CAAGD,KAAH,CAAf,CAXU,CAaV;MACA;;MACA/B,gBAAgB,CAACC,OAAjB,GAA2B8B,KAA3B;IACD;EACF,CApBD;;EAsBA,OAAO,CAACpC,aAAD,EAAgBkC,WAAhB,CAAP;AACD,CAxJD;;AA0JA,eAAe1C,WAAf"}
1
+ {"version":3,"file":"useScrollTo.js","names":["useEffect","useRef","useState","useCallback","verticalScrollOffset","findFirstVisibleElement","isScrolledToTheBottom","getScrollTop","scrollElement","useScrollTo","selectedIndexProp","scrollElementId","href","offset","options","onChange","direction","RETRY_MAX","selectedIndex","setSelectedIndex","scrollEle","requestedAnimationFrame","lastContainerScrollTop","selectedIndexRef","current","document","getElementById","window","checkScroll","event","requestAnimationFrame","firstVisibleElementIndex","newSelectedIndex","length","containerScrollTop","isScrollingDown","addEventListener","removeEventListener","cancelAnimationFrame","checkRenderedInterval","hashValue","location","hash","split","option","find","o","value","retry","setInterval","ele","clearInterval","setScrollTo","id","index","wrappedOnChange","history","pushState"],"sources":["../../../src/ScrollTo/useScrollTo.js"],"sourcesContent":["import { useEffect, useRef, useState, useCallback } from \"react\";\nimport {\n verticalScrollOffset,\n findFirstVisibleElement,\n isScrolledToTheBottom,\n getScrollTop,\n scrollElement,\n} from \"./utils\";\n\nconst useScrollTo = (\n selectedIndexProp = 0,\n scrollElementId,\n href,\n offset = 0,\n options,\n onChange,\n direction = \"column\"\n) => {\n const RETRY_MAX = 5;\n const [selectedIndex, setSelectedIndex] = useState(selectedIndexProp);\n\n const scrollEle = useRef();\n const requestedAnimationFrame = useRef(0);\n const lastContainerScrollTop = useRef();\n\n // ref to use a often-changing value in useCallback, as recommended in\n // https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n const selectedIndexRef = useRef(selectedIndex);\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n scrollEle.current = (scrollElementId && document.getElementById(scrollElementId)) || window;\n lastContainerScrollTop.current = verticalScrollOffset(scrollEle.current);\n }, [scrollElementId]);\n\n const checkScroll = useCallback(\n (event) => {\n if (requestedAnimationFrame.current === 0 && window?.requestAnimationFrame) {\n requestedAnimationFrame.current = window.requestAnimationFrame(() => {\n requestedAnimationFrame.current = 0;\n\n const firstVisibleElementIndex = findFirstVisibleElement(\n scrollEle.current,\n options,\n offset\n );\n\n let newSelectedIndex = firstVisibleElementIndex;\n\n // select the first element when all elements are bellow the container's top\n if (firstVisibleElementIndex < 0) {\n newSelectedIndex = 0;\n }\n\n // if the user has reached the bottom of the container, select the first nav item still visible\n // (usually this selects the last nav item, when it can't reach the top the container)\n // in theory only needed when scrolling down, but no... because of the Safari bouncing behaviour\n if (newSelectedIndex < options.length - 1 && isScrolledToTheBottom(scrollEle.current)) {\n newSelectedIndex += 1;\n }\n\n const containerScrollTop = getScrollTop(scrollEle.current);\n const isScrollingDown = containerScrollTop > lastContainerScrollTop.current;\n lastContainerScrollTop.current = containerScrollTop;\n\n // only update the selected item if the scroll direction is moving away from it\n if (isScrollingDown) {\n if (newSelectedIndex < selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n } else if (newSelectedIndex > selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n\n setSelectedIndex(newSelectedIndex);\n onChange?.(event, newSelectedIndex);\n });\n }\n },\n [offset, options, onChange]\n );\n\n // registers and unregisters the scroll listener\n useEffect(() => {\n if (scrollEle.current) {\n scrollEle.current.addEventListener(\"scroll\", checkScroll, false);\n }\n\n return () => {\n if (scrollEle.current) {\n scrollEle.current.removeEventListener(\"scroll\", checkScroll);\n }\n\n if (requestedAnimationFrame.current !== 0) {\n window.cancelAnimationFrame(requestedAnimationFrame.current);\n requestedAnimationFrame.current = 0;\n }\n };\n }, [checkScroll]);\n\n // waits for the elements to be rendered and scrolls to the one referenced\n // in the URL hash, if any\n useEffect(() => {\n let checkRenderedInterval;\n\n if (href) {\n const hashValue = document.location.hash.split(\"#\")[1] || \"\";\n\n const option = options.find((o) => o.value === hashValue);\n\n if (option) {\n let retry = 0;\n checkRenderedInterval = setInterval(() => {\n const ele = document.getElementById(option.value);\n\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n clearInterval(checkRenderedInterval);\n } else {\n retry += 1;\n if (retry === RETRY_MAX) {\n clearInterval(checkRenderedInterval);\n }\n }\n }, 1000);\n }\n }\n\n return () => {\n clearInterval(checkRenderedInterval);\n };\n\n // we really want to run this just in the first load\n // in fact this doesn't even belong here, the logic should be external\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const setScrollTo = (event, id, index, wrappedOnChange) => {\n const option = options.find((o) => o.value === id);\n\n if (option) {\n const ele = document.getElementById(id);\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset, direction);\n }\n\n if (href) {\n window.history.pushState({}, \"\", `#${options[index].value}`);\n }\n\n setSelectedIndex(index);\n wrappedOnChange?.(index);\n\n // Safari scrolls immediately (no smooth scroll support),\n // so this ref value must be updated asap\n selectedIndexRef.current = index;\n }\n };\n\n return [selectedIndex, setScrollTo];\n};\n\nexport default useScrollTo;\n"],"mappings":";AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,EAAsCC,WAAtC,QAAyD,OAAzD;AACA,SACEC,oBADF,EAEEC,uBAFF,EAGEC,qBAHF,EAIEC,YAJF,EAKEC,aALF,QAM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