@hitachivantara/uikit-react-core 5.36.5 → 5.36.7

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 (94) hide show
  1. package/dist/cjs/components/AppSwitcher/Action/Action.cjs +4 -2
  2. package/dist/cjs/components/AppSwitcher/Action/Action.cjs.map +1 -1
  3. package/dist/cjs/components/AppSwitcher/Action/Action.styles.cjs +6 -8
  4. package/dist/cjs/components/AppSwitcher/Action/Action.styles.cjs.map +1 -1
  5. package/dist/cjs/components/AppSwitcher/AppSwitcher.cjs +4 -2
  6. package/dist/cjs/components/AppSwitcher/AppSwitcher.cjs.map +1 -1
  7. package/dist/cjs/components/AppSwitcher/AppSwitcher.styles.cjs +4 -3
  8. package/dist/cjs/components/AppSwitcher/AppSwitcher.styles.cjs.map +1 -1
  9. package/dist/cjs/components/BreadCrumb/Page/Page.cjs +1 -1
  10. package/dist/cjs/components/Button/Button.cjs +0 -3
  11. package/dist/cjs/components/Button/Button.cjs.map +1 -1
  12. package/dist/cjs/components/Calendar/utils.cjs.map +1 -1
  13. package/dist/cjs/components/Dialog/Dialog.cjs +2 -5
  14. package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
  15. package/dist/cjs/components/Dropdown/Dropdown.cjs +0 -3
  16. package/dist/cjs/components/Dropdown/Dropdown.cjs.map +1 -1
  17. package/dist/cjs/components/FileUploader/File/File.cjs +3 -3
  18. package/dist/cjs/components/FileUploader/File/File.cjs.map +1 -1
  19. package/dist/cjs/components/Header/Navigation/MenuItem/MenuItem.styles.cjs.map +1 -1
  20. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.cjs +9 -2
  21. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.cjs.map +1 -1
  22. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.styles.cjs +2 -2
  23. package/dist/cjs/components/OverflowTooltip/OverflowTooltip.styles.cjs.map +1 -1
  24. package/dist/cjs/components/Snackbar/SnackbarProvider/SnackbarProvider.cjs +9 -14
  25. package/dist/cjs/components/Snackbar/SnackbarProvider/SnackbarProvider.cjs.map +1 -1
  26. package/dist/cjs/components/Tooltip/Tooltip.cjs +2 -1
  27. package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
  28. package/dist/cjs/components/TreeView/internals/DescendantProvider.cjs +0 -3
  29. package/dist/cjs/components/TreeView/internals/DescendantProvider.cjs.map +1 -1
  30. package/dist/cjs/components/TreeView/internals/TreeViewProvider.cjs +0 -3
  31. package/dist/cjs/components/TreeView/internals/TreeViewProvider.cjs.map +1 -1
  32. package/dist/cjs/components/Typography/utils.cjs +3 -13
  33. package/dist/cjs/components/Typography/utils.cjs.map +1 -1
  34. package/dist/cjs/components/VerticalNavigation/TreeView/descendants.cjs +0 -3
  35. package/dist/cjs/components/VerticalNavigation/TreeView/descendants.cjs.map +1 -1
  36. package/dist/cjs/hooks/useControlled.cjs +0 -3
  37. package/dist/cjs/hooks/useControlled.cjs.map +1 -1
  38. package/dist/cjs/providers/Provider.cjs +3 -2
  39. package/dist/cjs/providers/Provider.cjs.map +1 -1
  40. package/dist/cjs/utils/classes.cjs.map +1 -1
  41. package/dist/cjs/utils/document.cjs +11 -0
  42. package/dist/cjs/utils/document.cjs.map +1 -0
  43. package/dist/cjs/utils/theme.cjs +5 -7
  44. package/dist/cjs/utils/theme.cjs.map +1 -1
  45. package/dist/esm/components/AppSwitcher/Action/Action.js +4 -2
  46. package/dist/esm/components/AppSwitcher/Action/Action.js.map +1 -1
  47. package/dist/esm/components/AppSwitcher/Action/Action.styles.js +6 -8
  48. package/dist/esm/components/AppSwitcher/Action/Action.styles.js.map +1 -1
  49. package/dist/esm/components/AppSwitcher/AppSwitcher.js +4 -2
  50. package/dist/esm/components/AppSwitcher/AppSwitcher.js.map +1 -1
  51. package/dist/esm/components/AppSwitcher/AppSwitcher.styles.js +4 -3
  52. package/dist/esm/components/AppSwitcher/AppSwitcher.styles.js.map +1 -1
  53. package/dist/esm/components/BreadCrumb/Page/Page.js +1 -1
  54. package/dist/esm/components/Button/Button.js +0 -3
  55. package/dist/esm/components/Button/Button.js.map +1 -1
  56. package/dist/esm/components/Calendar/utils.js.map +1 -1
  57. package/dist/esm/components/Dialog/Dialog.js +2 -5
  58. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  59. package/dist/esm/components/Dropdown/Dropdown.js +0 -3
  60. package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
  61. package/dist/esm/components/FileUploader/File/File.js +2 -2
  62. package/dist/esm/components/FileUploader/File/File.js.map +1 -1
  63. package/dist/esm/components/Header/Navigation/MenuItem/MenuItem.styles.js.map +1 -1
  64. package/dist/esm/components/OverflowTooltip/OverflowTooltip.js +9 -2
  65. package/dist/esm/components/OverflowTooltip/OverflowTooltip.js.map +1 -1
  66. package/dist/esm/components/OverflowTooltip/OverflowTooltip.styles.js +2 -2
  67. package/dist/esm/components/OverflowTooltip/OverflowTooltip.styles.js.map +1 -1
  68. package/dist/esm/components/Snackbar/SnackbarProvider/SnackbarProvider.js +9 -14
  69. package/dist/esm/components/Snackbar/SnackbarProvider/SnackbarProvider.js.map +1 -1
  70. package/dist/esm/components/Tooltip/Tooltip.js +2 -1
  71. package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
  72. package/dist/esm/components/TreeView/internals/DescendantProvider.js +0 -3
  73. package/dist/esm/components/TreeView/internals/DescendantProvider.js.map +1 -1
  74. package/dist/esm/components/TreeView/internals/TreeViewProvider.js +0 -3
  75. package/dist/esm/components/TreeView/internals/TreeViewProvider.js.map +1 -1
  76. package/dist/esm/components/Typography/utils.js +3 -13
  77. package/dist/esm/components/Typography/utils.js.map +1 -1
  78. package/dist/esm/components/VerticalNavigation/TreeView/descendants.js +0 -3
  79. package/dist/esm/components/VerticalNavigation/TreeView/descendants.js.map +1 -1
  80. package/dist/esm/hooks/useControlled.js +0 -3
  81. package/dist/esm/hooks/useControlled.js.map +1 -1
  82. package/dist/esm/providers/Provider.js +4 -3
  83. package/dist/esm/providers/Provider.js.map +1 -1
  84. package/dist/esm/utils/classes.js.map +1 -1
  85. package/dist/esm/utils/document.js +11 -0
  86. package/dist/esm/utils/document.js.map +1 -0
  87. package/dist/esm/utils/theme.js +5 -7
  88. package/dist/esm/utils/theme.js.map +1 -1
  89. package/dist/types/index.d.ts +13 -9
  90. package/package.json +4 -4
  91. package/dist/cjs/components/AppSwitcher/TitleWithTooltip.cjs +0 -22
  92. package/dist/cjs/components/AppSwitcher/TitleWithTooltip.cjs.map +0 -1
  93. package/dist/esm/components/AppSwitcher/TitleWithTooltip.js +0 -22
  94. package/dist/esm/components/AppSwitcher/TitleWithTooltip.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/components/Calendar/utils.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\n\nimport capitalize from \"lodash/capitalize\";\n\nimport { DateRangeProp } from \"./types\";\n\n/**\n * Constant with the number of weeks to be displayed on the calendar.\n */\nexport const CALENDAR_WEEKS = 6;\n\n/**\n * Constant with the default locale that should be used as the default.\n */\nexport const DEFAULT_LOCALE = \"en\";\n\n/**\n * Pads a string value with leading zeroes(0) until length is reached.\n *\n * @param value - Value to be padded.\n * @param length - Length of the value after the padding is added.\n * @returns The value as a string with the received amount of padding.\n *\n * @example zeroPad(5, 2) => \"05\"\n */\nexport const zeroPad = (value: number, length: number) =>\n `${value}`.padStart(length, \"0\");\n\n/**\n * Returns the number of days in the month given a month and year.\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The number of days in a month for the received year.\n */\nexport const getMonthDays = (month: number, year: number) =>\n new Date(year, month, 0).getDate();\n\n/**\n * Gets the week day of the first day of a given month and year.\n * From 0 (Sunday) to 6 (Saturday).\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The zero indexed week day where 0 is Sunday (0 to 6).\n */\nexport const getMonthFirstWeekday = (month: number, year: number) =>\n new Date(year, month - 1, 1).getDay();\n\n/**\n * Creates a `Date` instance in UTC timezone.\n *\n * @param year - The year of the date.\n * @param monthIndex - The zero indexed month of the year (0 to 11).\n * @param day - The day of the month.\n * @param [hour=1] - The hour of the day.\n * @returns A `Date` instance in UTC timezone.\n */\nexport const makeUTCDate = (\n year: number,\n monthIndex: number,\n day: number,\n hour = 1\n) => new Date(Date.UTC(year, monthIndex, day, hour));\n\n/**\n * Checks if the received date is a valid date.\n *\n * @param date - The date to be validated.\n * @returns A flag stating if the date is valid or not.\n */\nexport const isDate = (date: any): date is Date =>\n Object.prototype.toString.call(date) === \"[object Date]\" &&\n !Number.isNaN(date.valueOf());\n\nexport const isDateRangeProp = (date: any): date is DateRangeProp =>\n \"startDate\" in date;\n\n/**\n * Checks if two dates are in the same month and year.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same month and year or not.\n */\nexport const isSameMonth = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Checks if two dates are on the same day.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same day or not.\n */\nexport const isSameDay = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getDate() === date2.getDate() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Formats the received date using the ISO format (YYYY-MM-DD).\n *\n * @param date - The date to be formatted.\n * @returns The formatted date in ISO format.\n */\nexport const getDateISO = (date?: Date) => {\n if (!isDate(date)) return null;\n\n return [\n date.getFullYear(),\n zeroPad(date.getMonth() + 1, 2),\n zeroPad(date.getDate(), 2),\n ].join(\"-\");\n};\n\n/**\n * Returns an object with the previous month taking also into consideration the year.\n * For example the previous month of January 2000 will be December 1999.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getPreviousMonth = (month: number, year: number) => {\n const prevMonth = month > 1 ? month - 1 : 12;\n const prevMonthYear = month > 1 ? year : year - 1;\n\n return { month: prevMonth, year: prevMonthYear };\n};\n\n/**\n * Returns an object with the next month taking also into consideration the year.\n * For example the next month of December 2000 will be January 2001.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getNextMonth = (month: number, year: number) => {\n const nextMonth = month < 12 ? month + 1 : 1;\n const nextMonthYear = month < 12 ? year : year + 1;\n\n return { month: nextMonth, year: nextMonthYear };\n};\n\n/**\n * Returns a list with the names of all the months localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The representation value for the month.\n * @returns An array with all the months names.\n */\nexport const getMonthNamesList = (\n locale: string | undefined,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) => {\n const options = { month: representationValue, timeZone: \"UTC\" };\n\n return [...new Array(12)].map((n, index) => {\n const auxDate = makeUTCDate(1970, index, 1);\n return capitalize(Intl.DateTimeFormat(locale, options).format(auxDate));\n });\n};\n\n/**\n * Returns a list with the names of all the weekdays localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied.\n * @returns An array with all the weekday names.\n */\nexport const getWeekdayNamesList = (locale: string) => {\n const formatter = new Intl.DateTimeFormat(locale, {\n weekday: \"narrow\",\n timeZone: \"UTC\",\n });\n\n return [...new Array(7)].map((n, index) => {\n return formatter.format(makeUTCDate(1970, 0, 4 + index));\n });\n};\n\n/**\n * Returns the name of the month for the supplied month localized in the received locale and representation value.\n *\n * @param date - The date from which the month name is extracted.\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The locale to be applied to the Intl format.\n * @returns The name of the month.\n */\nexport const getMonthName = (\n date: Date,\n locale: string,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) =>\n new Intl.DateTimeFormat(locale, { month: representationValue }).format(date);\n\n/**\n * Formats the received date according to Design System specifications.\n * Currently: day month, year => `14 Aug, 2019`.\n *\n * @param date - UTC date to be formatted.\n * @param locale - The locale to be applied to the Intl format.\n * @returns The formatted date as a string.\n */\nexport const getFormattedDate = (\n // TODO: fix this\n date: any,\n locale: any,\n rep: Intl.DateTimeFormatOptions[\"month\"] = \"short\"\n) =>\n `${date.getDate()} ${getMonthName(date, locale, rep)} ${date.getFullYear()}`;\n\n/**\n * Creates an array of 42 days. The complete current month and enough days from the previous and next months to fill\n * the 42 positions.\n *\n * @param month - The number of the month (1 to 12).\n * @param year - The number of the year.\n * @returns The array of dates.\n */\nexport const createDatesArray = (month: number, year: number) => {\n // Initializes the variables needed to calculate the dates for the received month and year\n const monthDays = getMonthDays(month, year);\n const daysFromPrevMonth = getMonthFirstWeekday(month, year);\n const daysFromNextMonth =\n CALENDAR_WEEKS * 7 - (daysFromPrevMonth + monthDays);\n const prevMonthYear = getPreviousMonth(month, year);\n const nextMonthYear = getNextMonth(month, year);\n const prevMonthDays = getMonthDays(prevMonthYear.month, prevMonthYear.year);\n\n // Creates the arrays for the dates for previous, current and next months\n const prevMonthDates = [...new Array(daysFromPrevMonth)].map((n, index) => {\n const day = index + 1 + (prevMonthDays - daysFromPrevMonth);\n return new Date(prevMonthYear.year, prevMonthYear.month - 1, day);\n });\n const currentMonthDates = [...new Array(monthDays)].map((n, index) => {\n const day = index + 1;\n return new Date(year, month - 1, day);\n });\n const nextMonthDates = [...new Array(daysFromNextMonth)].map((n, index) => {\n const day = index + 1;\n return new Date(nextMonthYear.year, nextMonthYear.month - 1, day);\n });\n\n return [...prevMonthDates, ...currentMonthDates, ...nextMonthDates];\n};\n\n/**\n * Checks if the received locale is valid according to Intl.\n *\n * @param locale - The locale to be checked\n * @returns True if the locale is valid, false otherwise.\n */\nexport const isValidLocale = (locale: string) => {\n try {\n if (Intl.DateTimeFormat.supportedLocalesOf(locale).length > 0) {\n return true;\n }\n // eslint-disable-next-line no-console\n console.warn(`${locale} is not supported. Falling back to a known locale.`);\n return false;\n } catch (error) {\n if (\n error != null &&\n typeof error === \"object\" &&\n \"name\" in error &&\n error?.name === \"RangeError\"\n ) {\n // eslint-disable-next-line no-console\n console.error(`Invalid locale: ${locale}`);\n return false;\n }\n if (error != null && typeof error === \"object\" && \"message\" in error) {\n // eslint-disable-next-line no-console\n console.error(error?.message);\n return false;\n }\n\n return false;\n }\n};\n\nexport const isRange = (date): date is DateRangeProp =>\n date != null && typeof date === \"object\" && \"startDate\" in date;\n\n/**\n * Checks if the date falls within a specified date range.\n *\n * @param date - The date to be evaluated.\n * @param providedValueRange - Provided selection range.\n * @returns - True if the date falls within the range, false otherwise.\n */\nexport const dateInProvidedValueRange = (\n date: any,\n providedValueRange: any\n) => {\n const { startDate, endDate } = providedValueRange;\n\n if (!isRange(providedValueRange) || endDate == null) return false;\n const localEndDate = endDate;\n\n const modStartDate = dayjs(startDate).format(\"YYYY-MM-DD\");\n const modEndDate = dayjs(localEndDate).format(\"YYYY-MM-DD\");\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return convertedDate >= modStartDate && convertedDate <= modEndDate;\n};\n\nexport const checkIfDateIsDisabled = (\n date?: string | number | Date | dayjs.Dayjs,\n minimumDate?: string | number | Date | dayjs.Dayjs,\n maximumDate?: string | number | Date | dayjs.Dayjs\n) => {\n if (!minimumDate && !maximumDate) return false;\n const modStartDate = minimumDate\n ? dayjs(minimumDate).format(\"YYYY-MM-DD\")\n : undefined;\n const modEndDate = maximumDate\n ? dayjs(maximumDate).format(\"YYYY-MM-DD\")\n : undefined;\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return (\n (modStartDate !== undefined && convertedDate < modStartDate) ||\n (modEndDate !== undefined && convertedDate > modEndDate)\n );\n};\n\nexport const formatToLocale = (date, locale) => {\n return new Intl.DateTimeFormat(locale, {\n day: \"numeric\",\n month: \"short\",\n year: \"numeric\",\n }).format(date);\n};\n"],"names":["CALENDAR_WEEKS","getMonthDays","month","year","Date","getDate","getMonthFirstWeekday","getDay","makeUTCDate","monthIndex","day","hour","UTC","isDate","date","Object","prototype","toString","call","Number","isNaN","valueOf","isDateRangeProp","isSameMonth","date1","date2","getMonth","getFullYear","isSameDay","getPreviousMonth","prevMonth","prevMonthYear","getNextMonth","nextMonth","nextMonthYear","getMonthNamesList","locale","representationValue","options","timeZone","Array","map","n","index","auxDate","capitalize","Intl","DateTimeFormat","format","getWeekdayNamesList","formatter","weekday","getMonthName","getFormattedDate","rep","createDatesArray","monthDays","daysFromPrevMonth","daysFromNextMonth","prevMonthDays","prevMonthDates","currentMonthDates","nextMonthDates","isRange","dateInProvidedValueRange","providedValueRange","startDate","endDate","localEndDate","modStartDate","dayjs","modEndDate","convertedDate","checkIfDateIsDisabled","minimumDate","maximumDate","undefined","formatToLocale"],"mappings":";;AASO,MAAMA,iBAAiB;AA0BjBC,MAAAA,eAAeA,CAACC,OAAeC,SAC1C,IAAIC,KAAKD,MAAMD,OAAO,CAAC,EAAEG,QAAQ;AAUtBC,MAAAA,uBAAuBA,CAACJ,OAAeC,SAClD,IAAIC,KAAKD,MAAMD,QAAQ,GAAG,CAAC,EAAEK,OAAO;AAW/B,MAAMC,cAAcA,CACzBL,MACAM,YACAC,KACAC,OAAO,MACJ,IAAIP,KAAKA,KAAKQ,IAAIT,MAAMM,YAAYC,KAAKC,IAAI,CAAC;AAQ5C,MAAME,SAASA,CAACC,SACrBC,OAAOC,UAAUC,SAASC,KAAKJ,IAAI,MAAM,mBACzC,CAACK,OAAOC,MAAMN,KAAKO,SAAS;AAEjBC,MAAAA,kBAAkBA,CAACR,SAC9B,eAAeA;AASJS,MAAAA,cAAcA,CAACC,OAAYC,UAAe;AACrD,MAAI,EAAEZ,OAAOW,KAAK,KAAKX,OAAOY,KAAK;AAAW,WAAA;AAG5CD,SAAAA,MAAME,eAAeD,MAAMC,SAAAA,KAC3BF,MAAMG,YAAkBF,MAAAA,MAAME;AAElC;AASaC,MAAAA,YAAYA,CAACJ,OAAYC,UAAe;AACnD,MAAI,EAAEZ,OAAOW,K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IACPC,MAAM;AAAA,EAAA,CACP,EAAE6C,OAAOlC,IAAI;AAChB;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/components/Calendar/utils.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\n\nimport capitalize from \"lodash/capitalize\";\n\nimport { DateRangeProp } from \"./types\";\n\n/**\n * Constant with the number of weeks to be displayed on the calendar.\n */\nexport const CALENDAR_WEEKS = 6;\n\n/**\n * Constant with the default locale that should be used as the default.\n */\nexport const DEFAULT_LOCALE = \"en\";\n\n/**\n * Pads a string value with leading zeroes(0) until length is reached.\n *\n * @param value - Value to be padded.\n * @param length - Length of the value after the padding is added.\n * @returns The value as a string with the received amount of padding.\n *\n * @example zeroPad(5, 2) => \"05\"\n */\nexport const zeroPad = (value: number, length: number) =>\n `${value}`.padStart(length, \"0\");\n\n/**\n * Returns the number of days in the month given a month and year.\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The number of days in a month for the received year.\n */\nexport const getMonthDays = (month: number, year: number) =>\n new Date(year, month, 0).getDate();\n\n/**\n * Gets the week day of the first day of a given month and year.\n * From 0 (Sunday) to 6 (Saturday).\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @returns The zero indexed week day where 0 is Sunday (0 to 6).\n */\nexport const getMonthFirstWeekday = (month: number, year: number) =>\n new Date(year, month - 1, 1).getDay();\n\n/**\n * Creates a `Date` instance in UTC timezone.\n *\n * @param year - The year of the date.\n * @param monthIndex - The zero indexed month of the year (0 to 11).\n * @param day - The day of the month.\n * @param [hour=1] - The hour of the day.\n * @returns A `Date` instance in UTC timezone.\n */\nexport const makeUTCDate = (\n year: number,\n monthIndex: number,\n day: number,\n hour = 1\n) => new Date(Date.UTC(year, monthIndex, day, hour));\n\n/**\n * Checks if the received date is a valid date.\n *\n * @param date - The date to be validated.\n * @returns A flag stating if the date is valid or not.\n */\nexport const isDate = (date: any): date is Date =>\n Object.prototype.toString.call(date) === \"[object Date]\" &&\n !Number.isNaN(date.valueOf());\n\nexport const isDateRangeProp = (date: any): date is DateRangeProp =>\n \"startDate\" in date;\n\n/**\n * Checks if two dates are in the same month and year.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same month and year or not.\n */\nexport const isSameMonth = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Checks if two dates are on the same day.\n *\n * @param date1 - First date.\n * @param date2 - Second date.\n * @returns A flag stating if the dates are in the same day or not.\n */\nexport const isSameDay = (date1: any, date2: any) => {\n if (!(isDate(date1) && isDate(date2))) return false;\n\n return (\n date1.getDate() === date2.getDate() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n};\n\n/**\n * Formats the received date using the ISO format (YYYY-MM-DD).\n *\n * @param date - The date to be formatted.\n * @returns The formatted date in ISO format.\n */\nexport const getDateISO = (date?: Date) => {\n if (!isDate(date)) return null;\n\n return [\n date.getFullYear(),\n zeroPad(date.getMonth() + 1, 2),\n zeroPad(date.getDate(), 2),\n ].join(\"-\");\n};\n\n/**\n * Returns an object with the previous month taking also into consideration the year.\n * For example the previous month of January 2000 will be December 1999.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getPreviousMonth = (month: number, year: number) => {\n const prevMonth = month > 1 ? month - 1 : 12;\n const prevMonthYear = month > 1 ? year : year - 1;\n\n return { month: prevMonth, year: prevMonthYear };\n};\n\n/**\n * Returns an object with the next month taking also into consideration the year.\n * For example the next month of December 2000 will be January 2001.\n *\n * @param month - Number of the month.\n * @param year - Number of the year.\n * @returns Object with new month and year defined.\n */\nexport const getNextMonth = (month: number, year: number) => {\n const nextMonth = month < 12 ? month + 1 : 1;\n const nextMonthYear = month < 12 ? year : year + 1;\n\n return { month: nextMonth, year: nextMonthYear };\n};\n\n/**\n * Returns a list with the names of all the months localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The representation value for the month.\n * @returns An array with all the months names.\n */\nexport const getMonthNamesList = (\n locale: string | undefined,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) => {\n const options = { month: representationValue, timeZone: \"UTC\" };\n\n return [...new Array(12)].map((n, index) => {\n const auxDate = makeUTCDate(1970, index, 1);\n return capitalize(Intl.DateTimeFormat(locale, options).format(auxDate));\n });\n};\n\n/**\n * Returns a list with the names of all the weekdays localized in the received locale and representation value.\n *\n * @param locale - The locale to be applied.\n * @returns An array with all the weekday names.\n */\nexport const getWeekdayNamesList = (locale: string) => {\n const formatter = new Intl.DateTimeFormat(locale, {\n weekday: \"narrow\",\n timeZone: \"UTC\",\n });\n\n return [...new Array(7)].map((n, index) => {\n return formatter.format(makeUTCDate(1970, 0, 4 + index));\n });\n};\n\n/**\n * Returns the name of the month for the supplied month localized in the received locale and representation value.\n *\n * @param date - The date from which the month name is extracted.\n * @param locale - The locale to be applied to the Intl format.\n * @param representationValue - The locale to be applied to the Intl format.\n * @returns The name of the month.\n */\nexport const getMonthName = (\n date: Date,\n locale: string,\n representationValue: Intl.DateTimeFormatOptions[\"month\"] = \"long\"\n) =>\n new Intl.DateTimeFormat(locale, { month: representationValue }).format(date);\n\n/**\n * Formats the received date according to Design System specifications.\n * Currently: day month, year => `14 Aug, 2019`.\n *\n * @param date - UTC date to be formatted.\n * @param locale - The locale to be applied to the Intl format.\n * @returns The formatted date as a string.\n */\nexport const getFormattedDate = (\n // TODO: fix this\n date: any,\n locale: any,\n rep: Intl.DateTimeFormatOptions[\"month\"] = \"short\"\n) =>\n `${date.getDate()} ${getMonthName(date, locale, rep)} ${date.getFullYear()}`;\n\n/**\n * Creates an array of 42 days. The complete current month and enough days from the previous and next months to fill\n * the 42 positions.\n *\n * @param month - The number of the month (1 to 12).\n * @param year - The number of the year.\n * @returns The array of dates.\n */\nexport const createDatesArray = (month: number, year: number) => {\n // Initializes the variables needed to calculate the dates for the received month and year\n const monthDays = getMonthDays(month, year);\n const daysFromPrevMonth = getMonthFirstWeekday(month, year);\n const daysFromNextMonth =\n CALENDAR_WEEKS * 7 - (daysFromPrevMonth + monthDays);\n const prevMonthYear = getPreviousMonth(month, year);\n const nextMonthYear = getNextMonth(month, year);\n const prevMonthDays = getMonthDays(prevMonthYear.month, prevMonthYear.year);\n\n // Creates the arrays for the dates for previous, current and next months\n const prevMonthDates = [...new Array(daysFromPrevMonth)].map((n, index) => {\n const day = index + 1 + (prevMonthDays - daysFromPrevMonth);\n return new Date(prevMonthYear.year, prevMonthYear.month - 1, day);\n });\n const currentMonthDates = [...new Array(monthDays)].map((n, index) => {\n const day = index + 1;\n return new Date(year, month - 1, day);\n });\n const nextMonthDates = [...new Array(daysFromNextMonth)].map((n, index) => {\n const day = index + 1;\n return new Date(nextMonthYear.year, nextMonthYear.month - 1, day);\n });\n\n return [...prevMonthDates, ...currentMonthDates, ...nextMonthDates];\n};\n\nexport const isRange = (date): date is DateRangeProp =>\n date != null && typeof date === \"object\" && \"startDate\" in date;\n\n/**\n * Checks if the date falls within a specified date range.\n *\n * @param date - The date to be evaluated.\n * @param providedValueRange - Provided selection range.\n * @returns - True if the date falls within the range, false otherwise.\n */\nexport const dateInProvidedValueRange = (\n date: any,\n providedValueRange: any\n) => {\n const { startDate, endDate } = providedValueRange;\n\n if (!isRange(providedValueRange) || endDate == null) return false;\n const localEndDate = endDate;\n\n const modStartDate = dayjs(startDate).format(\"YYYY-MM-DD\");\n const modEndDate = dayjs(localEndDate).format(\"YYYY-MM-DD\");\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return convertedDate >= modStartDate && convertedDate <= modEndDate;\n};\n\nexport const checkIfDateIsDisabled = (\n date?: string | number | Date | dayjs.Dayjs,\n minimumDate?: string | number | Date | dayjs.Dayjs,\n maximumDate?: string | number | Date | dayjs.Dayjs\n) => {\n if (!minimumDate && !maximumDate) return false;\n const modStartDate = minimumDate\n ? dayjs(minimumDate).format(\"YYYY-MM-DD\")\n : undefined;\n const modEndDate = maximumDate\n ? dayjs(maximumDate).format(\"YYYY-MM-DD\")\n : undefined;\n\n const convertedDate = dayjs(date).format(\"YYYY-MM-DD\");\n\n return (\n (modStartDate !== undefined && convertedDate < modStartDate) ||\n (modEndDate !== undefined && convertedDate > modEndDate)\n );\n};\n\nexport const formatToLocale = (date, locale) => {\n return new Intl.DateTimeFormat(locale, {\n day: \"numeric\",\n month: \"short\",\n year: \"numeric\",\n }).format(date);\n};\n"],"names":["CALENDAR_WEEKS","getMonthDays","month","year","Date","getDate","getMonthFirstWeekday","getDay","makeUTCDate","monthIndex","day","hour","UTC","isDate","date","Object","prototype","toString","call","Number","isNaN","valueOf","isDateRangeProp","isSameMonth","date1","date2","getMonth","getFullYear","isSameDay","getPreviousMonth","prevMonth","prevMonthYear","getNextMonth","nextMonth","nextMonthYear","getMonthNamesList","locale","representationValue","options","timeZone","Array","map","n","index","auxDate","capitalize","Intl","DateTimeFormat","format","getWeekdayNamesList","formatter","weekday","getMonthName","getFormattedDate","rep","createDatesArray","monthDays","daysFromPrevMonth","daysFromNextMonth","prevMonthDays","prevMonthDates","currentMonthDates","nextMonthDates","isRange","dateInProvidedValueRange","providedValueRange","startDate","endDate","localEndDate","modStartDate","dayjs","modEndDate","convertedDate","checkIfDateIsDisabled","minimumDate","maximumDate","undefined","formatToLocale"],"mappings":";;AASO,MAAMA,iBAAiB;AA0BjBC,MAAAA,eAAeA,CAACC,OAAeC,SAC1C,IAAIC,KAAKD,MAAMD,OAAO,CAAC,EAAEG,QAAQ;AAUtBC,MAAAA,uBAAuBA,CAACJ,OAAeC,SAClD,IAAIC,KAAKD,MAAMD,QAAQ,GAAG,CAAC,EAAEK,OAAO;AAW/B,MAAMC,cAAcA,CACzBL,MACAM,YACAC,KACAC,OAAO,MACJ,IAAIP,KAAKA,KAAKQ,IAAIT,MAAMM,YAAYC,KAAKC,IAAI,CAAC;AA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WAAA;AACzC,QAAMN,eAAeK,cACjBJ,MAAMI,WAAW,EAAE1B,OAAO,YAAY,IACtC4B;AACJ,QAAML,aAAaI,cACfL,MAAMK,WAAW,EAAE3B,OAAO,YAAY,IACtC4B;AAEJ,QAAMJ,gBAAgBF,MAAMxD,IAAI,EAAEkC,OAAO,YAAY;AAErD,SACGqB,iBAAiBO,UAAaJ,gBAAgBH,gBAC9CE,eAAeK,UAAaJ,gBAAgBD;AAEjD;AAEaM,MAAAA,iBAAiBA,CAAC/D,MAAMsB,WAAW;AACvC,SAAA,IAAIU,KAAKC,eAAeX,QAAQ;AAAA,IACrC1B,KAAK;AAAA,IACLR,OAAO;AAAA,IACPC,MAAM;AAAA,EAAA,CACP,EAAE6C,OAAOlC,IAAI;AAChB;"}
@@ -4,6 +4,7 @@ import MuiDialog from "@mui/material/Dialog";
4
4
  import { Close } from "@hitachivantara/uikit-react-icons";
5
5
  import { theme } from "@hitachivantara/uikit-styles";
6
6
  import { useDefaultProps } from "../../hooks/useDefaultProps.js";
7
+ import { getElementById } from "../../utils/document.js";
7
8
  import { setId } from "../../utils/setId.js";
8
9
  import { useTheme } from "../../hooks/useTheme.js";
9
10
  import { hexToRgbA } from "../../utils/hexToRgbA.js";
@@ -45,11 +46,7 @@ const HvDialog = (props) => {
45
46
  const contextValue = useMemo(() => ({
46
47
  fullscreen
47
48
  }), [fullscreen]);
48
- return /* @__PURE__ */ jsxs(MuiDialog, { container: typeof window !== "undefined" ? (
49
- // TODO: review
50
- // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
51
- document.getElementById(rootId || "") || document.body
52
- ) : void 0, className: cx(classes.root, className), classes: {
49
+ return /* @__PURE__ */ jsxs(MuiDialog, { container: getElementById(rootId), className: cx(classes.root, className), classes: {
53
50
  container: css({
54
51
  position: "relative"
55
52
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\n\nimport MuiDialog, { DialogProps as MuiDialogProps } from \"@mui/material/Dialog\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTooltip } from \"@core/components/Tooltip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport { staticClasses, useClasses } from \"./Dialog.styles\";\nimport { DialogContext } from \"./context\";\n\nexport { staticClasses as dialogClasses };\n\nexport type HvDialogClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDialogProps\n extends Omit<MuiDialogProps, \"fullScreen\" | \"classes\" | \"open\">,\n HvBaseProps {\n /** Current state of the Dialog. */\n open?: boolean;\n /** Callback fired when the component requests to be closed. */\n onClose?: (event: any, reason?: \"escapeKeyDown\" | \"backdropClick\") => void;\n /** @inheritdoc */\n maxWidth?: MuiDialogProps[\"maxWidth\"];\n /** @inheritdoc */\n fullWidth?: MuiDialogProps[\"fullWidth\"];\n /**\n * Element id that should be focus when the Dialog opens.\n * Auto-focusing elements can cause usability issues, so this should be avoided.\n * @deprecated Use `autoFocus` on the element instead, if auto-focusing is required.\n */\n firstFocusable?: string;\n /** Title for the button close. */\n buttonTitle?: string;\n /** Set the dialog to fullscreen mode. */\n fullscreen?: boolean;\n /** Prevent closing the dialog when clicking on the backdrop. */\n disableBackdropClick?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDialogClasses;\n /** Variant of the dialog. Adds a status bar to the top of the dialog. If not provided, no status bar is added. */\n variant?: \"success\" | \"error\" | \"warning\";\n /** @ignore */\n ref?: MuiDialogProps[\"ref\"];\n /** @ignore */\n component?: MuiDialogProps[\"component\"];\n}\n\nexport const HvDialog = (props: HvDialogProps) => {\n const {\n variant,\n classes: classesProp,\n className,\n id,\n children,\n open = false,\n onClose,\n firstFocusable,\n buttonTitle = \"Close\",\n fullscreen = false,\n disableBackdropClick = false,\n ...others\n } = useDefaultProps(\"HvDialog\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { rootId, colors } = useTheme();\n\n const measuredRef = useCallback(() => {\n if (!firstFocusable) return;\n\n const element = document.getElementById(firstFocusable);\n element?.focus();\n }, [firstFocusable]);\n\n const contextValue = useMemo(() => ({ fullscreen }), [fullscreen]);\n\n return (\n <MuiDialog\n container={\n typeof window !== \"undefined\"\n ? // TODO: review\n // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc\n document.getElementById(rootId || \"\") || document.body\n : undefined\n }\n className={cx(classes.root, className)}\n classes={{ container: css({ position: \"relative\" }) }}\n id={id}\n ref={measuredRef}\n open={open}\n fullScreen={fullscreen}\n onClose={(event, reason) => {\n // `disableBackdropClick` property was removed in MUI5\n // and we want to maintain that functionality\n if (disableBackdropClick) return;\n\n onClose?.(event, reason);\n }}\n slotProps={{\n backdrop: {\n classes: {\n root: cx(\n css({\n background: hexToRgbA(colors?.atmo4 || theme.colors.atmo4, 0.8),\n }),\n classes.background\n ),\n },\n },\n }}\n PaperProps={{\n classes: {\n root: cx(\n css({ position: \"absolute\" }),\n classes.paper,\n variant && cx(classes.statusBar, classes[variant]),\n {\n [classes.fullscreen]: fullscreen,\n }\n ),\n },\n }}\n aria-modal\n {...others}\n >\n <HvTooltip placement=\"top\" title={buttonTitle}>\n <HvButton\n id={setId(id, \"close\")}\n className={classes.closeButton}\n variant=\"secondaryGhost\"\n onClick={(event) => onClose?.(event, undefined)}\n >\n <Close role=\"none\" />\n </HvButton>\n </HvTooltip>\n <DialogContext.Provider value={contextValue}>\n {children}\n </DialogContext.Provider>\n </MuiDialog>\n );\n};\n"],"names":["HvDialog","props","variant","classes","classesProp","className","id","children","open","onClose","firstFocusable","buttonTitle","fullscreen","disableBackdropClick","others","useDefaultProps","css","cx","useClasses","rootId","colors","useTheme","measuredRef","useCallback","element","document","getElementById","focus","contextValue","useMemo","window","body","undefined","root","container","position","event","reason","backdrop","background","hexToRgbA","atmo4","theme","paper","statusBar","setId","closeButton"],"mappings":";;;;;;;;;;;;;;AAyDaA,MAAAA,WAAWA,CAACC,UAAyB;AAC1C,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,OAAO;AAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC,uBAAuB;AAAA,IACvB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,YAAYd,KAAK;AAE/B,QAAA;AAAA,IAAEE;AAAAA,IAASa;AAAAA,IAAKC;AAAAA,EAAAA,IAAOC,WAAWd,WAAW;AAC7C,QAAA;AAAA,IAAEe;AAAAA,IAAQC;AAAAA,MAAWC,SAAS;AAE9BC,QAAAA,cAAcC,YAAY,MAAM;AACpC,QAAI,CAACb;AAAgB;AAEfc,UAAAA,UAAUC,SAASC,eAAehB,cAAc;AACtDc,aAASG,MAAM;AAAA,EAAA,GACd,CAACjB,cAAc,CAAC;AAEbkB,QAAAA,eAAeC,QAAQ,OAAO;AAAA,IAAEjB;AAAAA,EAAAA,IAAe,CAACA,UAAU,CAAC;AAEjE,SACG,qBAAA,WAAA,EACC,WACE,OAAOkB,WAAW;AAAA;AAAA;AAAA,IAGdL,SAASC,eAAeP,UAAU,EAAE,KAAKM,SAASM;AAAAA,MAClDC,QAEN,WAAWf,GAAGd,QAAQ8B,MAAM5B,SAAS,GACrC,SAAS;AAAA,IAAE6B,WAAWlB,IAAI;AAAA,MAAEmB,UAAU;AAAA,IAAA,CAAY;AAAA,EAAA,GAClD,IACA,KAAKb,aACL,MACA,YAAYV,YACZ,SAAS,CAACwB,OAAOC,WAAW;AAGtBxB,QAAAA;AAAsB;AAE1BJ,cAAU2B,OAAOC,MAAM;AAAA,KAEzB,WAAW;AAAA,IACTC,UAAU;AAAA,MACRnC,SAAS;AAAA,QACP8B,MAAMhB,GACJD,IAAI;AAAA,UACFuB,YAAYC,UAAUpB,QAAQqB,SAASC,MAAMtB,OAAOqB,OAAO,GAAG;AAAA,QAAA,CAC/D,GACDtC,QAAQoC,UACV;AAAA,MACF;AAAA,IACF;AAAA,KAEF,YAAY;AAAA,IACVpC,SAAS;AAAA,MACP8B,MAAMhB,GACJD,IAAI;AAAA,QAAEmB,UAAU;AAAA,MAAA,CAAY,GAC5BhC,QAAQwC,OACRzC,WAAWe,GAAGd,QAAQyC,WAAWzC,QAAQD,OAAO,CAAC,GACjD;AAAA,QACE,CAACC,QAAQS,UAAU,GAAGA;AAAAA,MAAAA,CAE1B;AAAA,IACF;AAAA,EAEF,GAAA,cAAU,MACV,GAAIE,QAEJ,UAAA;AAAA,IAAA,oBAAC,WAAU,EAAA,WAAU,OAAM,OAAOH,aAChC,UAAA,oBAAC,UACC,EAAA,IAAIkC,MAAMvC,IAAI,OAAO,GACrB,WAAWH,QAAQ2C,aACnB,SAAQ,kBACR,SAAUV,CAAU3B,UAAAA,UAAU2B,OAAOJ,MAAS,GAE9C,UAAA,oBAAC,OAAM,EAAA,MAAK,OAAM,CAAA,EACpB,CAAA,GACF;AAAA,wBACC,cAAc,UAAd,EAAuB,OAAOJ,cAC5BrB,UACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\n\nimport MuiDialog, { DialogProps as MuiDialogProps } from \"@mui/material/Dialog\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTooltip } from \"@core/components/Tooltip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { getElementById } from \"@core/utils/document\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport { staticClasses, useClasses } from \"./Dialog.styles\";\nimport { DialogContext } from \"./context\";\n\nexport { staticClasses as dialogClasses };\n\nexport type HvDialogClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDialogProps\n extends Omit<MuiDialogProps, \"fullScreen\" | \"classes\" | \"open\">,\n HvBaseProps {\n /** Current state of the Dialog. */\n open?: boolean;\n /** Callback fired when the component requests to be closed. */\n onClose?: (event: any, reason?: \"escapeKeyDown\" | \"backdropClick\") => void;\n /** @inheritdoc */\n maxWidth?: MuiDialogProps[\"maxWidth\"];\n /** @inheritdoc */\n fullWidth?: MuiDialogProps[\"fullWidth\"];\n /**\n * Element id that should be focus when the Dialog opens.\n * Auto-focusing elements can cause usability issues, so this should be avoided.\n * @deprecated Use `autoFocus` on the element instead, if auto-focusing is required.\n */\n firstFocusable?: string;\n /** Title for the button close. */\n buttonTitle?: string;\n /** Set the dialog to fullscreen mode. */\n fullscreen?: boolean;\n /** Prevent closing the dialog when clicking on the backdrop. */\n disableBackdropClick?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDialogClasses;\n /** Variant of the dialog. Adds a status bar to the top of the dialog. If not provided, no status bar is added. */\n variant?: \"success\" | \"error\" | \"warning\";\n /** @ignore */\n ref?: MuiDialogProps[\"ref\"];\n /** @ignore */\n component?: MuiDialogProps[\"component\"];\n}\n\nexport const HvDialog = (props: HvDialogProps) => {\n const {\n variant,\n classes: classesProp,\n className,\n id,\n children,\n open = false,\n onClose,\n firstFocusable,\n buttonTitle = \"Close\",\n fullscreen = false,\n disableBackdropClick = false,\n ...others\n } = useDefaultProps(\"HvDialog\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const { rootId, colors } = useTheme();\n\n const measuredRef = useCallback(() => {\n if (!firstFocusable) return;\n\n const element = document.getElementById(firstFocusable);\n element?.focus();\n }, [firstFocusable]);\n\n const contextValue = useMemo(() => ({ fullscreen }), [fullscreen]);\n\n return (\n <MuiDialog\n container={getElementById(rootId)}\n className={cx(classes.root, className)}\n classes={{ container: css({ position: \"relative\" }) }}\n id={id}\n ref={measuredRef}\n open={open}\n fullScreen={fullscreen}\n onClose={(event, reason) => {\n // `disableBackdropClick` property was removed in MUI5\n // and we want to maintain that functionality\n if (disableBackdropClick) return;\n\n onClose?.(event, reason);\n }}\n slotProps={{\n backdrop: {\n classes: {\n root: cx(\n css({\n background: hexToRgbA(colors?.atmo4 || theme.colors.atmo4, 0.8),\n }),\n classes.background\n ),\n },\n },\n }}\n PaperProps={{\n classes: {\n root: cx(\n css({ position: \"absolute\" }),\n classes.paper,\n variant && cx(classes.statusBar, classes[variant]),\n {\n [classes.fullscreen]: fullscreen,\n }\n ),\n },\n }}\n aria-modal\n {...others}\n >\n <HvTooltip placement=\"top\" title={buttonTitle}>\n <HvButton\n id={setId(id, \"close\")}\n className={classes.closeButton}\n variant=\"secondaryGhost\"\n onClick={(event) => onClose?.(event, undefined)}\n >\n <Close role=\"none\" />\n </HvButton>\n </HvTooltip>\n <DialogContext.Provider value={contextValue}>\n {children}\n </DialogContext.Provider>\n </MuiDialog>\n );\n};\n"],"names":["HvDialog","props","variant","classes","classesProp","className","id","children","open","onClose","firstFocusable","buttonTitle","fullscreen","disableBackdropClick","others","useDefaultProps","css","cx","useClasses","rootId","colors","useTheme","measuredRef","useCallback","element","document","getElementById","focus","contextValue","useMemo","root","container","position","event","reason","backdrop","background","hexToRgbA","atmo4","theme","paper","statusBar","setId","closeButton","undefined"],"mappings":";;;;;;;;;;;;;;;AA0DaA,MAAAA,WAAWA,CAACC,UAAyB;AAC1C,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,OAAO;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tC,QAAQD,OAAO,CAAC,GACjD;AAAA,QACE,CAACC,QAAQS,UAAU,GAAGA;AAAAA,MAAAA,CAE1B;AAAA,IACF;AAAA,EAEF,GAAA,cAAU,MACV,GAAIE,QAEJ,UAAA;AAAA,IAAA,oBAAC,WAAU,EAAA,WAAU,OAAM,OAAOH,aAChC,UAAA,oBAAC,UACC,EAAA,IAAI+B,MAAMpC,IAAI,OAAO,GACrB,WAAWH,QAAQwC,aACnB,SAAQ,kBACR,SAAUV,CAAUxB,UAAAA,UAAUwB,OAAOW,MAAS,GAE9C,UAAA,oBAAC,OAAM,EAAA,MAAK,OAAM,CAAA,EACpB,CAAA,GACF;AAAA,wBACC,cAAc,UAAd,EAAuB,OAAOhB,cAC5BrB,UACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -86,9 +86,6 @@ const HvDropdown = forwardRef((props, ref) => {
86
86
  useEffect(() => {
87
87
  setSelectionLabel(getSelectionLabel(labels, placeholder, multiSelect, values));
88
88
  }, [labels, multiSelect, placeholder, values]);
89
- if (virtualized && !height && process.env.NODE_ENV !== "production") {
90
- console.error("Dropdown/List in virtualized mode requires a height. Please define it.");
91
- }
92
89
  const dropdownHeaderRef = useRef();
93
90
  const {
94
91
  ref: refProp,
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps, useForkRef } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvDropdownStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = forwardRef<HTMLDivElement, HvDropdownProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n const [internalValues, setInternalValues] = useState(values);\n\n useEffect(() => {\n setInternalValues(values);\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (virtualized && !height && process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const {\n ref: refProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n ...otherBaseDropdownProps\n } = baseDropdownProps;\n const headerForkedRef = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderRef\n );\n\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection = getSelected(internalValues).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null\n ? [...containerRef.getElementsByTagName(\"li\")]\n : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = isInvalid(validationState);\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n ref={dropdownForkedRef}\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={headerForkedRef}\n {...otherBaseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","forwardRef","props","ref","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","useEffect","process","env","NODE_ENV","console","error","dropdownHeaderRef","useRef","refProp","dropdownHeaderRefProp","otherBaseDropdownProps","headerForkedRef","useForkRef","dropdownForkedRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","current","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","selectionDisabled","placeholderClosed","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","root","labelContainer","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","rootList","dropdownListContainer"],"mappings":";;;;;;;;;;;;;;;;;;;AA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A;AAAA,IACCmE,gBACC,oBAAC,eACC,EAAA,IAAII,MAAMjE,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQmE,OAElBf,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;"}
1
+ {"version":3,"file":"Dropdown.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState } from \"react\";\n\nimport { PopperProps, useForkRef } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { setId } from \"@core/utils/setId\";\nimport { useLabels, useUniqueId, useControlled } from \"@core/hooks\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvListValue } from \"@core/components/List\";\nimport {\n isInvalid,\n HvInfoMessage,\n HvWarningText,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { getSelected, getSelectionLabel } from \"./utils\";\nimport { HvDropdownList, HvDropdownListProps } from \"./List\";\nimport { staticClasses, useClasses } from \"./Dropdown.styles\";\nimport { HvDropdownLabelsProps, HvDropdownStatus } from \"./types\";\n\nexport { staticClasses as dropdownClasses };\n\nexport type HvDropdownClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvDropdownClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: any;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: any;\n /**\n * The placeholder value when nothing is selected.\n */\n placeholder?: string;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvDropdownStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: any;\n /**\n * Identifies the element that provides an error message for the dropdown.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (selected: HvListValue | HvListValue[] | undefined) => void;\n /**\n * The list to be rendered by the dropdown.\n */\n values?: HvListValue[];\n /**\n * If `true` the dropdown is multiSelect, if `false` the dropdown is single select.\n */\n multiSelect?: boolean;\n /**\n * If `true` the dropdown is rendered with a search bar, if `false` there won't be a search bar.\n */\n showSearch?: boolean;\n /**\n * If `true` the dropdown starts opened if `false` it starts closed.\n */\n expanded?: boolean;\n /**\n * When uncontrolled, defines the initial expanded state.\n */\n defaultExpanded?: boolean;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * Disable the portal behavior.\n * The children stay within it's parent DOM hierarchy.\n */\n disablePortal?: boolean;\n /**\n * If `true` the dropdown width depends size of content if `false` the width depends on the header size.\n * Defaults to `false`.\n */\n variableWidth?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Placement of the dropdown.\n */\n placement?: \"left\" | \"right\";\n /**\n * An object containing props to be wired to the popper component.\n */\n popperProps?: Partial<PopperProps>;\n /**\n * Callback called when the user cancels the changes.\n *\n * Called when the cancel button is used and when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onCancel?: (event: Event) => void;\n /**\n * Callback called when dropdown changes the expanded state.\n *\n * @param {object} event The event source of the callback.\n * @param {boolean} open If the dropdown new state is open (`true`) or closed (`false`).\n */\n onToggle?: (event: Event, open: boolean) => void;\n /**\n * Callback called when the user clicks outside the open container.\n *\n * @param {object} event The event source of the callback.\n */\n onClickOutside?: (event: Event) => void;\n /**\n * @ignore\n */\n onFocus?: React.FocusEventHandler<any>;\n /**\n * @ignore\n */\n onBlur?: React.FocusEventHandler<any>;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n /**\n * Extra props passed to the dropdown.\n */\n baseDropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * Extra props passed to the list.\n */\n listProps?: HvDropdownListProps;\n}\n\nconst DEFAULT_LABELS: HvDropdownLabelsProps = {\n select: undefined,\n selectAll: \"All\",\n cancelLabel: \"Cancel\",\n applyLabel: \"Apply\",\n searchPlaceholder: \"Search\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * A dropdown list is a graphical control element, similar to a list box, that allows the user to choose one value from a list.\n */\nexport const HvDropdown = forwardRef<HTMLDivElement, HvDropdownProps>(\n (props, ref) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n\n required = false,\n disabled = false,\n readOnly = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n\n placeholder = \"Select...\",\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n onCancel,\n onToggle,\n onClickOutside,\n\n onFocus,\n onBlur,\n\n values,\n multiSelect = false,\n showSearch = false,\n expanded,\n defaultExpanded = false,\n notifyChangesOnFirstRender = false,\n labels: labelsProp,\n hasTooltips = false,\n disablePortal = false,\n singleSelectionToggle = true,\n placement,\n variableWidth = false,\n popperProps = {},\n height,\n maxHeight,\n virtualized = false,\n baseDropdownProps = {},\n listProps = {},\n ...others\n } = useDefaultProps(\"HvDropdown\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const elementId = useUniqueId(id, \"hvdropdown\");\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const [isOpen, setIsOpen] = useControlled(\n expanded,\n Boolean(defaultExpanded)\n );\n const [selectionLabel, setSelectionLabel] = useState(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n const [internalValues, setInternalValues] = useState(values);\n\n useEffect(() => {\n setInternalValues(values);\n }, [values]);\n\n useEffect(() => {\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, values)\n );\n }, [labels, multiSelect, placeholder, values]);\n\n if (import.meta.env.DEV && virtualized && !height) {\n // eslint-disable-next-line no-console\n console.error(\n \"Dropdown/List in virtualized mode requires a height. Please define it.\"\n );\n }\n\n const dropdownHeaderRef = useRef<HTMLDivElement>();\n\n const {\n ref: refProp,\n dropdownHeaderRef: dropdownHeaderRefProp,\n ...otherBaseDropdownProps\n } = baseDropdownProps;\n const headerForkedRef = useForkRef(\n dropdownHeaderRefProp,\n dropdownHeaderRef\n );\n\n const dropdownForkedRef = useForkRef(ref, refProp);\n\n const handleToggle: HvBaseDropdownProps[\"onToggle\"] = (event, open) => {\n onToggle?.(event, open);\n\n setIsOpen(open);\n\n if (!open) {\n // also run built-in validation when closing without changes\n // as the user \"touched\" the input\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required) {\n const hasSelection = getSelected(internalValues).length > 0;\n\n if (!hasSelection) {\n return \"invalid\";\n }\n }\n\n return \"valid\";\n });\n }\n };\n\n /** Applies the selected values to the state */\n const handleSelection: HvDropdownListProps[\"onChange\"] = (\n listValues,\n commitChanges,\n toggle,\n notifyChanges = true\n ) => {\n const selected = getSelected(listValues);\n\n if (commitChanges) {\n setInternalValues(listValues);\n setSelectionLabel(\n getSelectionLabel(labels, placeholder, multiSelect, listValues)\n );\n\n setValidationState(() => {\n // this will only run if status is uncontrolled\n if (required && selected.length === 0) {\n return \"invalid\";\n }\n\n return \"valid\";\n });\n }\n if (notifyChanges) onChange?.(multiSelect ? selected : selected[0]);\n if (toggle) {\n handleToggle(undefined as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n }\n };\n\n /**\n * Handles the `Cancel` action. Both single and ranged modes are handled here.\n */\n const handleCancel: HvDropdownListProps[\"onCancel\"] = (evt) => {\n onCancel?.(evt as any);\n\n handleToggle(evt as any, false);\n\n // focus-ring won't be visible even if using the keyboard:\n // https://github.com/WICG/focus-visible/issues/88\n dropdownHeaderRef.current?.focus({ preventScroll: true });\n };\n\n const handleClickOutside: HvBaseDropdownProps[\"onClickOutside\"] = (evt) => {\n onClickOutside?.(evt);\n onCancel?.(evt);\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n const inputs = containerRef?.getElementsByTagName(\"input\");\n if (inputs && inputs.length > 0) {\n inputs[0].focus();\n return;\n }\n const listItems =\n containerRef != null\n ? [...containerRef.getElementsByTagName(\"li\")]\n : [];\n listItems.every((listItem) => {\n if (listItem.tabIndex >= 0) {\n listItem.focus();\n return false;\n }\n return true;\n });\n };\n\n const buildHeaderLabel = () => {\n const hasSelection = getSelected(internalValues).length > 0;\n return labels?.select || !multiSelect ? (\n <HvTypography\n component=\"div\"\n variant=\"body\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n [classes.placeholderClosed]: !(isOpen || hasSelection),\n })}\n >\n {selectionLabel.selected}\n </HvTypography>\n ) : (\n <HvTypography\n component=\"div\"\n className={cx(classes.placeholder, {\n [classes.selectionDisabled]: disabled,\n })}\n variant=\"body\"\n >\n <b>{selectionLabel.selected}</b>\n {` ${labels?.multiSelectionConjunction} ${selectionLabel.total}`}\n </HvTypography>\n );\n };\n\n const hasLabel = label != null;\n const hasDescription = description != null;\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = isInvalid(validationState);\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n className={cx(\n classes.root,\n {\n [classes.disabled]: disabled,\n },\n className\n )}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={classes.description}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvBaseDropdown\n ref={dropdownForkedRef}\n id={setId(id, \"dropdown\")}\n classes={{\n root: cx(classes.dropdown, {\n [classes.readOnly]: readOnly,\n }),\n arrow: classes.arrow,\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n headerOpen: classes.dropdownHeaderOpen,\n }}\n expanded={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n disablePortal={disablePortal}\n placement={placement}\n popperProps={popperProps}\n placeholder={buildHeaderLabel()}\n onToggle={handleToggle}\n onClickOutside={handleClickOutside}\n onContainerCreation={setFocusToContent}\n role=\"combobox\"\n variableWidth={variableWidth}\n aria-label={ariaLabel}\n aria-labelledby={\n [label && setId(elementId, \"label\"), ariaLabelledBy]\n .join(\" \")\n .trim() || undefined\n }\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n onFocus={onFocus}\n onBlur={onBlur}\n dropdownHeaderRef={headerForkedRef}\n {...otherBaseDropdownProps}\n >\n <HvDropdownList\n id={setId(elementId, \"values\")}\n classes={{\n rootList: classes.rootList,\n dropdownListContainer: classes.dropdownListContainer,\n }}\n values={internalValues}\n multiSelect={multiSelect}\n showSearch={showSearch}\n onChange={handleSelection}\n onCancel={handleCancel}\n labels={labels}\n notifyChangesOnFirstRender={notifyChangesOnFirstRender}\n hasTooltips={hasTooltips}\n singleSelectionToggle={singleSelectionToggle}\n aria-label={ariaLabel}\n aria-labelledby={hasLabel ? setId(elementId, \"label\") : undefined}\n height={height}\n maxHeight={maxHeight}\n virtualized={virtualized}\n {...listProps}\n />\n </HvBaseDropdown>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n }\n);\n"],"names":["DEFAULT_LABELS","select","undefined","selectAll","cancelLabel","applyLabel","searchPlaceholder","multiSelectionConjunction","HvDropdown","forwardRef","props","ref","classes","classesProp","className","id","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","placeholder","onChange","status","statusMessage","ariaErrorMessage","onCancel","onToggle","onClickOutside","onFocus","onBlur","values","multiSelect","showSearch","expanded","defaultExpanded","notifyChangesOnFirstRender","labels","labelsProp","hasTooltips","disablePortal","singleSelectionToggle","placement","variableWidth","popperProps","height","maxHeight","virtualized","baseDropdownProps","listProps","others","useDefaultProps","cx","useClasses","useLabels","elementId","useUniqueId","validationState","setValidationState","useControlled","validationMessage","isOpen","setIsOpen","Boolean","selectionLabel","setSelectionLabel","useState","getSelectionLabel","internalValues","setInternalValues","useEffect","dropdownHeaderRef","useRef","refProp","dropdownHeaderRefProp","otherBaseDropdownProps","headerForkedRef","useForkRef","dropdownForkedRef","handleToggle","event","open","hasSelection","getSelected","length","handleSelection","listValues","commitChanges","toggle","notifyChanges","selected","current","focus","preventScroll","handleCancel","evt","handleClickOutside","setFocusToContent","containerRef","inputs","getElementsByTagName","listItems","every","listItem","tabIndex","buildHeaderLabel","selectionDisabled","placeholderClosed","total","hasLabel","hasDescription","canShowError","isStateInvalid","isInvalid","errorMessageId","setId","root","labelContainer","dropdown","arrow","header","dropdownHeader","dropdownHeaderInvalid","headerOpen","dropdownHeaderOpen","join","trim","rootList","dropdownListContainer","error"],"mappings":";;;;;;;;;;;;;;;;;;;AAuMA,MAAMA,iBAAwC;AAAA,EAC5CC,QAAQC;AAAAA,EACRC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,mBAAmB;AAAA,EACnBC,2BAA2B;AAC7B;AAKO,MAAMC,aAAaC,WACxB,CAACC,OAAOC,QAAQ;AACR,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnBC;AAAAA,IACA,oBAAoBC;AAAAA,IAEpBC,cAAc;AAAA,IAEdC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IAEAC;AAAAA,IACAC,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC;AAAAA,IACAC,kBAAkB;AAA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BACnB,oBACE,CAAC/F,eAAegG,MAAM5D,WAAW,aAAa,GAAGnC,eAAe,EAC7DyG,KAAK,GAAG,EACRC,KAAAA,KAAUhI,QAEf,SACA,QACA,mBAAmB8E,iBACnB,GAAID,wBAEJ,UAAA,oBAAC,kBACC,IAAIwC,MAAM5D,WAAW,QAAQ,GAC7B,SAAS;AAAA,MACPwE,UAAUvH,QAAQuH;AAAAA,MAClBC,uBAAuBxH,QAAQwH;AAAAA,IACjC,GACA,QAAQ5D,gBACR,aACA,YACA,UAAUiB,iBACV,UAAUS,cACV,QACA,4BACA,aACA,uBACA,cAAY7E,WACZ,mBAAiB4F,WAAWM,MAAM5D,WAAW,OAAO,IAAIzD,QACxD,QACA,WACA,aACImD,GAAAA,UAAAA,CAAU,EAElB,CAAA;AAAA,IACC8D,gBACC,oBAAC,eACC,EAAA,IAAII,MAAM5D,WAAW,OAAO,GAC5B,eAAa,MACb,WAAW/C,QAAQyH,OAElBrE,UACH,mBAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ,CACF;"}
@@ -1,6 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from "@emotion/react/jsx-runtime";
2
2
  import { Close, Fail, Success } from "@hitachivantara/uikit-react-icons";
3
- import { cx } from "@emotion/css";
4
3
  import { setId } from "../../../utils/setId.js";
5
4
  import { convertUnits } from "../utils.js";
6
5
  import { useClasses } from "./File.styles.js";
@@ -45,7 +44,8 @@ const HvFile = (props) => {
45
44
  removeFileButtonLabel
46
45
  } = useDefaultProps("HvFile", props);
47
46
  const {
48
- classes
47
+ classes,
48
+ cx
49
49
  } = useClasses(classesProp);
50
50
  const hasError = data.status === "fail";
51
51
  const inProgress = data.status === "progress";
@@ -1 +1 @@
1
- {"version":3,"file":"File.js","sources":["../../../../../src/components/FileUploader/File/File.tsx"],"sourcesContent":["import { Close, Fail, Success } from \"@hitachivantara/uikit-react-icons\";\n\nimport { cx } from \"@emotion/css\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvProgressBar } from \"@core/components/ProgressBar\";\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { convertUnits } from \"../utils\";\nimport { staticClasses, useClasses } from \"./File.styles\";\n\nexport { staticClasses as fileClasses };\n\nexport type HvFileClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFileData extends Omit<File, \"name\" | \"size\"> {\n /**\n * The file id.\n */\n id?: string;\n /**\n * The file name.\n */\n name?: string;\n /**\n * The upload status.\n */\n status?: \"progress\" | \"success\" | \"fail\";\n /**\n * The file size in bytes.\n */\n size?: number;\n /**\n * Upload progress in bytes.\n */\n progress?: number;\n /**\n * Optional node representing a preview of the uploaded file.\n */\n preview?: React.ReactNode;\n /**\n * Error message when the upload failed.\n */\n errorMessage?: string;\n}\n\nexport type HvFilesAddedEvent = (files: HvFileData[]) => void;\n\nexport type HvFileRemovedEvent = (file: HvFileData) => void;\n\nexport type HvFileProps = {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * File information to be displayed.\n */\n data: HvFileData;\n /**\n * Callback fired when file is removed from list.\n */\n onFileRemoved?: HvFileRemovedEvent;\n /**\n * Value of aria-label to apply to remove file button in file list.\n * */\n removeFileButtonLabel?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvFileClasses;\n};\n\nconst getStatusIcon = (\n classes?: HvFileClasses,\n status?: HvFileData[\"status\"]\n) => {\n switch (status) {\n case \"success\":\n return <Success className={classes?.icon} color=\"positive\" />;\n case \"fail\":\n return <Fail className={classes?.icon} color=\"negative\" />;\n default:\n return <div className={classes?.icon} />;\n }\n};\n\nconst getProgressText = (data: HvFileData, classes?: HvFileClasses) => {\n const hasFailed = data.status === \"fail\";\n const inProgress = data.status === \"progress\";\n\n return (\n <>\n {data.progress || data.size || data.errorMessage ? `\\xa0|\\xa0` : null}\n\n {inProgress && data.progress != null && (\n <HvTypography variant=\"label\">\n {`${convertUnits(data.progress)}\\xa0/\\xa0`}\n </HvTypography>\n )}\n\n {!hasFailed && data.size && (\n <HvTypography>{`${convertUnits(data.size)}`}</HvTypography>\n )}\n\n {hasFailed && data.errorMessage && (\n <HvTypography className={classes?.fail}>\n {data.errorMessage}\n </HvTypography>\n )}\n </>\n );\n};\n\nconst getProgressBarWith = ({ size, progress }: HvFileData) => {\n const width =\n progress != null && size != null ? Math.round((progress * 100) / size) : 0;\n\n return width;\n};\n\nexport const HvFile = (props: HvFileProps) => {\n const {\n id,\n classes: classesProp,\n data,\n onFileRemoved,\n removeFileButtonLabel,\n } = useDefaultProps(\"HvFile\", props);\n const { classes } = useClasses(classesProp);\n\n const hasError = data.status === \"fail\";\n\n const inProgress = data.status === \"progress\";\n\n const progressText = getProgressText(data, classes);\n\n const statusIcon = getStatusIcon(classes, data.status);\n\n const currentProgress = getProgressBarWith(data);\n\n return (\n <li className={classes.root}>\n {!hasError && inProgress && (\n <HvProgressBar\n classes={{\n root: classes.progressbar,\n progressBarContainer: cx(\n classes.progressbarContainer,\n classes.progressbarBack\n ),\n }}\n value={currentProgress}\n hideLabel\n />\n )}\n\n {statusIcon}\n\n <HvTypography className={classes.nameText} variant=\"label\">\n {data.name}\n </HvTypography>\n\n <span className={classes.progressTextContainer}>{progressText}</span>\n\n {data.preview && (\n <div className={classes.previewContainer}>{data.preview}</div>\n )}\n\n <HvButton\n id={setId(id, \"remove-button\")}\n aria-label={removeFileButtonLabel}\n className={classes.removeButton}\n onClick={() => onFileRemoved?.(data)}\n icon\n >\n <Close iconSize=\"XS\" />\n </HvButton>\n </li>\n );\n};\n"],"names":["getStatusIcon","classes","status","icon","getProgressText","data","hasFailed","inProgress","progress","size","errorMessage","convertUnits","fail","getProgressBarWith","width","Math","round","HvFile","props","id","classesProp","onFileRemoved","removeFileButtonLabel","useDefaultProps","useClasses","hasError","progressText","statusIcon","currentProgress","root","progressbar","progressBarContainer","cx","progressbarContainer","progressbarBack","nameText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AA,IACAgB;AAAAA,IACAC;AAAAA,EAAAA,IACEC,gBAAgB,UAAUL,KAAK;AAC7B,QAAA;AAAA,IAAEjB;AAAAA,EAAAA,IAAYuB,WAAWJ,WAAW;AAEpCK,QAAAA,WAAWpB,KAAKH,WAAW;AAE3BK,QAAAA,aAAaF,KAAKH,WAAW;AAE7BwB,QAAAA,eAAetB,gBAAgBC,MAAMJ,OAAO;AAElD,QAAM0B,aAAa3B,cAAcC,SAASI,KAAKH,MAAM;AAE/C0B,QAAAA,kBAAkBf,mBAAmBR,IAAI;AAE/C,SACG,qBAAA,MAAA,EAAG,WAAWJ,QAAQ4B,MACpB,UAAA;AAAA,IAAA,CAACJ,YAAYlB,cACX,oBAAA,eAAA,EACC,SAAS;AAAA,MACPsB,MAAM5B,QAAQ6B;AAAAA,MACdC,sBAAsBC,GACpB/B,QAAQgC,sBACRhC,QAAQiC,eACV;AAAA,IAEF,GAAA,OAAON,iBACP,WAAS,KAEZ,CAAA;AAAA,IAEAD;AAAAA,IAED,oBAAC,gBAAa,WAAW1B,QAAQkC,UAAU,SAAQ,SAChD9B,eAAK+B,KACR,CAAA;AAAA,IAEC,oBAAA,QAAA,EAAK,WAAWnC,QAAQoC,uBAAwBX,UAAa,cAAA;AAAA,IAE7DrB,KAAKiC,WACH,oBAAA,OAAA,EAAI,WAAWrC,QAAQsC,kBAAmBlC,eAAKiC,QAAQ,CAAA;AAAA,IAG1D,oBAAC,YACC,IAAIE,MAAMrB,IAAI,eAAe,GAC7B,cAAYG,uBACZ,WAAWrB,QAAQwC,cACnB,SAAS,MAAMpB,gBAAgBhB,IAAI,GACnC,MAAI,MAEJ,UAAC,oBAAA,OAAA,EAAM,UAAS,KAAA,CAAI,EACtB,CAAA;AAAA,EACF,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"File.js","sources":["../../../../../src/components/FileUploader/File/File.tsx"],"sourcesContent":["import { Close, Fail, Success } from \"@hitachivantara/uikit-react-icons\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { HvProgressBar } from \"@core/components/ProgressBar\";\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { convertUnits } from \"../utils\";\nimport { staticClasses, useClasses } from \"./File.styles\";\n\nexport { staticClasses as fileClasses };\n\nexport type HvFileClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFileData extends Omit<File, \"name\" | \"size\"> {\n /**\n * The file id.\n */\n id?: string;\n /**\n * The file name.\n */\n name?: string;\n /**\n * The upload status.\n */\n status?: \"progress\" | \"success\" | \"fail\";\n /**\n * The file size in bytes.\n */\n size?: number;\n /**\n * Upload progress in bytes.\n */\n progress?: number;\n /**\n * Optional node representing a preview of the uploaded file.\n */\n preview?: React.ReactNode;\n /**\n * Error message when the upload failed.\n */\n errorMessage?: string;\n}\n\nexport type HvFilesAddedEvent = (files: HvFileData[]) => void;\n\nexport type HvFileRemovedEvent = (file: HvFileData) => void;\n\nexport type HvFileProps = {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * File information to be displayed.\n */\n data: HvFileData;\n /**\n * Callback fired when file is removed from list.\n */\n onFileRemoved?: HvFileRemovedEvent;\n /**\n * Value of aria-label to apply to remove file button in file list.\n * */\n removeFileButtonLabel?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvFileClasses;\n};\n\nconst getStatusIcon = (\n classes?: HvFileClasses,\n status?: HvFileData[\"status\"]\n) => {\n switch (status) {\n case \"success\":\n return <Success className={classes?.icon} color=\"positive\" />;\n case \"fail\":\n return <Fail className={classes?.icon} color=\"negative\" />;\n default:\n return <div className={classes?.icon} />;\n }\n};\n\nconst getProgressText = (data: HvFileData, classes?: HvFileClasses) => {\n const hasFailed = data.status === \"fail\";\n const inProgress = data.status === \"progress\";\n\n return (\n <>\n {data.progress || data.size || data.errorMessage ? `\\xa0|\\xa0` : null}\n\n {inProgress && data.progress != null && (\n <HvTypography variant=\"label\">\n {`${convertUnits(data.progress)}\\xa0/\\xa0`}\n </HvTypography>\n )}\n\n {!hasFailed && data.size && (\n <HvTypography>{`${convertUnits(data.size)}`}</HvTypography>\n )}\n\n {hasFailed && data.errorMessage && (\n <HvTypography className={classes?.fail}>\n {data.errorMessage}\n </HvTypography>\n )}\n </>\n );\n};\n\nconst getProgressBarWith = ({ size, progress }: HvFileData) => {\n const width =\n progress != null && size != null ? Math.round((progress * 100) / size) : 0;\n\n return width;\n};\n\nexport const HvFile = (props: HvFileProps) => {\n const {\n id,\n classes: classesProp,\n data,\n onFileRemoved,\n removeFileButtonLabel,\n } = useDefaultProps(\"HvFile\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const hasError = data.status === \"fail\";\n\n const inProgress = data.status === \"progress\";\n\n const progressText = getProgressText(data, classes);\n\n const statusIcon = getStatusIcon(classes, data.status);\n\n const currentProgress = getProgressBarWith(data);\n\n return (\n <li className={classes.root}>\n {!hasError && inProgress && (\n <HvProgressBar\n classes={{\n root: classes.progressbar,\n progressBarContainer: cx(\n classes.progressbarContainer,\n classes.progressbarBack\n ),\n }}\n value={currentProgress}\n hideLabel\n />\n )}\n\n {statusIcon}\n\n <HvTypography className={classes.nameText} variant=\"label\">\n {data.name}\n </HvTypography>\n\n <span className={classes.progressTextContainer}>{progressText}</span>\n\n {data.preview && (\n <div className={classes.previewContainer}>{data.preview}</div>\n )}\n\n <HvButton\n id={setId(id, \"remove-button\")}\n aria-label={removeFileButtonLabel}\n className={classes.removeButton}\n onClick={() => onFileRemoved?.(data)}\n icon\n >\n <Close iconSize=\"XS\" />\n </HvButton>\n </li>\n );\n};\n"],"names":["getStatusIcon","classes","status","icon","getProgressText","data","hasFailed","inProgress","progress","size","errorMessage","convertUnits","fail","getProgressBarWith","width","Math","round","HvFile","props","id","classesProp","onFileRemoved","removeFileButtonLabel","useDefaultProps","cx","useClasses","hasError","progressText","statusIcon","currentProgress","root","progressbar","progressBarContainer","progressbarContainer","progressbarBack","nameText","name","progressTextContainer","preview","previewContainer","setId","removeButton"],"mappings":";;;;;;;;;;AA0EA,MAAMA,gBAAgBA,CACpBC,SACAC,WACG;AACH,UAAQA,QAAM;AAAA,IACZ,KAAK;AACH,iCAAQ,SAAQ,EAAA,WAAWD,SAASE,MAAM,OAAM,WAAa,CAAA;AAAA,IAC/D,KAAK;AACH,iCAAQ,MAAK,EAAA,WAAWF,SAASE,MAAM,OAAM,WAAa,CAAA;AAAA,IAC5D;AACE,aAAQ,oBAAA,OAAA,EAAI,WAAWF,SAASE,KAAQ,CAAA;AAAA,EAC5C;AACF;AAEA,MAAMC,kBAAkBA,CAACC,MAAkBJ,YAA4B;AAC/DK,QAAAA,YAAYD,KAAKH,WAAW;AAC5BK,QAAAA,aAAaF,KAAKH,WAAW;AAEnC,SAEKG,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,IAAAA,KAAKG,YAAYH,KAAKI,QAAQJ,KAAKK,eAAgB,QAAa;AAAA,IAEhEH,cAAcF,KAAKG,YAAY,QAC7B,oBAAA,cAAA,EAAa,SAAQ,SAClB,UAAEG,GAAAA,aAAaN,KAAKG,QAAQ,CAAE,OAClC;AAAA,IAGD,CAACF,aAAaD,KAAKI,QAClB,oBAAC,cAAe,EAAA,UAAA,GAAEE,aAAaN,KAAKI,IAAI,CAAE,GAAE,CAAA;AAAA,IAG7CH,aAAaD,KAAKK,gBACjB,oBAAC,gBAAa,WAAWT,SAASW,MAC/BP,UAAAA,KAAKK,aACR,CAAA;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAEA,MAAMG,qBAAqBA,CAAC;AAAA,EAAEJ;AAAAA,EAAMD;AAAqB,MAAM;AACvDM,QAAAA,QACJN,YAAY,QAAQC,QAAQ,OAAOM,KAAKC,MAAOR,WAAW,MAAOC,IAAI,IAAI;AAEpEK,SAAAA;AACT;AAEaG,MAAAA,SAASA,CAACC,UAAuB;AACtC,QAAA;AAAA,IACJC;AAAAA,IACAlB,S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x"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { CSSInterpolation } from \"@emotion/css\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nconst item: CSSInterpolation = {\n border: \"none\",\n cursor: \"pointer\",\n padding: `${theme.space.xs} ${theme.space.sm}`,\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n \"&:active\": {\n outline: \"none\",\n },\n \"&:focus\": {\n outline: \"none\",\n },\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n \"& span\": {\n display: \"inline-flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n \"& span::after\": {\n content: \"attr(data-text)\",\n height: 0,\n visibility: \"hidden\",\n overflow: \"hidden\",\n userSelect: \"none\",\n pointerEvents: \"none\",\n fontWeight: theme.fontWeights.semibold,\n\n \"@media speech\": {\n display: \"none\",\n },\n },\n};\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvHeader-MenuItem\",\n {\n root: {\n display: \"inline\",\n \"&:hover\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n \"&:focus-within\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n },\n menu: {\n marginTop: 0,\n paddingBottom: \"4px\",\n paddingTop: \"4px\",\n height: \"100%\",\n borderTop: \"none\",\n borderBottom: `4px solid ${theme.colors.atmo2}`,\n },\n menubar: {\n marginTop: \"0px\",\n paddingBottom: \"4px\",\n paddingTop: \"4px\",\n height: \"100%\",\n borderTop: `0px solid ${theme.colors.atmo1}`,\n borderBottom: `${\"4px\"} solid ${theme.colors.atmo1}`,\n },\n selected: {\n \"&$menu\": {\n marginTop: 0,\n paddingBottom: 0,\n borderTop: \"none\",\n borderBottom: `4px solid ${theme.colors.secondary}`,\n paddingTop: \"4px\",\n height: \"100%\",\n \"& > * > span\": {\n color: theme.colors.secondary,\n },\n },\n \"&$menubar\": {\n marginTop: 0,\n paddingBottom: 0,\n borderTop: \"none\",\n borderBottom: `4px solid ${theme.colors.secondary}`,\n paddingTop: \"4px\",\n height: \"100%\",\n },\n },\n link: {\n textDecoration: \"none\",\n ...item,\n },\n button: {\n color: \"inherit\",\n ...item,\n },\n }\n);\n"],"names":["item","border","cursor","padding","theme","space","xs","sm","height","display","alignItems","outline","outlineStyles","flexDirection","justifyContent","content","visibility","overflow","userSelect","pointerEvents","fontWeight","fontWeights","semibold","staticClasses","useClasses","createClasses","root","backgroundColor","colors","containerBackgroundHover","menu","marginTop","paddingBottom","paddingTop","borderTop","borderBottom","atmo2","menubar","atmo1","selected","secondary","color","link","textDecoration","button"],"mappings":";;;AAOA,MAAMA,OAAyB;AAAA,EAC7BC,QAAQ;AAAA,EACRC,QAAQ;AAAA,EACRC,SAAU,GAAEC,MAAMC,MAAMC,EAAG,IAAGF,MAAMC,MAAME,EAAG;AAAA,EAC7CC,QAAQ;AAAA,EACRC,SAAS;AAAA,EACTC,YAAY;AAAA,EACZ,YAAY;AAAA,IACVC,SAAS;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACTA,SAAS;AAAA,EACX;AAAA,EACA,mBAAmB;AAAA,IACjB,GAAGC;AAAAA,EACL;AAAA,EACA,UAAU;AAAA,IACRH,SAAS;AAAA,IACTI,eAAe;AAAA,IACfH,YAAY;AAAA,IACZI,gBAAgB;AAAA,EAClB;AAAA,EACA,iBAAiB;AAAA,IACfC,SAAS;AAAA,IACTP,QAAQ;AAAA,IACRQ,YAAY;AAAA,IACZC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,eAAe;AAAA,IACfC,YAAYhB,MAAMiB,YAAYC;AAAAA,IAE9B,iBAAiB;AAAA,MACfb,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEa,MAAA;AAAA,EAAEc;AAAAA,EAAeC;AAAW,IAAIC,cAC3C,qBACA;AAAA,EACEC,MAAM;AAAA,IACJjB,SAAS;AAAA,IACT,WAAW;AAAA,MACTkB,iBAAiBvB,MAAMwB,OAAOC;AAAAA,IAChC;AAAA,IACA,kBAAkB;AAAA,MAChBF,iBAAiBvB,MAAMwB,OAAOC;AAAAA,IAChC;AAAA,EACF;AAAA,EACAC,MAAM;AAAA,IACJC,WAAW;AAAA,IACXC,eAAe;AAAA,IACfC,YAAY;AAAA,IACZzB,QAAQ;AAAA,IACR0B,WAAW;AAAA,IACXC,cAAe,aAAY/B,MAAMwB,OAAOQ,KAAM;AAAA,EAChD;AAAA,EACAC,SAAS;AAAA,IACPN,WAAW;AAAA,IACXC,eAAe;AAAA,IACfC,YAAY;AAAA,IACZzB,QAAQ;AAAA,IACR0B,WAAY,aAAY9B,MAAMwB,OAAOU,KAAM;AAAA,IAC3CH,cAAe,GAAE,KAAM,UAAS/B,MAAMwB,OAAOU,KAAM;AAAA,EACrD;AAAA,EACAC,UAAU;AAAA,IACR,UAAU;AAAA,MACRR,WAAW;AAAA,MACXC,eAAe;AAAA,MACfE,WAAW;AAAA,MACXC,cAAe,aAAY/B,MAAMwB,OAAOY,SAAU;AAAA,MAClDP,YAAY;AAAA,MACZzB,QAAQ;AAAA,MACR,gBAAgB;AAAA,QACdiC,OAAOrC,MAAMwB,OAAOY;AAAAA,MACtB;AAAA,IACF;AAAA,IACA,aAAa;AAAA,MACXT,WAAW;AAAA,MACXC,eAAe;AAAA,MACfE,WAAW;AAAA,MACXC,cAAe,aAAY/B,MAAMwB,OAAOY,SAAU;AAAA,MAClDP,YAAY;AAAA,MACZzB,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EACAkC,MAAM;AAAA,IACJC,gBAAgB;AAAA,IAChB,GAAG3C;AAAAA,EACL;AAAA,EACA4C,QAAQ;AAAA,IACNH,OAAO;AAAA,IACP,GAAGzC;AAAAA,EACL;AACF,CACF;"}
1
+ {"version":3,"file":"MenuItem.styles.js","sources":["../../../../../../src/components/Header/Navigation/MenuItem/MenuItem.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport type { CSSInterpolation } from \"@emotion/serialize\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nconst item: CSSInterpolation = {\n border: \"none\",\n cursor: \"pointer\",\n padding: `${theme.space.xs} ${theme.space.sm}`,\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n \"&:active\": {\n outline: \"none\",\n },\n \"&:focus\": {\n outline: \"none\",\n },\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n \"& span\": {\n display: \"inline-flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n \"& span::after\": {\n content: \"attr(data-text)\",\n height: 0,\n visibility: \"hidden\",\n overflow: \"hidden\",\n userSelect: \"none\",\n pointerEvents: \"none\",\n fontWeight: theme.fontWeights.semibold,\n\n \"@media speech\": {\n display: \"none\",\n },\n },\n};\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvHeader-MenuItem\",\n {\n root: {\n display: \"inline\",\n \"&:hover\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n \"&:focus-within\": {\n backgroundColor: theme.colors.containerBackgroundHover,\n },\n },\n menu: {\n marginTop: 0,\n paddingBottom: \"4px\",\n paddingTop: \"4px\",\n height: \"100%\",\n borderTop: \"none\",\n borderBottom: `4px solid ${theme.colors.atmo2}`,\n },\n menubar: {\n marginTop: \"0px\",\n paddingBottom: \"4px\",\n paddingTop: \"4px\",\n height: \"100%\",\n borderTop: `0px solid ${theme.colors.atmo1}`,\n borderBottom: `${\"4px\"} solid ${theme.colors.atmo1}`,\n },\n selected: {\n \"&$menu\": {\n marginTop: 0,\n paddingBottom: 0,\n borderTop: \"none\",\n borderBottom: `4px solid ${theme.colors.secondary}`,\n paddingTop: \"4px\",\n height: \"100%\",\n \"& > * > span\": {\n color: theme.colors.secondary,\n },\n },\n \"&$menubar\": {\n marginTop: 0,\n paddingBottom: 0,\n borderTop: \"none\",\n borderBottom: `4px solid ${theme.colors.secondary}`,\n paddingTop: \"4px\",\n height: \"100%\",\n },\n },\n link: {\n textDecoration: \"none\",\n ...item,\n },\n button: {\n color: \"inherit\",\n ...item,\n },\n }\n);\n"],"names":["item","border","cursor","padding","theme","space","xs","sm","height","display","alignItems","outline","outlineStyles","flexDirection","justifyContent","content","visibility","overflow","userSelect","pointerEvents","fontWeight","fontWeights","semibold","staticClasses","useClasses","createClasses","root","backgroundColor","colors","containerBackgroundHover","menu","marginTop","paddingBottom","paddingTop","borderTop","borderBottom","atmo2","menubar","atmo1","selected","secondary","color","link","textDecoration","button"],"mappings":";;;AAOA,MAAMA,OAAyB;AAAA,EAC7BC,QAAQ;AAAA,EACRC,QAAQ;AAAA,EACRC,SAAU,GAAEC,MAAMC,MAAMC,EAAG,IAAGF,MAAMC,MAAME,EAAG;AAAA,EAC7CC,QAAQ;AAAA,EACRC,SAAS;AAAA,EACTC,YAAY;AAAA,EACZ,YAAY;AAAA,IACVC,SAAS;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACTA,SAAS;AAAA,EACX;AAAA,EACA,mBAAmB;AAAA,IACjB,GAAGC;AAAAA,EACL;AAAA,EACA,UAAU;AAAA,IACRH,SAAS;AAAA,IACTI,eAAe;AAAA,IACfH,YAAY;AAAA,IACZI,gBAAgB;AAAA,EAClB;AAAA,EACA,iBAAiB;AAAA,IACfC,SAAS;AAAA,IACTP,QAAQ;AAAA,IACRQ,YAAY;AAAA,IACZC,UAAU;AAAA,IACVC,YAAY;AAAA,IACZC,eAAe;AAAA,IACfC,YAAYhB,MAAMiB,YAAYC;AAAAA,IAE9B,iBAAiB;AAAA,MACfb,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEa,MAAA;AAAA,EAAEc;AAAAA,EAAeC;AAAW,IAAIC,cAC3C,qBACA;AAAA,EACEC,MAAM;AAAA,IACJjB,SAAS;AAAA,IACT,WAAW;AAAA,MACTkB,iBAAiBvB,MAAMwB,OAAOC;AAAAA,IAChC;AAAA,IACA,kBAAkB;AAAA,MAChBF,iBAAiBvB,MAAMwB,OAAOC;AAAAA,IAChC;AAAA,EACF;AAAA,EACAC,MAAM;AAAA,IACJC,WAAW;AAAA,IACXC,eAAe;AAAA,IACfC,YAAY;AAAA,IACZzB,QAAQ;AAAA,IACR0B,WAAW;AAAA,IACXC,cAAe,aAAY/B,MAAMwB,OAAOQ,KAAM;AAAA,EAChD;AAAA,EACAC,SAAS;AAAA,IACPN,WAAW;AAAA,IACXC,eAAe;AAAA,IACfC,YAAY;AAAA,IACZzB,QAAQ;AAAA,IACR0B,WAAY,aAAY9B,MAAMwB,OAAOU,KAAM;AAAA,IAC3CH,cAAe,GAAE,KAAM,UAAS/B,MAAMwB,OAAOU,KAAM;AAAA,EACrD;AAAA,EACAC,UAAU;AAAA,IACR,UAAU;AAAA,MACRR,WAAW;AAAA,MACXC,eAAe;AAAA,MACfE,WAAW;AAAA,MACXC,cAAe,aAAY/B,MAAMwB,OAAOY,SAAU;AAAA,MAClDP,YAAY;AAAA,MACZzB,QAAQ;AAAA,MACR,gBAAgB;AAAA,QACdiC,OAAOrC,MAAMwB,OAAOY;AAAAA,MACtB;AAAA,IACF;AAAA,IACA,aAAa;AAAA,MACXT,WAAW;AAAA,MACXC,eAAe;AAAA,MACfE,WAAW;AAAA,MACXC,cAAe,aAAY/B,MAAMwB,OAAOY,SAAU;AAAA,MAClDP,YAAY;AAAA,MACZzB,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EACAkC,MAAM;AAAA,IACJC,gBAAgB;AAAA,IAChB,GAAG3C;AAAAA,EACL;AAAA,EACA4C,QAAQ;AAAA,IACNH,OAAO;AAAA,IACP,GAAGzC;AAAAA,EACL;AACF,CACF;"}
@@ -23,6 +23,7 @@ const HvOverflowTooltip = (props) => {
23
23
  cx
24
24
  } = useClasses(classesProp);
25
25
  const {
26
+ height = 0,
26
27
  width = 0,
27
28
  ref
28
29
  } = useResizeDetector({
@@ -32,9 +33,15 @@ const HvOverflowTooltip = (props) => {
32
33
  },
33
34
  handleHeight: false
34
35
  });
35
- const scrollWidth = ref.current?.scrollWidth || 0;
36
- const isOverflowing = scrollWidth - width >= 1;
37
36
  const isParag = useMemo(() => paragraphOverflow && isParagraph(data?.toString()), [data, paragraphOverflow]);
37
+ const isOverflowing = useMemo(() => {
38
+ if (isParag) {
39
+ const scrollHeight = ref.current?.scrollHeight || 0;
40
+ return scrollHeight - height >= 1;
41
+ }
42
+ const scrollWidth = ref.current?.scrollWidth || 0;
43
+ return scrollWidth - width >= 1;
44
+ }, [height, isParag, ref, width]);
38
45
  const content = useMemo(() => /* @__PURE__ */ jsx("div", { ref, className: cx({
39
46
  [classes.tooltipAnchor]: !isParag,
40
47
  [classes.tooltipAnchorParagraph]: isParag
@@ -1 +1 @@
1
- {"version":3,"file":"OverflowTooltip.js","sources":["../../../../src/components/OverflowTooltip/OverflowTooltip.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvTooltip, HvTooltipProps } from \"@core/components/Tooltip\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./OverflowTooltip.styles\";\n\nexport { staticClasses as overflowTooltipClasses };\nexport type HvOverflowTooltipClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvOverflowTooltipProps extends HvBaseProps {\n /** The node that will be rendered inside the tooltip. */\n data: React.ReactNode;\n /** If true, the tooltip is shown. */\n open?: boolean;\n /** If `true` the overflow tooltip will always use the paragraph overflow style. */\n paragraphOverflow?: boolean;\n /** Tooltip placement. */\n placement?:\n | \"bottom-end\"\n | \"bottom-start\"\n | \"bottom\"\n | \"left-end\"\n | \"left-start\"\n | \"left\"\n | \"right-end\"\n | \"right-start\"\n | \"right\"\n | \"top-end\"\n | \"top-start\"\n | \"top\";\n /** Extra properties to add to the tooltip. */\n tooltipsProps?: Partial<HvTooltipProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvOverflowTooltipClasses;\n}\n\nconst isParagraph = (children = \"\") => /\\s/.test(children);\n\n/**\n * This component generates a tooltip whenever the text is overflowed.\n */\nexport const HvOverflowTooltip = (props: HvOverflowTooltipProps) => {\n const {\n id,\n classes: classesProp,\n className,\n data,\n open,\n paragraphOverflow,\n placement = \"top-start\",\n tooltipsProps,\n } = useDefaultProps(\"HvOverflowTooltip\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { width = 0, ref } = useResizeDetector({\n refreshMode: \"debounce\",\n refreshOptions: {\n trailing: true,\n },\n handleHeight: false,\n });\n const scrollWidth = ref.current?.scrollWidth || 0;\n // The difference should be higher than a pixel to be considered as overflowing\n const isOverflowing = scrollWidth - width >= 1;\n\n const isParag = useMemo(\n () => paragraphOverflow && isParagraph(data?.toString()),\n [data, paragraphOverflow]\n );\n\n const content = useMemo(\n () => (\n <div\n ref={ref}\n className={cx(\n {\n [classes.tooltipAnchor]: !isParag,\n [classes.tooltipAnchorParagraph]: isParag,\n },\n className\n )}\n >\n {data}\n </div>\n ),\n [\n className,\n classes.tooltipAnchor,\n classes.tooltipAnchorParagraph,\n cx,\n data,\n isParag,\n ref,\n ]\n );\n\n return (\n <HvTooltip\n id={id}\n disableHoverListener={!isOverflowing}\n open={open}\n placement={placement}\n title={\n <HvTypography className={classes.tooltipData} variant=\"body\">\n {data}\n </HvTypography>\n }\n // unset since `content` *is* the label\n aria-label={null as any}\n aria-labelledby={null as any}\n {...tooltipsProps}\n >\n {content}\n </HvTooltip>\n );\n};\n"],"names":["isParagraph","children","test","HvOverflowTooltip","props","id","classes","classesProp","className","data","open","paragraphOverflow","placement","tooltipsProps","useDefaultProps","cx","useClasses","width","ref","useResizeDetector","refreshMode","refreshOptions","trailing","handleHeight","scrollWidth","current","isOverflowing","isParag","useMemo","toString","content","tooltipAnchor","tooltipAnchorParagraph","tooltipData"],"mappings":";;;;;;;;AAyCA,MAAMA,cAAcA,CAAC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AAAA,IAAAA;AAAAA,EAAAA;AAGP;"}
1
+ {"version":3,"file":"OverflowTooltip.js","sources":["../../../../src/components/OverflowTooltip/OverflowTooltip.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvTooltip, HvTooltipProps } from \"@core/components/Tooltip\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./OverflowTooltip.styles\";\n\nexport { staticClasses as overflowTooltipClasses };\nexport type HvOverflowTooltipClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvOverflowTooltipProps extends HvBaseProps {\n /** The node that will be rendered inside the tooltip. */\n data: React.ReactNode;\n /** If true, the tooltip is shown. */\n open?: boolean;\n /** If `true`, the overflow tooltip will always use the paragraph overflow style. */\n paragraphOverflow?: boolean;\n /** Tooltip placement. */\n placement?:\n | \"bottom-end\"\n | \"bottom-start\"\n | \"bottom\"\n | \"left-end\"\n | \"left-start\"\n | \"left\"\n | \"right-end\"\n | \"right-start\"\n | \"right\"\n | \"top-end\"\n | \"top-start\"\n | \"top\";\n /** Extra properties to add to the tooltip. */\n tooltipsProps?: Partial<HvTooltipProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvOverflowTooltipClasses;\n}\n\nconst isParagraph = (children = \"\") => /\\s/.test(children);\n\n/**\n * This component generates a tooltip whenever the text is overflowed.\n */\nexport const HvOverflowTooltip = (props: HvOverflowTooltipProps) => {\n const {\n id,\n classes: classesProp,\n className,\n data,\n open,\n paragraphOverflow,\n placement = \"top-start\",\n tooltipsProps,\n } = useDefaultProps(\"HvOverflowTooltip\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n height = 0,\n width = 0,\n ref,\n } = useResizeDetector({\n refreshMode: \"debounce\",\n refreshOptions: {\n trailing: true,\n },\n handleHeight: false,\n });\n\n const isParag = useMemo(\n () => paragraphOverflow && isParagraph(data?.toString()),\n [data, paragraphOverflow]\n );\n\n // The difference should be higher than a pixel to be considered as overflowing\n const isOverflowing = useMemo(() => {\n if (isParag) {\n const scrollHeight = ref.current?.scrollHeight || 0;\n\n return scrollHeight - height >= 1;\n }\n\n const scrollWidth = ref.current?.scrollWidth || 0;\n\n return scrollWidth - width >= 1;\n }, [height, isParag, ref, width]);\n\n const content = useMemo(\n () => (\n <div\n ref={ref}\n className={cx(\n {\n [classes.tooltipAnchor]: !isParag,\n [classes.tooltipAnchorParagraph]: isParag,\n },\n className\n )}\n >\n {data}\n </div>\n ),\n [\n className,\n classes.tooltipAnchor,\n classes.tooltipAnchorParagraph,\n cx,\n data,\n isParag,\n ref,\n ]\n );\n\n return (\n <HvTooltip\n id={id}\n disableHoverListener={!isOverflowing}\n open={open}\n placement={placement}\n title={\n <HvTypography className={classes.tooltipData} variant=\"body\">\n {data}\n </HvTypography>\n }\n // unset since `content` *is* the label\n aria-label={null as any}\n aria-labelledby={null as any}\n {...tooltipsProps}\n >\n {content}\n </HvTooltip>\n );\n};\n"],"names":["isParagraph","children","test","HvOverflowTooltip","props","id","classes","classesProp","className","data","open","paragraphOverflow","placement","tooltipsProps","useDefaultProps","cx","useClasses","height","width","ref","useResizeDetector","refreshMode","refreshOptions","trailing","handleHeight","isParag","useMemo","toString","isOverflowing","scrollHeight","current","scrollWidth","content","tooltipAnchor","tooltipAnchorParagraph","tooltipData"],"mappings":";;;;;;;;AAyCA,MAAMA,cAAcA,CAACC,WAAW,OAAO,KAAKC,KAAKD,QAAQ;AAK5CE,MAAAA,oBAAoBA,CAACC,UAAkC;AAC5D,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC;AAAAA,EAAAA,IACEC,gBAAgB,qBAAqBV,KAAK;AAExC,QAAA;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ooltipAnchorParagraph: {
13
13
  overflow: "hidden",
14
14
  display: "-webkit-box",
15
- "-webkit-line-clamp": 2,
16
- "-webkit-box-orient": "vertical"
15
+ WebkitLineClamp: 3,
16
+ WebkitBoxOrient: "vertical"
17
17
  }
18
18
  });
19
19
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"OverflowTooltip.styles.js","sources":["../../../../src/components/OverflowTooltip/OverflowTooltip.styles.tsx"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvOverflowTooltip\",\n {\n tooltipData: {},\n tooltipAnchor: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n tooltipAnchorParagraph: {\n overflow: \"hidden\",\n display: \"-webkit-box\",\n \"-webkit-line-clamp\": 2,\n \"-webkit-box-orient\": \"vertical\",\n },\n }\n);\n"],"names":["staticClasses","useClasses","createClasses","tooltipData","tooltipAnchor","whiteSpace","overflow","textOverflow","tooltipAnchorParagraph","display"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAC3C,qBACA;AAAA,EACEC,aAAa,CAAC;AAAA,EACdC,eAAe;AAAA,IACbC,YAAY;AAAA,IACZC,UAAU;AAAA,IACVC,cAAc;AAAA,EAChB;AAAA,EACAC,wBAAwB;AAAA,IACtBF,UAAU;AAAA,IACVG,SAAS;AAAA,IACT,sBAAsB;AAAA,IACtB,sBAAsB;AAAA,EACxB;AACF,CACF;"}
1
+ {"version":3,"file":"OverflowTooltip.styles.js","sources":["../../../../src/components/OverflowTooltip/OverflowTooltip.styles.tsx"],"sourcesContent":["import { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\n \"HvOverflowTooltip\",\n {\n tooltipData: {},\n tooltipAnchor: {\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n },\n tooltipAnchorParagraph: {\n overflow: \"hidden\",\n display: \"-webkit-box\",\n WebkitLineClamp: 3,\n WebkitBoxOrient: \"vertical\",\n },\n }\n);\n"],"names":["staticClasses","useClasses","createClasses","tooltipData","tooltipAnchor","whiteSpace","overflow","textOverflow","tooltipAnchorParagraph","display","WebkitLineClamp","WebkitBoxOrient"],"mappings":";AAEa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAC3C,qBACA;AAAA,EACEC,aAAa,CAAC;AAAA,EACdC,eAAe;AAAA,IACbC,YAAY;AAAA,IACZC,UAAU;AAAA,IACVC,cAAc;AAAA,EAChB;AAAA,EACAC,wBAAwB;AAAA,IACtBF,UAAU;AAAA,IACVG,SAAS;AAAA,IACTC,iBAAiB;AAAA,IACjBC,iBAAiB;AAAA,EACnB;AACF,CACF;"}
@@ -1,14 +1,9 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
2
  import { forwardRef, useCallback, useMemo } from "react";
3
3
  import { SnackbarContent, useSnackbar, SnackbarProvider } from "notistack";
4
- import { clsx } from "clsx";
5
- import { css } from "@emotion/css";
6
4
  import { useClasses } from "./SnackbarProvider.styles.js";
7
5
  import { staticClasses } from "./SnackbarProvider.styles.js";
8
6
  import { HvSnackbarContent } from "../SnackbarContent/SnackbarContent.js";
9
- function _EMOTION_STRINGIFIED_CSS_ERROR__() {
10
- return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
11
- }
12
7
  const HvNotistackSnackMessage = forwardRef((props, ref) => {
13
8
  const {
14
9
  id,
@@ -33,7 +28,7 @@ const useHvSnackbar = () => {
33
28
  } = options;
34
29
  return enqueueNotistackSnackbar(/* @__PURE__ */ jsx(HvNotistackSnackMessage, { id, message, variant, snackbarContentProps }), {
35
30
  ...otherOptions,
36
- className: clsx(className)
31
+ className
37
32
  });
38
33
  }, [enqueueNotistackSnackbar]);
39
34
  return useMemo(() => ({
@@ -56,17 +51,17 @@ const HvSnackbarProvider = ({
56
51
  }) => {
57
52
  const {
58
53
  classes,
54
+ css,
59
55
  cx
60
56
  } = useClasses(classesProp);
61
57
  const notistackClasses = {
62
- containerRoot: /* @__PURE__ */ css(process.env.NODE_ENV === "production" ? {
63
- name: "146ko5x",
64
- styles: "pointer-events:all;& > div > div{padding:0 !important;transition:all 0s ease 0s !important;}"
65
- } : {
66
- name: "tg900f-containerRoot",
67
- styles: "pointer-events:all;& > div > div{padding:0 !important;transition:all 0s ease 0s !important;};label:containerRoot;",
68
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL2h2LXVpa2l0LXJlYWN0L2h2LXVpa2l0LXJlYWN0L3BhY2thZ2VzL2NvcmUvc3JjL2NvbXBvbmVudHMvU25hY2tiYXIvU25hY2tiYXJQcm92aWRlci9TbmFja2JhclByb3ZpZGVyLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFnSW1CIiwiZmlsZSI6Ii9ob21lL3J1bm5lci93b3JrL2h2LXVpa2l0LXJlYWN0L2h2LXVpa2l0LXJlYWN0L3BhY2thZ2VzL2NvcmUvc3JjL2NvbXBvbmVudHMvU25hY2tiYXIvU25hY2tiYXJQcm92aWRlci9TbmFja2JhclByb3ZpZGVyLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGZvcndhcmRSZWYsIFJlYWN0Tm9kZSwgdXNlQ2FsbGJhY2ssIHVzZU1lbW8gfSBmcm9tIFwicmVhY3RcIjtcblxuaW1wb3J0IHtcbiAgQ29tYmluZWRDbGFzc0tleSxcbiAgT3B0aW9uc09iamVjdCxcbiAgU25hY2tiYXJDb250ZW50LFxuICBTbmFja2JhclByb3ZpZGVyLFxuICBTbmFja2JhclByb3ZpZGVyUHJvcHMsXG4gIHVzZVNuYWNrYmFyLFxufSBmcm9tIFwibm90aXN0YWNrXCI7XG5cbmltcG9ydCB7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__
58
+ containerRoot: css({
59
+ pointerEvents: "all",
60
+ "& > div > div": {
61
+ // Overrides notistack extra padding
62
+ padding: "0 !important",
63
+ transition: "all 0s ease 0s !important"
64
+ }
70
65
  }),
71
66
  ...notistackClassesOverride
72
67
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SnackbarProvider.js","sources":["../../../../../src/components/Snackbar/SnackbarProvider/SnackbarProvider.tsx"],"sourcesContent":["import { forwardRef, ReactNode, useCallback, useMemo } from \"react\";\n\nimport {\n CombinedClassKey,\n OptionsObject,\n SnackbarContent,\n SnackbarProvider,\n SnackbarProviderProps,\n useSnackbar,\n} from \"notistack\";\n\nimport { clsx } from \"clsx\";\n\nimport { SnackbarOrigin } from \"@mui/material/Snackbar\";\nimport { ClassNameMap } from \"@mui/material\";\n\nimport { css } from \"@emotion/css\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { HvSnackbarContent, HvSnackbarContentProps } from \"../SnackbarContent\";\nimport { staticClasses, useClasses } from \"./SnackbarProvider.styles\";\nimport { HvSnackbarVariant } from \"../types\";\n\nexport { staticClasses as snackbarProviderClasses };\n\nexport type HvSnackbarProviderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSnackbarProviderProps {\n /** Your component tree. */\n children: React.ReactNode;\n /** Max visible snackbars. */\n maxSnack?: number;\n /** How much time the snackbar remains visible in milliseconds. */\n autoHideDuration?: number;\n /** Where is the snackbar placed. */\n anchorOrigin?: SnackbarOrigin;\n /** Class object used to override notistack classes. */\n notistackClassesOverride?: Partial<ClassNameMap<CombinedClassKey>>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSnackbarProviderClasses;\n className?: string;\n}\n\nexport interface HvNotistackSnackMessageProps extends OptionsObject {\n /** Id to be applied to the root node. */\n id?: string;\n /** Classname to apply on the root node */\n className?: string;\n /** Your component tree. */\n message?: ReactNode;\n /** Variant of the snackbar. */\n variant?: HvSnackbarVariant;\n /** Extra values to pass to the snackbar. */\n snackbarContentProps?: HvSnackbarContentProps;\n}\n\nconst HvNotistackSnackMessage = forwardRef<\n HTMLDivElement,\n HvNotistackSnackMessageProps\n>((props, ref) => {\n const { id, message, variant = \"success\", snackbarContentProps } = props;\n return (\n <SnackbarContent ref={ref}>\n <HvSnackbarContent\n id={id}\n variant={variant}\n showIcon\n label={message}\n role=\"none\"\n {...snackbarContentProps}\n />\n </SnackbarContent>\n );\n});\n\n// We override notistack hook to be able to customize the snackbar that should be called.\nexport const useHvSnackbar = () => {\n const { enqueueSnackbar: enqueueNotistackSnackbar, closeSnackbar } =\n useSnackbar();\n\n const enqueueSnackbar = useCallback(\n (message: ReactNode, options: HvNotistackSnackMessageProps = {}) => {\n const {\n id,\n variant = \"success\",\n snackbarContentProps,\n className,\n ...otherOptions\n } = options;\n\n return enqueueNotistackSnackbar(\n <HvNotistackSnackMessage\n id={id}\n message={message}\n variant={variant}\n snackbarContentProps={snackbarContentProps}\n />,\n { ...otherOptions, className: clsx(className) }\n );\n },\n [enqueueNotistackSnackbar]\n );\n return useMemo(\n () => ({\n enqueueSnackbar,\n closeSnackbar,\n }),\n [enqueueSnackbar, closeSnackbar]\n );\n};\n\nexport const HvSnackbarProvider = ({\n children,\n notistackClassesOverride,\n maxSnack = 5,\n autoHideDuration = 5000,\n anchorOrigin = {\n vertical: \"top\",\n horizontal: \"right\",\n },\n classes: classesProp,\n className,\n ...others\n}: HvSnackbarProviderProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const notistackClasses: SnackbarProviderProps[\"classes\"] = {\n containerRoot: css({\n pointerEvents: \"all\",\n \"& > div > div\": {\n // Overrides notistack extra padding\n padding: \"0 !important\",\n transition: \"all 0s ease 0s !important\",\n },\n }),\n ...notistackClassesOverride,\n };\n\n return (\n <SnackbarProvider\n classes={notistackClasses}\n maxSnack={maxSnack}\n autoHideDuration={autoHideDuration}\n anchorOrigin={anchorOrigin as SnackbarOrigin}\n className={cx(classes.snackItemRoot, className)}\n {...others}\n >\n {children}\n </SnackbarProvider>\n );\n};\n"],"names":["HvNotistackSnackMessage","forwardRef","props","ref","id","message","variant","snackbarContentProps","useHvSnackbar","enqueueSnackbar","enqueueNotistackSnackbar","closeSnackbar","useSnackbar","useCallback","options","className","otherOptions","clsx","useMemo","HvSnackbarProvider","children","notistackClassesOverride","maxSnack","autoHideDuration","anchorOrigin","vertical","horizontal","classes","classesProp","others","cx","useClasses","notistackClasses","containerRoot","css","process","env","NODE_ENV","name","styles","map","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","snackItemRoot"],"mappings":";;;;;;;;;;;AAyDA,MAAMA,0BAA0BC,WAG9B,CAACC,OAAOC,QAAQ;AACV,QAAA;AAAA,IAAEC;AAAAA,IAAIC;AAAAA,IAASC,UAAU;AAAA,IAAWC;AAAAA,EAAyBL,IAAAA;AACnE,SACG,oBAAA,iBAAA,EAAgB,KACf,UAAA,oBAAC,qBACC,IACA,SACA,UAAQ,MACR,OAAOG,SACP,MAAK,QACL,GAAIE,sBAAqB,EAE7B,CAAA;AAEJ,CAAC;AAGM,MAAMC,gBAAgBA,MAAM;AAC3B,QAAA;AAAA,IAAEC,iBAAiBC;AAAAA,IAA0BC;AAAAA,MACjDC,YAAY;AAEd,QAAMH,kBAAkBI,YACtB,CAACR,SAAoBS,UAAwC,CAAA,MAAO;AAC5D,UAAA;AAAA,MACJV;AAAAA,MACAE,UAAU;AAAA,MACVC;AAAAA,MACAQ;AAAAA,MACA,GAAGC;AAAAA,IACDF,IAAAA;AAEJ,WAAOJ,yBACJ,oBAAA,yBAAA,EACC,IACA,SACA,SACA,yBAEF;AAAA,MAAE,GAAGM;AAAAA,MAAcD,WAAWE,KAAKF,SAAS;AAAA,IAAA,CAC9C;AAAA,EAAA,GAEF,CAACL,wBAAwB,CAC3B;AACA,SAAOQ,QACL,OAAO;AAAA,IACLT;AAAAA,IACAE;AAAAA,EAEF,IAAA,CAACF,iBAAiBE,aAAa,CACjC;AACF;AAEO,MAAMQ,qBAAqBA,CAAC;AAAA,EACjCC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC,mBAAmB;AAAA,EACnBC,eAAe;AAAA,IACbC,UAAU;AAAA,IACVC,YAAY;AAAA,EACd;AAAA,EACAC,SAASC;AAAAA,EACTb;AAAAA,EACA,GAAGc;AACoB,MAAM;AACvB,QAAA;AAAA,IAAEF;AAAAA,IAASG;AAAAA,EAAAA,IAAOC,WAAWH,WAAW;AAE9C,QAAMI,mBAAqD;AAAA,IACzDC,eAAeC,oBAAGC,QAAAC,IAAAC,aAAA,eAAA;AAAA,MAAAC,MAAA;AAAA,MAAAC,QAAA;AAAA,IAAA,IAAA;AAAA,MAAAD,MAAA;AAAA,MAAAC,QAAA;AAAA,MAAAC,KAAA;AAAA,MAAAC,UAAAC;AAAAA,IAAAA,CAOjB;AAAA,IACD,GAAGrB;AAAAA,EAAAA;AAGL,SACG,oBAAA,kBAAA,EACC,SAASW,kBACT,UACA,kBACA,cACA,WAAWF,GAAGH,QAAQgB,eAAe5B,SAAS,GAC9C,GAAIc,QAEHT,SACH,CAAA;AAEJ;"}
1
+ {"version":3,"file":"SnackbarProvider.js","sources":["../../../../../src/components/Snackbar/SnackbarProvider/SnackbarProvider.tsx"],"sourcesContent":["import { forwardRef, ReactNode, useCallback, useMemo } from \"react\";\n\nimport {\n CombinedClassKey,\n OptionsObject,\n SnackbarContent,\n SnackbarProvider,\n SnackbarProviderProps,\n useSnackbar,\n} from \"notistack\";\n\nimport { SnackbarOrigin } from \"@mui/material/Snackbar\";\nimport { ClassNameMap } from \"@mui/material\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { HvSnackbarContent, HvSnackbarContentProps } from \"../SnackbarContent\";\nimport { staticClasses, useClasses } from \"./SnackbarProvider.styles\";\nimport { HvSnackbarVariant } from \"../types\";\n\nexport { staticClasses as snackbarProviderClasses };\n\nexport type HvSnackbarProviderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSnackbarProviderProps {\n /** Your component tree. */\n children: React.ReactNode;\n /** Max visible snackbars. */\n maxSnack?: number;\n /** How much time the snackbar remains visible in milliseconds. */\n autoHideDuration?: number;\n /** Where is the snackbar placed. */\n anchorOrigin?: SnackbarOrigin;\n /** Class object used to override notistack classes. */\n notistackClassesOverride?: Partial<ClassNameMap<CombinedClassKey>>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSnackbarProviderClasses;\n className?: string;\n}\n\nexport interface HvNotistackSnackMessageProps extends OptionsObject {\n /** Id to be applied to the root node. */\n id?: string;\n /** Classname to apply on the root node */\n className?: string;\n /** Your component tree. */\n message?: ReactNode;\n /** Variant of the snackbar. */\n variant?: HvSnackbarVariant;\n /** Extra values to pass to the snackbar. */\n snackbarContentProps?: HvSnackbarContentProps;\n}\n\nconst HvNotistackSnackMessage = forwardRef<\n HTMLDivElement,\n HvNotistackSnackMessageProps\n>((props, ref) => {\n const { id, message, variant = \"success\", snackbarContentProps } = props;\n return (\n <SnackbarContent ref={ref}>\n <HvSnackbarContent\n id={id}\n variant={variant}\n showIcon\n label={message}\n role=\"none\"\n {...snackbarContentProps}\n />\n </SnackbarContent>\n );\n});\n\n// We override notistack hook to be able to customize the snackbar that should be called.\nexport const useHvSnackbar = () => {\n const { enqueueSnackbar: enqueueNotistackSnackbar, closeSnackbar } =\n useSnackbar();\n\n const enqueueSnackbar = useCallback(\n (message: ReactNode, options: HvNotistackSnackMessageProps = {}) => {\n const {\n id,\n variant = \"success\",\n snackbarContentProps,\n className,\n ...otherOptions\n } = options;\n\n return enqueueNotistackSnackbar(\n <HvNotistackSnackMessage\n id={id}\n message={message}\n variant={variant}\n snackbarContentProps={snackbarContentProps}\n />,\n { ...otherOptions, className }\n );\n },\n [enqueueNotistackSnackbar]\n );\n return useMemo(\n () => ({\n enqueueSnackbar,\n closeSnackbar,\n }),\n [enqueueSnackbar, closeSnackbar]\n );\n};\n\nexport const HvSnackbarProvider = ({\n children,\n notistackClassesOverride,\n maxSnack = 5,\n autoHideDuration = 5000,\n anchorOrigin = {\n vertical: \"top\",\n horizontal: \"right\",\n },\n classes: classesProp,\n className,\n ...others\n}: HvSnackbarProviderProps) => {\n const { classes, css, cx } = useClasses(classesProp);\n\n const notistackClasses: SnackbarProviderProps[\"classes\"] = {\n containerRoot: css({\n pointerEvents: \"all\",\n \"& > div > div\": {\n // Overrides notistack extra padding\n padding: \"0 !important\",\n transition: \"all 0s ease 0s !important\",\n },\n }),\n ...notistackClassesOverride,\n };\n\n return (\n <SnackbarProvider\n classes={notistackClasses}\n maxSnack={maxSnack}\n autoHideDuration={autoHideDuration}\n anchorOrigin={anchorOrigin as SnackbarOrigin}\n className={cx(classes.snackItemRoot, className)}\n {...others}\n >\n {children}\n </SnackbarProvider>\n );\n};\n"],"names":["HvNotistackSnackMessage","forwardRef","props","ref","id","message","variant","snackbarContentProps","useHvSnackbar","enqueueSnackbar","enqueueNotistackSnackbar","closeSnackbar","useSnackbar","useCallback","options","className","otherOptions","useMemo","HvSnackbarProvider","children","notistackClassesOverride","maxSnack","autoHideDuration","anchorOrigin","vertical","horizontal","classes","classesProp","others","css","cx","useClasses","notistackClasses","containerRoot","pointerEvents","padding","transition","snackItemRoot"],"mappings":";;;;;;AAqDA,MAAMA,0BAA0BC,WAG9B,CAACC,OAAOC,QAAQ;AACV,QAAA;AAAA,IAAEC;AAAAA,IAAIC;AAAAA,IAASC,UAAU;AAAA,IAAWC;AAAAA,EAAyBL,IAAAA;AACnE,SACG,oBAAA,iBAAA,EAAgB,KACf,UAAA,oBAAC,qBACC,IACA,SACA,UAAQ,MACR,OAAOG,SACP,MAAK,QACL,GAAIE,sBAAqB,EAE7B,CAAA;AAEJ,CAAC;AAGM,MAAMC,gBAAgBA,MAAM;AAC3B,QAAA;AAAA,IAAEC,iBAAiBC;AAAAA,IAA0BC;AAAAA,MACjDC,YAAY;AAEd,QAAMH,kBAAkBI,YACtB,CAACR,SAAoBS,UAAwC,CAAA,MAAO;AAC5D,UAAA;AAAA,MACJV;AAAAA,MACAE,UAAU;AAAA,MACVC;AAAAA,MACAQ;AAAAA,MACA,GAAGC;AAAAA,IACDF,IAAAA;AAEJ,WAAOJ,yBACJ,oBAAA,yBAAA,EACC,IACA,SACA,SACA,yBAEF;AAAA,MAAE,GAAGM;AAAAA,MAAcD;AAAAA,IAAAA,CACrB;AAAA,EAAA,GAEF,CAACL,wBAAwB,CAC3B;AACA,SAAOO,QACL,OAAO;AAAA,IACLR;AAAAA,IACAE;AAAAA,EAEF,IAAA,CAACF,iBAAiBE,aAAa,CACjC;AACF;AAEO,MAAMO,qBAAqBA,CAAC;AAAA,EACjCC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC,mBAAmB;AAAA,EACnBC,eAAe;AAAA,IACbC,UAAU;AAAA,IACVC,YAAY;AAAA,EACd;AAAA,EACAC,SAASC;AAAAA,EACTZ;AAAAA,EACA,GAAGa;AACoB,MAAM;AACvB,QAAA;AAAA,IAAEF;AAAAA,IAASG;AAAAA,IAAKC;AAAAA,EAAAA,IAAOC,WAAWJ,WAAW;AAEnD,QAAMK,mBAAqD;AAAA,IACzDC,eAAeJ,IAAI;AAAA,MACjBK,eAAe;AAAA,MACf,iBAAiB;AAAA;AAAA,QAEfC,SAAS;AAAA,QACTC,YAAY;AAAA,MACd;AAAA,IAAA,CACD;AAAA,IACD,GAAGhB;AAAAA,EAAAA;AAGL,SACG,oBAAA,kBAAA,EACC,SAASY,kBACT,UACA,kBACA,cACA,WAAWF,GAAGJ,QAAQW,eAAetB,SAAS,GAC9C,GAAIa,QAEHT,SACH,CAAA;AAEJ;"}
@@ -3,6 +3,7 @@ import { forwardRef } from "react";
3
3
  import { Tooltip, Fade } from "@mui/material";
4
4
  import { useTheme } from "../../hooks/useTheme.js";
5
5
  import { useDefaultProps } from "../../hooks/useDefaultProps.js";
6
+ import { getElementById } from "../../utils/document.js";
6
7
  import { useClasses } from "./Tooltip.styles.js";
7
8
  import { staticClasses } from "./Tooltip.styles.js";
8
9
  const HvTooltip = forwardRef((props, ref) => {
@@ -33,7 +34,7 @@ const HvTooltip = forwardRef((props, ref) => {
33
34
  tooltip: useSingle ? classes.tooltip : classes.tooltipMulti,
34
35
  popper: classes.popper
35
36
  }, title, PopperProps: {
36
- container: typeof window !== "undefined" ? document.getElementById(containerId || rootId || "") || document.body : void 0
37
+ container: getElementById(containerId || rootId)
37
38
  }, ...others, children });
38
39
  });
39
40
  export {