@hitachivantara/uikit-react-core 5.85.1 → 5.87.0

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 (83) hide show
  1. package/dist/cjs/Banner/BannerContent/BannerContent.cjs +60 -28
  2. package/dist/cjs/Banner/BannerContent/BannerContent.styles.cjs +30 -1
  3. package/dist/cjs/ColorPicker/Fields/Fields.styles.cjs +3 -2
  4. package/dist/cjs/ColorPicker/PresetColors/PresetColors.styles.cjs +1 -1
  5. package/dist/cjs/ColorPicker/SavedColors/SavedColors.styles.cjs +2 -2
  6. package/dist/cjs/EmptyState/EmptyState.styles.cjs +1 -1
  7. package/dist/cjs/{ScrollTo/Horizontal → ScrollToHorizontal}/HorizontalScrollListItem/HorizontalScrollListItem.cjs +2 -2
  8. package/dist/cjs/{ScrollTo/Horizontal → ScrollToHorizontal}/HorizontalScrollListItem/HorizontalScrollListItem.styles.cjs +1 -1
  9. package/dist/cjs/{ScrollTo/Horizontal → ScrollToHorizontal}/ScrollToHorizontal.cjs +3 -3
  10. package/dist/cjs/{ScrollTo/Vertical → ScrollToVertical}/ScrollToVertical.cjs +3 -3
  11. package/dist/cjs/{ScrollTo/Vertical → ScrollToVertical}/VerticalScrollListItem/VerticalScrollListItem.cjs +1 -1
  12. package/dist/cjs/{ScrollTo/Vertical → ScrollToVertical}/VerticalScrollListItem/VerticalScrollListItem.styles.cjs +1 -1
  13. package/dist/cjs/Tag/Tag.styles.cjs +1 -1
  14. package/dist/cjs/{ScrollTo → hooks}/useScrollTo.cjs +14 -10
  15. package/dist/cjs/index.cjs +9 -9
  16. package/dist/cjs/{ScrollTo/utils.cjs → utils/scroll.cjs} +12 -0
  17. package/dist/esm/ActionBar/ActionBar.js.map +1 -1
  18. package/dist/esm/Banner/BannerContent/BannerContent.js +61 -29
  19. package/dist/esm/Banner/BannerContent/BannerContent.js.map +1 -1
  20. package/dist/esm/Banner/BannerContent/BannerContent.styles.js +30 -1
  21. package/dist/esm/Banner/BannerContent/BannerContent.styles.js.map +1 -1
  22. package/dist/esm/Box/Box.js.map +1 -1
  23. package/dist/esm/ColorPicker/Fields/Fields.styles.js +3 -2
  24. package/dist/esm/ColorPicker/Fields/Fields.styles.js.map +1 -1
  25. package/dist/esm/ColorPicker/PresetColors/PresetColors.styles.js +1 -1
  26. package/dist/esm/ColorPicker/PresetColors/PresetColors.styles.js.map +1 -1
  27. package/dist/esm/ColorPicker/SavedColors/SavedColors.styles.js +2 -2
  28. package/dist/esm/ColorPicker/SavedColors/SavedColors.styles.js.map +1 -1
  29. package/dist/esm/EmptyState/EmptyState.styles.js +1 -1
  30. package/dist/esm/EmptyState/EmptyState.styles.js.map +1 -1
  31. package/dist/esm/Focus/Focus.js.map +1 -1
  32. package/dist/esm/Grid/Grid.js.map +1 -1
  33. package/dist/esm/Kpi/Kpi.js.map +1 -1
  34. package/dist/esm/Link/Link.js.map +1 -1
  35. package/dist/esm/List/List.js.map +1 -1
  36. package/dist/esm/{ScrollTo/Horizontal → ScrollToHorizontal}/HorizontalScrollListItem/HorizontalScrollListItem.js +2 -2
  37. package/dist/esm/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.js.map +1 -0
  38. package/dist/esm/{ScrollTo/Horizontal → ScrollToHorizontal}/HorizontalScrollListItem/HorizontalScrollListItem.styles.js +1 -1
  39. package/dist/esm/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js.map +1 -0
  40. package/dist/esm/{ScrollTo/Horizontal → ScrollToHorizontal}/ScrollToHorizontal.js +3 -3
  41. package/dist/esm/{ScrollTo/Horizontal → ScrollToHorizontal}/ScrollToHorizontal.js.map +1 -1
  42. package/dist/esm/ScrollToHorizontal/ScrollToHorizontal.styles.js.map +1 -0
  43. package/dist/esm/{ScrollTo/Vertical → ScrollToVertical}/ScrollToVertical.js +3 -3
  44. package/dist/esm/{ScrollTo/Vertical → ScrollToVertical}/ScrollToVertical.js.map +1 -1
  45. package/dist/esm/ScrollToVertical/ScrollToVertical.styles.js.map +1 -0
  46. package/dist/esm/{ScrollTo/Vertical → ScrollToVertical}/VerticalScrollListItem/VerticalScrollListItem.js +1 -1
  47. package/dist/esm/ScrollToVertical/VerticalScrollListItem/VerticalScrollListItem.js.map +1 -0
  48. package/dist/esm/{ScrollTo/Vertical → ScrollToVertical}/VerticalScrollListItem/VerticalScrollListItem.styles.js +1 -1
  49. package/dist/esm/ScrollToVertical/VerticalScrollListItem/VerticalScrollListItem.styles.js.map +1 -0
  50. package/dist/esm/Tag/Tag.styles.js +1 -1
  51. package/dist/esm/Tag/Tag.styles.js.map +1 -1
  52. package/dist/esm/hocs/withTooltip.js.map +1 -1
  53. package/dist/esm/{ScrollTo → hooks}/useScrollTo.js +9 -5
  54. package/dist/esm/hooks/useScrollTo.js.map +1 -0
  55. package/dist/esm/index.js +10 -10
  56. package/dist/esm/{ScrollTo/utils.js → utils/scroll.js} +12 -0
  57. package/dist/esm/utils/scroll.js.map +1 -0
  58. package/dist/types/index.d.ts +340 -361
  59. package/package.json +6 -6
  60. package/dist/cjs/Banner/BannerContent/ActionContainer/ActionContainer.cjs +0 -46
  61. package/dist/cjs/Banner/BannerContent/ActionContainer/ActionContainer.styles.cjs +0 -31
  62. package/dist/cjs/Banner/BannerContent/MessageContainer/MessageContainer.cjs +0 -44
  63. package/dist/cjs/Banner/BannerContent/MessageContainer/MessageContainer.styles.cjs +0 -23
  64. package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.js +0 -47
  65. package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.js.map +0 -1
  66. package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.styles.js +0 -31
  67. package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.styles.js.map +0 -1
  68. package/dist/esm/Banner/BannerContent/MessageContainer/MessageContainer.js +0 -45
  69. package/dist/esm/Banner/BannerContent/MessageContainer/MessageContainer.js.map +0 -1
  70. package/dist/esm/Banner/BannerContent/MessageContainer/MessageContainer.styles.js +0 -23
  71. package/dist/esm/Banner/BannerContent/MessageContainer/MessageContainer.styles.js.map +0 -1
  72. package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js.map +0 -1
  73. package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js.map +0 -1
  74. package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.styles.js.map +0 -1
  75. package/dist/esm/ScrollTo/Vertical/ScrollToVertical.styles.js.map +0 -1
  76. package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js.map +0 -1
  77. package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.styles.js.map +0 -1
  78. package/dist/esm/ScrollTo/useScrollTo.js.map +0 -1
  79. package/dist/esm/ScrollTo/utils.js.map +0 -1
  80. /package/dist/cjs/{ScrollTo/Horizontal → ScrollToHorizontal}/ScrollToHorizontal.styles.cjs +0 -0
  81. /package/dist/cjs/{ScrollTo/Vertical → ScrollToVertical}/ScrollToVertical.styles.cjs +0 -0
  82. /package/dist/esm/{ScrollTo/Horizontal → ScrollToHorizontal}/ScrollToHorizontal.styles.js +0 -0
  83. /package/dist/esm/{ScrollTo/Vertical → ScrollToVertical}/ScrollToVertical.styles.js +0 -0
@@ -13,7 +13,9 @@ const { useClasses, staticClasses } = createClasses("HvBannerContent", {
13
13
  display: "flex",
14
14
  alignItems: "center",
15
15
  padding: theme.spacing("xs", 0),
16
- paddingLeft: theme.space.sm
16
+ paddingLeft: theme.space.sm,
17
+ ...theme.typography.body,
18
+ color: theme.colors.base_dark
17
19
  },
18
20
  action: {
19
21
  padding: theme.spacing("xs"),
@@ -39,6 +41,33 @@ const { useClasses, staticClasses } = createClasses("HvBannerContent", {
39
41
  outContainer: {
40
42
  width: "100%",
41
43
  position: "relative"
44
+ },
45
+ messageContainer: {
46
+ wordBreak: "break-word",
47
+ maxWidth: 700,
48
+ overflow: "hidden",
49
+ marginRight: 10
50
+ },
51
+ iconContainer: {
52
+ marginRight: theme.space.xs,
53
+ marginLeft: -theme.space.xs
54
+ },
55
+ messageActions: {
56
+ flex: "0 0 auto"
57
+ },
58
+ actionContainer: {
59
+ display: "flex",
60
+ flexDirection: "column",
61
+ height: "100%",
62
+ justifyContent: "space-between"
63
+ },
64
+ actionsInnerContainer: {
65
+ flexDirection: "row",
66
+ marginTop: "8px"
67
+ // avoid overlap with close button outline focus ring
68
+ },
69
+ closeAction: {
70
+ alignSelf: "flex-end"
42
71
  }
43
72
  });
44
73
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"BannerContent.styles.js","sources":["../../../../src/Banner/BannerContent/BannerContent.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvBannerContent\", {\n root: {\n minWidth: \"100%\",\n position: \"relative\",\n display: \"flex\",\n flexWrap: \"nowrap\",\n boxShadow: \"none\",\n borderRadius: theme.radii.none,\n },\n message: {\n display: \"flex\",\n alignItems: \"center\",\n padding: theme.spacing(\"xs\", 0),\n paddingLeft: theme.space.sm,\n },\n action: {\n padding: theme.spacing(\"xs\"),\n marginRight: 0,\n flex: \"0 0 auto\",\n placeSelf: \"stretch\",\n },\n baseVariant: {\n padding: 0,\n },\n success: {\n backgroundColor: theme.colors.positive_20,\n },\n warning: {\n backgroundColor: theme.colors.warning_20,\n },\n error: {\n backgroundColor: theme.colors.negative_20,\n },\n default: {\n backgroundColor: theme.colors.neutral_20,\n },\n outContainer: {\n width: \"100%\",\n position: \"relative\",\n },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,YAAY,kBAAkB,cAAc,mBAAmB;AAAA,EAC5E,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,UAAU;AAAA,IACV,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,MAAM,CAAC;AAAA,IAC9B,aAAa,MAAM,MAAM;AAAA,EAC3B;AAAA,EACA,QAAQ;AAAA,IACN,SAAS,MAAM,QAAQ,IAAI;AAAA,IAC3B,aAAa;AAAA,IACb,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EACA,aAAa;AAAA,IACX,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,SAAS;AAAA,IACP,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,OAAO;AAAA,IACL,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,SAAS;AAAA,IACP,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,cAAc;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EAAA;AAEd,CAAC;"}
1
+ {"version":3,"file":"BannerContent.styles.js","sources":["../../../../src/Banner/BannerContent/BannerContent.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvBannerContent\", {\n root: {\n minWidth: \"100%\",\n position: \"relative\",\n display: \"flex\",\n flexWrap: \"nowrap\",\n boxShadow: \"none\",\n borderRadius: theme.radii.none,\n },\n message: {\n display: \"flex\",\n alignItems: \"center\",\n padding: theme.spacing(\"xs\", 0),\n paddingLeft: theme.space.sm,\n ...theme.typography.body,\n color: theme.colors.base_dark,\n },\n action: {\n padding: theme.spacing(\"xs\"),\n marginRight: 0,\n flex: \"0 0 auto\",\n placeSelf: \"stretch\",\n },\n baseVariant: {\n padding: 0,\n },\n success: {\n backgroundColor: theme.colors.positive_20,\n },\n warning: {\n backgroundColor: theme.colors.warning_20,\n },\n error: {\n backgroundColor: theme.colors.negative_20,\n },\n default: {\n backgroundColor: theme.colors.neutral_20,\n },\n outContainer: {\n width: \"100%\",\n position: \"relative\",\n },\n messageContainer: {\n wordBreak: \"break-word\",\n maxWidth: 700,\n overflow: \"hidden\",\n marginRight: 10,\n },\n iconContainer: {\n marginRight: theme.space.xs,\n marginLeft: -theme.space.xs,\n },\n messageActions: {\n flex: \"0 0 auto\",\n },\n actionContainer: {\n display: \"flex\",\n flexDirection: \"column\",\n height: \"100%\",\n justifyContent: \"space-between\",\n },\n actionsInnerContainer: {\n flexDirection: \"row\",\n marginTop: \"8px\", // avoid overlap with close button outline focus ring\n },\n closeAction: {\n alignSelf: \"flex-end\",\n },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,YAAY,kBAAkB,cAAc,mBAAmB;AAAA,EAC5E,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,UAAU;AAAA,IACV,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,MAAM,CAAC;AAAA,IAC9B,aAAa,MAAM,MAAM;AAAA,IACzB,GAAG,MAAM,WAAW;AAAA,IACpB,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,IACN,SAAS,MAAM,QAAQ,IAAI;AAAA,IAC3B,aAAa;AAAA,IACb,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EACA,aAAa;AAAA,IACX,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,SAAS;AAAA,IACP,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,OAAO;AAAA,IACL,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,SAAS;AAAA,IACP,iBAAiB,MAAM,OAAO;AAAA,EAChC;AAAA,EACA,cAAc;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA,kBAAkB;AAAA,IAChB,WAAW;AAAA,IACX,UAAU;AAAA,IACV,UAAU;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EACA,eAAe;AAAA,IACb,aAAa,MAAM,MAAM;AAAA,IACzB,YAAY,CAAC,MAAM,MAAM;AAAA,EAC3B;AAAA,EACA,gBAAgB;AAAA,IACd,MAAM;AAAA,EACR;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAClB;AAAA,EACA,uBAAuB;AAAA,IACrB,eAAe;AAAA,IACf,WAAW;AAAA;AAAA,EACb;AAAA,EACA,aAAa;AAAA,IACX,WAAW;AAAA,EAAA;AAEf,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Box.js","sources":["../../../src/Box/Box.tsx"],"sourcesContent":["import { useDefaultProps } from \"@hitachivantara/uikit-react-utils\";\nimport { HvTheme, theme } from \"@hitachivantara/uikit-styles\";\n\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\n\n// v6 - This shouldn't be named HvBoxProps\nexport type HvBoxProps<C extends React.ElementType = \"div\"> =\n PolymorphicComponentRef<\n C,\n {\n style?: React.CSSProperties;\n sx?: React.CSSProperties | ((theme: HvTheme) => React.CSSProperties);\n }\n >;\n\nconst sxFn = (sx: HvBoxProps[\"sx\"]) => {\n return typeof sx === \"function\" ? sx(theme) : sx;\n};\n\n/**\n * Customizable layout component that can be used to wrap other components.\n * It can be used to add styles to the wrapped components.\n * It can also be used to create a layout using the flexbox properties.\n */\nexport const HvBox = fixedForwardRef(function HvBox<\n C extends React.ElementType = \"div\",\n>(props: HvBoxProps<C>, ref?: PolymorphicRef<C>) {\n const {\n style,\n component: Component = \"div\",\n sx,\n children,\n classes, // Extracted since useDefaultProps creates this prop even if it's not part of the component's API\n ...restProps\n } = useDefaultProps(\"HvBox\", props);\n\n return (\n <Component style={sx ? sxFn(sx) : style} ref={ref} {...restProps}>\n {children}\n </Component>\n );\n});\n"],"names":["HvBox"],"mappings":";;;;AAmBA,MAAM,OAAO,CAAC,OAAyB;AACrC,SAAO,OAAO,OAAO,aAAa,GAAG,KAAK,IAAI;AAChD;AAOO,MAAM,QAAQ,gBAAgB,SAASA,OAE5C,OAAsB,KAAyB;AACzC,QAAA;AAAA,IACJ;AAAA,IACA,WAAW,YAAY;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,SAAS,KAAK;AAGhC,SAAA,oBAAC,WAAU,EAAA,OAAO,KAAK,KAAK,EAAE,IAAI,OAAO,KAAW,GAAG,WACpD,SACH,CAAA;AAEJ,CAAC;"}
1
+ {"version":3,"file":"Box.js","sources":["../../../src/Box/Box.tsx"],"sourcesContent":["import { useDefaultProps } from \"@hitachivantara/uikit-react-utils\";\nimport { HvTheme, theme } from \"@hitachivantara/uikit-styles\";\n\nimport {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\n\n// v6 - This shouldn't be named HvBoxProps\nexport type HvBoxProps<C extends React.ElementType = \"div\"> =\n PolymorphicComponentRef<\n C,\n {\n style?: React.CSSProperties;\n sx?: React.CSSProperties | ((theme: HvTheme) => React.CSSProperties);\n }\n >;\n\nconst sxFn = (sx: HvBoxProps[\"sx\"]) => {\n return typeof sx === \"function\" ? sx(theme) : sx;\n};\n\n/**\n * Customizable layout component that can be used to wrap other components.\n * It can be used to add styles to the wrapped components.\n * It can also be used to create a layout using the flexbox properties.\n * @deprecated use native elements instead (e.g. `div`)\n */\nexport const HvBox = fixedForwardRef(function HvBox<\n C extends React.ElementType = \"div\",\n>(props: HvBoxProps<C>, ref?: PolymorphicRef<C>) {\n const {\n style,\n component: Component = \"div\",\n sx,\n children,\n classes, // Extracted since useDefaultProps creates this prop even if it's not part of the component's API\n ...restProps\n } = useDefaultProps(\"HvBox\", props);\n\n return (\n <Component style={sx ? sxFn(sx) : style} ref={ref} {...restProps}>\n {children}\n </Component>\n );\n});\n"],"names":["HvBox"],"mappings":";;;;AAmBA,MAAM,OAAO,CAAC,OAAyB;AACrC,SAAO,OAAO,OAAO,aAAa,GAAG,KAAK,IAAI;AAChD;AAQO,MAAM,QAAQ,gBAAgB,SAASA,OAE5C,OAAsB,KAAyB;AACzC,QAAA;AAAA,IACJ;AAAA,IACA,WAAW,YAAY;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,SAAS,KAAK;AAGhC,SAAA,oBAAC,WAAU,EAAA,OAAO,KAAK,KAAK,EAAE,IAAI,OAAO,KAAW,GAAG,WACpD,SACH,CAAA;AAEJ,CAAC;"}
@@ -1,4 +1,5 @@
1
1
  import { createClasses } from "@hitachivantara/uikit-react-utils";
2
+ import { theme } from "@hitachivantara/uikit-styles";
2
3
  const name = "HvColorPicker-Fields";
3
4
  const { staticClasses, useClasses } = createClasses(name, {
4
5
  fields: {
@@ -9,7 +10,7 @@ const { staticClasses, useClasses } = createClasses(name, {
9
10
  },
10
11
  single: {
11
12
  maxWidth: "50px",
12
- paddingLeft: "4px",
13
+ paddingLeft: theme.space.xxs,
13
14
  "& input": {
14
15
  marginLeft: 5,
15
16
  marginRight: 5
@@ -20,7 +21,7 @@ const { staticClasses, useClasses } = createClasses(name, {
20
21
  },
21
22
  double: {
22
23
  maxWidth: "82px",
23
- paddingRight: "4px",
24
+ paddingRight: theme.space.xxs,
24
25
  "& input": {
25
26
  textTransform: "uppercase",
26
27
  marginLeft: 5,
@@ -1 +1 @@
1
- {"version":3,"file":"Fields.styles.js","sources":["../../../../src/ColorPicker/Fields/Fields.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\n\nconst name = \"HvColorPicker-Fields\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n fields: {\n width: \"100%\",\n display: \"flex\",\n paddingTop: \"18px\",\n marginRight: \"0px\",\n },\n single: {\n maxWidth: \"50px\",\n paddingLeft: \"4px\",\n \"& input\": {\n marginLeft: 5,\n marginRight: 5,\n },\n \"& label\": {\n paddingLeft: 5,\n },\n },\n double: {\n maxWidth: \"82px\",\n paddingRight: \"4px\",\n \"& input\": {\n textTransform: \"uppercase\",\n marginLeft: 5,\n marginRight: 5,\n },\n \"& label\": {\n paddingLeft: 5,\n },\n },\n});\n"],"names":[],"mappings":";AAEA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,aAAa;AAAA,EACf;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,aAAa;AAAA,IACb,WAAW;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,IACA,WAAW;AAAA,MACT,aAAa;AAAA,IAAA;AAAA,EAEjB;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,cAAc;AAAA,IACd,WAAW;AAAA,MACT,eAAe;AAAA,MACf,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,IACA,WAAW;AAAA,MACT,aAAa;AAAA,IAAA;AAAA,EACf;AAEJ,CAAC;"}
1
+ {"version":3,"file":"Fields.styles.js","sources":["../../../../src/ColorPicker/Fields/Fields.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nconst name = \"HvColorPicker-Fields\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n fields: {\n width: \"100%\",\n display: \"flex\",\n paddingTop: \"18px\",\n marginRight: \"0px\",\n },\n single: {\n maxWidth: \"50px\",\n paddingLeft: theme.space.xxs,\n \"& input\": {\n marginLeft: 5,\n marginRight: 5,\n },\n \"& label\": {\n paddingLeft: 5,\n },\n },\n double: {\n maxWidth: \"82px\",\n paddingRight: theme.space.xxs,\n \"& input\": {\n textTransform: \"uppercase\",\n marginLeft: 5,\n marginRight: 5,\n },\n \"& label\": {\n paddingLeft: 5,\n },\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,aAAa;AAAA,EACf;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,aAAa,MAAM,MAAM;AAAA,IACzB,WAAW;AAAA,MACT,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,IACA,WAAW;AAAA,MACT,aAAa;AAAA,IAAA;AAAA,EAEjB;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,cAAc,MAAM,MAAM;AAAA,IAC1B,WAAW;AAAA,MACT,eAAe;AAAA,MACf,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,IACA,WAAW;AAAA,MACT,aAAa;AAAA,IAAA;AAAA,EACf;AAEJ,CAAC;"}
@@ -18,7 +18,7 @@ const { staticClasses, useClasses } = createClasses(name, {
18
18
  swatchWrap: {
19
19
  width: "32px",
20
20
  height: "32px",
21
- margin: "4px",
21
+ margin: theme.space.xxs,
22
22
  "& > span > div": {
23
23
  borderRadius: theme.radii.base
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PresetColors.styles.js","sources":["../../../../src/ColorPicker/PresetColors/PresetColors.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nconst name = \"HvColorPicker-PresetColors\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: { width: \"232px\" },\n colors: {\n display: \"flex\",\n flexWrap: \"wrap\",\n position: \"relative\",\n width: \"calc(100% + 8px)\",\n margin: \"-4px -4px\",\n padding: 0,\n },\n title: {\n fontWeight: theme.fontWeights.semibold,\n marginBottom: 8,\n },\n swatchWrap: {\n width: \"32px\",\n height: \"32px\",\n margin: \"4px\",\n\n \"& > span > div\": {\n borderRadius: theme.radii.base,\n },\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,MAAM,EAAE,OAAO,QAAQ;AAAA,EACvB,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,OAAO;AAAA,IACL,YAAY,MAAM,YAAY;AAAA,IAC9B,cAAc;AAAA,EAChB;AAAA,EACA,YAAY;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IAER,kBAAkB;AAAA,MAChB,cAAc,MAAM,MAAM;AAAA,IAAA;AAAA,EAC5B;AAEJ,CAAC;"}
1
+ {"version":3,"file":"PresetColors.styles.js","sources":["../../../../src/ColorPicker/PresetColors/PresetColors.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nconst name = \"HvColorPicker-PresetColors\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: { width: \"232px\" },\n colors: {\n display: \"flex\",\n flexWrap: \"wrap\",\n position: \"relative\",\n width: \"calc(100% + 8px)\",\n margin: \"-4px -4px\",\n padding: 0,\n },\n title: {\n fontWeight: theme.fontWeights.semibold,\n marginBottom: 8,\n },\n swatchWrap: {\n width: \"32px\",\n height: \"32px\",\n margin: theme.space.xxs,\n\n \"& > span > div\": {\n borderRadius: theme.radii.base,\n },\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,MAAM,EAAE,OAAO,QAAQ;AAAA,EACvB,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,OAAO;AAAA,IACL,YAAY,MAAM,YAAY;AAAA,IAC9B,cAAc;AAAA,EAChB;AAAA,EACA,YAAY;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ,MAAM,MAAM;AAAA,IAEpB,kBAAkB;AAAA,MAChB,cAAc,MAAM,MAAM;AAAA,IAAA;AAAA,EAC5B;AAEJ,CAAC;"}
@@ -3,7 +3,7 @@ import { theme } from "@hitachivantara/uikit-styles";
3
3
  const name = "HvColorPicker-SavedColors";
4
4
  const { staticClasses, useClasses } = createClasses(name, {
5
5
  addButton: {
6
- margin: "4px",
6
+ margin: theme.space.xxs,
7
7
  width: "32px",
8
8
  height: "32px"
9
9
  },
@@ -20,7 +20,7 @@ const { staticClasses, useClasses } = createClasses(name, {
20
20
  swatchWrap: {
21
21
  width: "32px",
22
22
  height: "32px",
23
- margin: "4px",
23
+ margin: theme.space.xxs,
24
24
  "& > span > div": {
25
25
  borderRadius: theme.radii.base
26
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SavedColors.styles.js","sources":["../../../../src/ColorPicker/SavedColors/SavedColors.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nconst name = \"HvColorPicker-SavedColors\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n addButton: {\n margin: \"4px\",\n width: \"32px\",\n height: \"32px\",\n },\n root: {\n display: \"flex\",\n flexWrap: \"wrap\",\n position: \"relative\",\n alignItems: \"center\",\n padding: 0,\n width: \"calc(100% + 8px)\",\n margin: \"-4px -4px\",\n },\n swatchRoot: { position: \"relative\" },\n swatchWrap: {\n width: \"32px\",\n height: \"32px\",\n margin: \"4px\",\n\n \"& > span > div\": {\n borderRadius: theme.radii.base,\n },\n },\n removeButtonRoot: {\n position: \"absolute\",\n top: 0,\n right: 0,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: 16,\n width: 16,\n background: theme.colors.atmo1,\n borderRadius: theme.radii.base,\n },\n removeButton: {\n height: 16,\n width: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n margin: 0,\n\n \"& div > span\": {\n height: 16,\n width: 16,\n\n \"& > div\": { height: 16, width: 16 },\n },\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,YAAY,EAAE,UAAU,WAAW;AAAA,EACnC,YAAY;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IAER,kBAAkB;AAAA,MAChB,cAAc,MAAM,MAAM;AAAA,IAAA;AAAA,EAE9B;AAAA,EACA,kBAAkB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY,MAAM,OAAO;AAAA,IACzB,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,cAAc;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAQ;AAAA,IAER,gBAAgB;AAAA,MACd,QAAQ;AAAA,MACR,OAAO;AAAA,MAEP,WAAW,EAAE,QAAQ,IAAI,OAAO,GAAG;AAAA,IAAA;AAAA,EACrC;AAEJ,CAAC;"}
1
+ {"version":3,"file":"SavedColors.styles.js","sources":["../../../../src/ColorPicker/SavedColors/SavedColors.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nconst name = \"HvColorPicker-SavedColors\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n addButton: {\n margin: theme.space.xxs,\n width: \"32px\",\n height: \"32px\",\n },\n root: {\n display: \"flex\",\n flexWrap: \"wrap\",\n position: \"relative\",\n alignItems: \"center\",\n padding: 0,\n width: \"calc(100% + 8px)\",\n margin: \"-4px -4px\",\n },\n swatchRoot: { position: \"relative\" },\n swatchWrap: {\n width: \"32px\",\n height: \"32px\",\n margin: theme.space.xxs,\n\n \"& > span > div\": {\n borderRadius: theme.radii.base,\n },\n },\n removeButtonRoot: {\n position: \"absolute\",\n top: 0,\n right: 0,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: 16,\n width: 16,\n background: theme.colors.atmo1,\n borderRadius: theme.radii.base,\n },\n removeButton: {\n height: 16,\n width: 16,\n minWidth: 16,\n minHeight: 16,\n padding: 0,\n margin: 0,\n\n \"& div > span\": {\n height: 16,\n width: 16,\n\n \"& > div\": { height: 16, width: 16 },\n },\n },\n});\n"],"names":[],"mappings":";;AAGA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,WAAW;AAAA,IACT,QAAQ,MAAM,MAAM;AAAA,IACpB,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,YAAY,EAAE,UAAU,WAAW;AAAA,EACnC,YAAY;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ,MAAM,MAAM;AAAA,IAEpB,kBAAkB;AAAA,MAChB,cAAc,MAAM,MAAM;AAAA,IAAA;AAAA,EAE9B;AAAA,EACA,kBAAkB;AAAA,IAChB,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO;AAAA,IACP,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,YAAY,MAAM,OAAO;AAAA,IACzB,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,cAAc;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAQ;AAAA,IAER,gBAAgB;AAAA,MACd,QAAQ;AAAA,MACR,OAAO;AAAA,MAEP,WAAW,EAAE,QAAQ,IAAI,OAAO,GAAG;AAAA,IAAA;AAAA,EACrC;AAEJ,CAAC;"}
@@ -16,7 +16,7 @@ const { staticClasses, useClasses } = createClasses("HvEmptyState", {
16
16
  },
17
17
  iconContainer: {},
18
18
  titleContainer: {
19
- marginTop: "4px",
19
+ marginTop: theme.space.xxs,
20
20
  marginBottom: theme.space.sm
21
21
  },
22
22
  textContainer: {
@@ -1 +1 @@
1
- {"version":3,"file":"EmptyState.styles.js","sources":["../../../src/EmptyState/EmptyState.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvEmptyState\", {\n root: {\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n },\n container: { display: \"flex\", flexDirection: \"row\" },\n containerMessageOnly: {\n alignItems: \"center\",\n \"& $textContainer\": {\n marginLeft: 0,\n },\n },\n iconContainer: {},\n titleContainer: {\n marginTop: \"4px\",\n marginBottom: theme.space.sm,\n },\n textContainer: {\n background: \"transparent\",\n maxWidth: \"510px\",\n overflow: \"hidden\",\n },\n messageContainer: {},\n actionContainer: { marginTop: theme.space.sm },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,gBAAgB;AAAA,EACzE,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,gBAAgB;AAAA,EAClB;AAAA,EACA,WAAW,EAAE,SAAS,QAAQ,eAAe,MAAM;AAAA,EACnD,sBAAsB;AAAA,IACpB,YAAY;AAAA,IACZ,oBAAoB;AAAA,MAClB,YAAY;AAAA,IAAA;AAAA,EAEhB;AAAA,EACA,eAAe,CAAC;AAAA,EAChB,gBAAgB;AAAA,IACd,WAAW;AAAA,IACX,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,eAAe;AAAA,IACb,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AAAA,EACA,kBAAkB,CAAC;AAAA,EACnB,iBAAiB,EAAE,WAAW,MAAM,MAAM,GAAG;AAC/C,CAAC;"}
1
+ {"version":3,"file":"EmptyState.styles.js","sources":["../../../src/EmptyState/EmptyState.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvEmptyState\", {\n root: {\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n },\n container: { display: \"flex\", flexDirection: \"row\" },\n containerMessageOnly: {\n alignItems: \"center\",\n \"& $textContainer\": {\n marginLeft: 0,\n },\n },\n iconContainer: {},\n titleContainer: {\n marginTop: theme.space.xxs,\n marginBottom: theme.space.sm,\n },\n textContainer: {\n background: \"transparent\",\n maxWidth: \"510px\",\n overflow: \"hidden\",\n },\n messageContainer: {},\n actionContainer: { marginTop: theme.space.sm },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,gBAAgB;AAAA,EACzE,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,gBAAgB;AAAA,EAClB;AAAA,EACA,WAAW,EAAE,SAAS,QAAQ,eAAe,MAAM;AAAA,EACnD,sBAAsB;AAAA,IACpB,YAAY;AAAA,IACZ,oBAAoB;AAAA,MAClB,YAAY;AAAA,IAAA;AAAA,EAEhB;AAAA,EACA,eAAe,CAAC;AAAA,EAChB,gBAAgB;AAAA,IACd,WAAW,MAAM,MAAM;AAAA,IACvB,cAAc,MAAM,MAAM;AAAA,EAC5B;AAAA,EACA,eAAe;AAAA,IACb,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AAAA,EACA,kBAAkB,CAAC;AAAA,EACnB,iBAAiB,EAAE,WAAW,MAAM,MAAM,GAAG;AAC/C,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Focus.js","sources":["../../../src/Focus/Focus.tsx"],"sourcesContent":["import { cloneElement, useState } from \"react\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { isBrowser } from \"../utils/browser\";\nimport { ConditionalWrapper } from \"../utils/ConditionalWrapper\";\nimport { isKey, isOneOfKeys } from \"../utils/keyboardUtils\";\nimport { staticClasses, useClasses } from \"./Focus.styles\";\nimport { getFocusableChildren, setFocusTo } from \"./utils\";\n\nexport { staticClasses as focusClasses };\nexport type HvFocusClasses = ExtractNames<typeof useClasses>;\n\nexport type HvFocusStrategies = \"listbox\" | \"menu\" | \"card\" | \"grid\";\n\nexport interface HvFocusProps extends HvBaseProps<HTMLElement, \"children\"> {\n children: React.ReactElement;\n /** Extra configuration for the child element. */\n configuration?: {\n tabIndex?: number;\n };\n /** Indicates that the disabled class should be applied. */\n disabledClass?: boolean;\n /** Whether the focus is selected. */\n selected?: boolean;\n /** Whether the focus is disabled. */\n disabled?: boolean;\n /** The reference to the root element to hold all Focus' context. */\n rootRef?: React.RefObject<HTMLElement>;\n /** Show focus when click element. v */\n focusOnClick?: boolean;\n /** Show focus when click element. v */\n focusDisabled?: boolean;\n /** Focus and navigation strategy to be used. v */\n strategy?: HvFocusStrategies;\n /** Uses an absolute positioned div as a focus. v */\n useFalseFocus?: boolean;\n /** Narrows the results of the focus to only theses class v */\n filterClass?: string;\n /** How much the navigation will skip when using the arrows. v */\n navigationJump?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFocusClasses;\n}\n\ninterface Focuses {\n first: Element;\n last: Element;\n previous: Element;\n next: Element;\n fall: Element;\n jump: Element;\n}\n\nexport const HvFocus = ({\n classes: classesProp,\n children,\n configuration = {},\n disabledClass = false,\n selected = false,\n disabled = false,\n rootRef = undefined,\n focusOnClick = false,\n focusDisabled = true,\n strategy = \"listbox\",\n useFalseFocus = false,\n filterClass,\n navigationJump = 4,\n}: HvFocusProps) => {\n const [showFocus, setShowFocus] = useState<boolean>(false);\n const [childFocus, setChildFocus] = useState<any>();\n const [hasRunConfig, setHasRunConfig] = useState(false);\n const { classes, cx } = useClasses(classesProp);\n\n const getFocuses = () => {\n const focuses = rootRef?.current\n ? Array.from(\n rootRef.current.getElementsByClassName(\n filterClass || staticClasses.root || \"root\",\n ),\n )\n : [];\n return focuses;\n };\n\n const setTabIndex = (el: any, tabIndex = 0) => {\n if (!el) return;\n const elChildFocus = getFocusableChildren(el)[0];\n if (elChildFocus) {\n el.tabIndex = -1;\n elChildFocus.tabIndex = tabIndex;\n } else {\n el.tabIndex = tabIndex;\n }\n };\n\n const setSelectedTabIndex = () => {\n const focuses = getFocuses();\n const firstSelected = focuses.find((focus) =>\n focus.classList.contains(classes.selected || \"selected\"),\n );\n\n if (!firstSelected) return;\n focuses.forEach((focus) => setTabIndex(focus, -1));\n setTabIndex(firstSelected, 0);\n };\n\n const clearTabSiblings = (el: any) => {\n getFocuses().forEach((focus) => setTabIndex(focus, -1));\n setTabIndex(el, 0);\n };\n\n const onFocusStrategy = (evt: any) => {\n if (strategy === \"listbox\") {\n clearTabSiblings(evt.currentTarget);\n }\n };\n\n const onBlurStrategy = () => {\n if (\n strategy === \"listbox\" &&\n rootRef &&\n rootRef.current &&\n !rootRef.current.contains(document.activeElement)\n ) {\n setTimeout(() => {\n setSelectedTabIndex();\n }, 10);\n }\n };\n\n const config = (el: any) => {\n const { tabIndex } = configuration;\n if (!el || hasRunConfig) return;\n if (strategy === \"card\") {\n setChildFocus(children);\n return;\n }\n\n if (strategy === \"grid\") {\n return;\n }\n\n const focusableChildren = getFocusableChildren(el);\n if (focusableChildren.length) {\n focusableChildren.forEach((child: any) => setTabIndex(child, -1));\n setChildFocus(focusableChildren[0]);\n }\n\n if (tabIndex != null) setTabIndex(el, tabIndex);\n setHasRunConfig(true);\n };\n\n const addFocusClass = (evt: any) => {\n if (!useFalseFocus) {\n // evt.currentTarget.classList.add(classes.focused);\n classes.focused\n .split(\" \")\n .forEach((c) => evt.currentTarget.classList.add(c));\n // add global class HvIsFocused as a marker\n // not to be styled directly, only as helper in specific css queries\n evt.currentTarget.classList.add(\"HvIsFocused\");\n classes?.focus\n ?.split(\" \")\n .forEach((c) => evt.currentTarget.classList.add(c));\n }\n };\n\n const removeFocusClass = () => {\n if (!useFalseFocus) {\n getFocuses().forEach((element) => {\n // element.classList.remove(classes.focused);\n classes.focused.split(\" \").forEach((c) => element.classList.remove(c));\n // remove the global class HvIsFocused\n element.classList.remove(\"HvIsFocused\");\n classes?.focus?.split(\" \").forEach((c) => element.classList.remove(c));\n });\n }\n };\n\n const onFocus = (evt: any) => {\n addFocusClass(evt);\n setShowFocus(true);\n // give focus to child element if any focusable\n\n childFocus?.focus?.();\n onFocusStrategy(evt);\n };\n\n const onBlur = () => {\n setShowFocus(false);\n removeFocusClass();\n onBlurStrategy();\n };\n\n const onMouseDown = (evt: any) => {\n const hasCard = !!evt.currentTarget?.querySelector(\".HvIsCardGridElement\");\n if (strategy === \"grid\" && hasCard) return;\n\n setFocusTo(evt.currentTarget);\n setTabIndex(evt.currentTarget, 0);\n // remove focus outline unless explicitly enabled\n if (!focusOnClick) {\n // TODO this piece of code works only because onMouseDown is happening after the focus event\n // There is nothing in here that guarantees the order of these events, so it may present a problem in the future\n removeFocusClass();\n setShowFocus(false);\n }\n };\n\n const focusAndUpdateIndex = (\n nextFocus: Element,\n previousFocus: any,\n focusesList: Element[],\n ) => {\n if (focusesList?.includes(previousFocus)) {\n setTabIndex(previousFocus, -1);\n }\n setTabIndex(nextFocus, 0);\n setFocusTo(nextFocus);\n };\n\n const getEnabledKeys = (\n currentFocusIndex: number,\n jump: number,\n listSize: number,\n ) => ({\n right:\n (currentFocusIndex + 1) % jump === 0 ||\n currentFocusIndex + 1 > listSize - 1,\n left: currentFocusIndex % jump === 0,\n up: currentFocusIndex - jump < 0,\n down:\n currentFocusIndex + jump > listSize ||\n currentFocusIndex + jump > listSize - 1,\n });\n\n const onGridKeyDownHandler = (\n evt: any,\n focuses: Focuses,\n focusesList: Element[],\n currentFocusIndex: number,\n jump: number,\n ) => {\n const childFocusIsInput = childFocus && childFocus.nodeName === \"INPUT\";\n\n if (\n !isOneOfKeys(evt, [\n \"ArrowUp\",\n \"ArrowDown\",\n \"ArrowLeft\",\n \"ArrowRight\",\n \"Home\",\n \"End\",\n \"Space\",\n \"Enter\",\n ]) ||\n (childFocusIsInput && isKey(evt, \"Enter\"))\n ) {\n // nothing to do\n return;\n }\n\n // we'll do something with the key so prevent default and stop propagation\n // except for Enter and SpaceBar\n if (!isOneOfKeys(evt, [\"Enter\", \"Space\"])) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n\n const blockedKeys = getEnabledKeys(\n currentFocusIndex,\n jump,\n focusesList.length,\n );\n\n switch (evt.code) {\n case \"Space\":\n case \"Enter\":\n if (isBrowser(\"firefox\")) {\n evt.target.click();\n } else {\n evt.currentTarget.click();\n }\n break;\n case \"ArrowUp\":\n if (!blockedKeys.up) {\n focusAndUpdateIndex(\n focuses.jump || focuses.last,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"ArrowDown\":\n if (!blockedKeys.down) {\n focusAndUpdateIndex(\n focuses.fall || focuses.first,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"ArrowLeft\":\n if (!blockedKeys.left) {\n focusAndUpdateIndex(\n focuses.previous || focuses.last,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"ArrowRight\":\n if (!blockedKeys.right) {\n focusAndUpdateIndex(\n focuses.next || focuses.first,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"Home\":\n focusAndUpdateIndex(focuses.first, evt.current, focusesList);\n break;\n case \"End\":\n focusAndUpdateIndex(focuses.last, evt.current, focusesList);\n break;\n default:\n }\n };\n\n const onVerticalArrangementHandler = (\n evt: any,\n focuses: Focuses,\n focusesList: Element[],\n ) => {\n const childFocusIsInput = childFocus && childFocus.nodeName === \"INPUT\";\n\n if (\n !isOneOfKeys(evt, [\n \"ArrowUp\",\n \"ArrowDown\",\n \"Home\",\n \"End\",\n \"Space\",\n \"Enter\",\n ]) ||\n (childFocusIsInput && isKey(evt, \"Enter\"))\n ) {\n // nothing to do\n return;\n }\n\n // we'll do something with the key so prevent default and stop propagation\n evt.preventDefault();\n evt.stopPropagation();\n\n switch (evt.code) {\n case \"Space\":\n case \"Enter\":\n evt.target.click();\n break;\n case \"ArrowUp\":\n focusAndUpdateIndex(\n focuses.previous || focuses.last,\n evt.current,\n focusesList,\n );\n break;\n case \"ArrowDown\":\n focusAndUpdateIndex(\n focuses.next || focuses.first,\n evt.current,\n focusesList,\n );\n break;\n case \"Home\":\n focusAndUpdateIndex(focuses.first, evt.current, focusesList);\n break;\n case \"End\":\n focusAndUpdateIndex(focuses.last, evt.current, focusesList);\n break;\n default:\n }\n };\n\n const onSingleHandler = (evt: any) => {\n const childFocusIsInput = childFocus && childFocus.nodeName === \"INPUT\";\n\n if (\n !isOneOfKeys(evt, [\"Space\", \"Enter\"]) ||\n (childFocusIsInput && isKey(evt, \"Enter\"))\n ) {\n // nothing to do\n return;\n }\n\n // we'll do something with the key so prevent default and stop propagation\n evt.preventDefault();\n evt.stopPropagation();\n\n evt.currentTarget.click();\n };\n\n const onKeyDown = (evt: any) => {\n if (rootRef?.current == null) {\n // operating outside of a composite widget\n // nothing to manage, just style and trigger clicks\n onSingleHandler(evt);\n return;\n }\n\n // TODO keep the smart default, but allow to explicitly override if disabled elements should be focusable\n const isDisabledFocusable = strategy === \"menu\";\n const focusesList = getFocuses().filter(\n (el) =>\n isDisabledFocusable ||\n !el.classList.contains(classes?.disabled as string),\n );\n\n const currentFocus = focusesList.indexOf(evt.currentTarget);\n\n const focuses: Focuses = {\n first: focusesList[0],\n last: focusesList[focusesList.length - 1],\n previous: focusesList[currentFocus - 1],\n next: focusesList[currentFocus + 1],\n fall: focusesList[currentFocus + navigationJump],\n jump: focusesList[currentFocus - navigationJump],\n };\n\n if (strategy === \"grid\") {\n onGridKeyDownHandler(\n evt,\n focuses,\n focusesList,\n currentFocus,\n navigationJump,\n );\n return;\n }\n\n // TODO add property for specifying the composite widget orientation\n // TODO implement handler for horizontal orientation\n onVerticalArrangementHandler(evt, focuses, focusesList);\n };\n\n const onKeyUp = (evt: any) => {\n if (isBrowser(\"firefox\")) evt.preventDefault();\n };\n\n if (disabled) return children;\n\n const focusWrapper = (childrenToWrap: React.ReactNode) => (\n <div className={classes.externalReference}>\n {childrenToWrap}\n {showFocus && <div className={classes.falseFocus} />}\n </div>\n );\n\n return (\n <ConditionalWrapper condition={useFalseFocus} wrapper={focusWrapper}>\n {cloneElement(children, {\n className: cx(\n [classes.root, filterClass],\n {\n [classes.selected]: selected,\n [classes.disabled]: disabledClass,\n [classes.focusDisabled]: focusDisabled,\n },\n children.props.className,\n ),\n ref: config,\n onFocus,\n onBlur,\n onMouseDown,\n onKeyDown,\n onKeyUp,\n selected,\n })}\n </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e,YAAY,QAAQ,IAAI,aAAa;AAE1D,UAAM,UAAmB;AAAA,MACvB,OAAO,YAAY,CAAC;AAAA,MACpB,MAAM,YAAY,YAAY,SAAS,CAAC;AAAA,MACxC,UAAU,YAAY,eAAe,CAAC;AAAA,MACtC,MAAM,YAAY,eAAe,CAAC;AAAA,MAClC,MAAM,YAAY,eAAe,cAAc;AAAA,MAC/C,MAAM,YAAY,eAAe,cAAc;AAAA,IACjD;AAEA,QAAI,aAAa,QAAQ;AACvB;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA;AAAA,IAAA;AAK2B,iCAAA,KAAK,SAAS,WAAW;AAAA,EACxD;AAEM,QAAA,UAAU,CAAC,QAAa;AAC5B,QAAI,UAAU,SAAS,EAAG,KAAI,eAAe;AAAA,EAC/C;AAEA,MAAI,SAAiB,QAAA;AAErB,QAAM,eAAe,CAAC,wCACnB,OAAI,EAAA,WAAW,QAAQ,mBACrB,UAAA;AAAA,IAAA;AAAA,IACA,aAAa,oBAAC,OAAI,EAAA,WAAW,QAAQ,WAAY,CAAA;AAAA,EAAA,GACpD;AAGF,6BACG,oBAAmB,EAAA,WAAW,eAAe,SAAS,cACpD,uBAAa,UAAU;AAAA,IACtB,WAAW;AAAA,MACT,CAAC,QAAQ,MAAM,WAAW;AAAA,MAC1B;AAAA,QACE,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACpB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACpB,CAAC,QAAQ,aAAa,GAAG;AAAA,MAC3B;AAAA,MACA,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAA,GACH;AAEJ;"}
1
+ {"version":3,"file":"Focus.js","sources":["../../../src/Focus/Focus.tsx"],"sourcesContent":["import { cloneElement, useState } from \"react\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { isBrowser } from \"../utils/browser\";\nimport { ConditionalWrapper } from \"../utils/ConditionalWrapper\";\nimport { isKey, isOneOfKeys } from \"../utils/keyboardUtils\";\nimport { staticClasses, useClasses } from \"./Focus.styles\";\nimport { getFocusableChildren, setFocusTo } from \"./utils\";\n\nexport { staticClasses as focusClasses };\nexport type HvFocusClasses = ExtractNames<typeof useClasses>;\n\nexport type HvFocusStrategies = \"listbox\" | \"menu\" | \"card\" | \"grid\";\n\nexport interface HvFocusProps extends HvBaseProps<HTMLElement, \"children\"> {\n children: React.ReactElement;\n /** Extra configuration for the child element. */\n configuration?: {\n tabIndex?: number;\n };\n /** Indicates that the disabled class should be applied. */\n disabledClass?: boolean;\n /** Whether the focus is selected. */\n selected?: boolean;\n /** Whether the focus is disabled. */\n disabled?: boolean;\n /** The reference to the root element to hold all Focus' context. */\n rootRef?: React.RefObject<HTMLElement>;\n /** Show focus when click element. v */\n focusOnClick?: boolean;\n /** Show focus when click element. v */\n focusDisabled?: boolean;\n /** Focus and navigation strategy to be used. v */\n strategy?: HvFocusStrategies;\n /** Uses an absolute positioned div as a focus. v */\n useFalseFocus?: boolean;\n /** Narrows the results of the focus to only theses class v */\n filterClass?: string;\n /** How much the navigation will skip when using the arrows. v */\n navigationJump?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFocusClasses;\n}\n\ninterface Focuses {\n first: Element;\n last: Element;\n previous: Element;\n next: Element;\n fall: Element;\n jump: Element;\n}\n\n/** @deprecated internal use only. this component has navigation issues. */\nexport const HvFocus = ({\n classes: classesProp,\n children,\n configuration = {},\n disabledClass = false,\n selected = false,\n disabled = false,\n rootRef = undefined,\n focusOnClick = false,\n focusDisabled = true,\n strategy = \"listbox\",\n useFalseFocus = false,\n filterClass,\n navigationJump = 4,\n}: HvFocusProps) => {\n const [showFocus, setShowFocus] = useState<boolean>(false);\n const [childFocus, setChildFocus] = useState<any>();\n const [hasRunConfig, setHasRunConfig] = useState(false);\n const { classes, cx } = useClasses(classesProp);\n\n const getFocuses = () => {\n const focuses = rootRef?.current\n ? Array.from(\n rootRef.current.getElementsByClassName(\n filterClass || staticClasses.root || \"root\",\n ),\n )\n : [];\n return focuses;\n };\n\n const setTabIndex = (el: any, tabIndex = 0) => {\n if (!el) return;\n const elChildFocus = getFocusableChildren(el)[0];\n if (elChildFocus) {\n el.tabIndex = -1;\n elChildFocus.tabIndex = tabIndex;\n } else {\n el.tabIndex = tabIndex;\n }\n };\n\n const setSelectedTabIndex = () => {\n const focuses = getFocuses();\n const firstSelected = focuses.find((focus) =>\n focus.classList.contains(classes.selected || \"selected\"),\n );\n\n if (!firstSelected) return;\n focuses.forEach((focus) => setTabIndex(focus, -1));\n setTabIndex(firstSelected, 0);\n };\n\n const clearTabSiblings = (el: any) => {\n getFocuses().forEach((focus) => setTabIndex(focus, -1));\n setTabIndex(el, 0);\n };\n\n const onFocusStrategy = (evt: any) => {\n if (strategy === \"listbox\") {\n clearTabSiblings(evt.currentTarget);\n }\n };\n\n const onBlurStrategy = () => {\n if (\n strategy === \"listbox\" &&\n rootRef &&\n rootRef.current &&\n !rootRef.current.contains(document.activeElement)\n ) {\n setTimeout(() => {\n setSelectedTabIndex();\n }, 10);\n }\n };\n\n const config = (el: any) => {\n const { tabIndex } = configuration;\n if (!el || hasRunConfig) return;\n if (strategy === \"card\") {\n setChildFocus(children);\n return;\n }\n\n if (strategy === \"grid\") {\n return;\n }\n\n const focusableChildren = getFocusableChildren(el);\n if (focusableChildren.length) {\n focusableChildren.forEach((child: any) => setTabIndex(child, -1));\n setChildFocus(focusableChildren[0]);\n }\n\n if (tabIndex != null) setTabIndex(el, tabIndex);\n setHasRunConfig(true);\n };\n\n const addFocusClass = (evt: any) => {\n if (!useFalseFocus) {\n // evt.currentTarget.classList.add(classes.focused);\n classes.focused\n .split(\" \")\n .forEach((c) => evt.currentTarget.classList.add(c));\n // add global class HvIsFocused as a marker\n // not to be styled directly, only as helper in specific css queries\n evt.currentTarget.classList.add(\"HvIsFocused\");\n classes?.focus\n ?.split(\" \")\n .forEach((c) => evt.currentTarget.classList.add(c));\n }\n };\n\n const removeFocusClass = () => {\n if (!useFalseFocus) {\n getFocuses().forEach((element) => {\n // element.classList.remove(classes.focused);\n classes.focused.split(\" \").forEach((c) => element.classList.remove(c));\n // remove the global class HvIsFocused\n element.classList.remove(\"HvIsFocused\");\n classes?.focus?.split(\" \").forEach((c) => element.classList.remove(c));\n });\n }\n };\n\n const onFocus = (evt: any) => {\n addFocusClass(evt);\n setShowFocus(true);\n // give focus to child element if any focusable\n\n childFocus?.focus?.();\n onFocusStrategy(evt);\n };\n\n const onBlur = () => {\n setShowFocus(false);\n removeFocusClass();\n onBlurStrategy();\n };\n\n const onMouseDown = (evt: any) => {\n const hasCard = !!evt.currentTarget?.querySelector(\".HvIsCardGridElement\");\n if (strategy === \"grid\" && hasCard) return;\n\n setFocusTo(evt.currentTarget);\n setTabIndex(evt.currentTarget, 0);\n // remove focus outline unless explicitly enabled\n if (!focusOnClick) {\n // TODO this piece of code works only because onMouseDown is happening after the focus event\n // There is nothing in here that guarantees the order of these events, so it may present a problem in the future\n removeFocusClass();\n setShowFocus(false);\n }\n };\n\n const focusAndUpdateIndex = (\n nextFocus: Element,\n previousFocus: any,\n focusesList: Element[],\n ) => {\n if (focusesList?.includes(previousFocus)) {\n setTabIndex(previousFocus, -1);\n }\n setTabIndex(nextFocus, 0);\n setFocusTo(nextFocus);\n };\n\n const getEnabledKeys = (\n currentFocusIndex: number,\n jump: number,\n listSize: number,\n ) => ({\n right:\n (currentFocusIndex + 1) % jump === 0 ||\n currentFocusIndex + 1 > listSize - 1,\n left: currentFocusIndex % jump === 0,\n up: currentFocusIndex - jump < 0,\n down:\n currentFocusIndex + jump > listSize ||\n currentFocusIndex + jump > listSize - 1,\n });\n\n const onGridKeyDownHandler = (\n evt: any,\n focuses: Focuses,\n focusesList: Element[],\n currentFocusIndex: number,\n jump: number,\n ) => {\n const childFocusIsInput = childFocus && childFocus.nodeName === \"INPUT\";\n\n if (\n !isOneOfKeys(evt, [\n \"ArrowUp\",\n \"ArrowDown\",\n \"ArrowLeft\",\n \"ArrowRight\",\n \"Home\",\n \"End\",\n \"Space\",\n \"Enter\",\n ]) ||\n (childFocusIsInput && isKey(evt, \"Enter\"))\n ) {\n // nothing to do\n return;\n }\n\n // we'll do something with the key so prevent default and stop propagation\n // except for Enter and SpaceBar\n if (!isOneOfKeys(evt, [\"Enter\", \"Space\"])) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n\n const blockedKeys = getEnabledKeys(\n currentFocusIndex,\n jump,\n focusesList.length,\n );\n\n switch (evt.code) {\n case \"Space\":\n case \"Enter\":\n if (isBrowser(\"firefox\")) {\n evt.target.click();\n } else {\n evt.currentTarget.click();\n }\n break;\n case \"ArrowUp\":\n if (!blockedKeys.up) {\n focusAndUpdateIndex(\n focuses.jump || focuses.last,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"ArrowDown\":\n if (!blockedKeys.down) {\n focusAndUpdateIndex(\n focuses.fall || focuses.first,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"ArrowLeft\":\n if (!blockedKeys.left) {\n focusAndUpdateIndex(\n focuses.previous || focuses.last,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"ArrowRight\":\n if (!blockedKeys.right) {\n focusAndUpdateIndex(\n focuses.next || focuses.first,\n evt.current,\n focusesList,\n );\n }\n break;\n case \"Home\":\n focusAndUpdateIndex(focuses.first, evt.current, focusesList);\n break;\n case \"End\":\n focusAndUpdateIndex(focuses.last, evt.current, focusesList);\n break;\n default:\n }\n };\n\n const onVerticalArrangementHandler = (\n evt: any,\n focuses: Focuses,\n focusesList: Element[],\n ) => {\n const childFocusIsInput = childFocus && childFocus.nodeName === \"INPUT\";\n\n if (\n !isOneOfKeys(evt, [\n \"ArrowUp\",\n \"ArrowDown\",\n \"Home\",\n \"End\",\n \"Space\",\n \"Enter\",\n ]) ||\n (childFocusIsInput && isKey(evt, \"Enter\"))\n ) {\n // nothing to do\n return;\n }\n\n // we'll do something with the key so prevent default and stop propagation\n evt.preventDefault();\n evt.stopPropagation();\n\n switch (evt.code) {\n case \"Space\":\n case \"Enter\":\n evt.target.click();\n break;\n case \"ArrowUp\":\n focusAndUpdateIndex(\n focuses.previous || focuses.last,\n evt.current,\n focusesList,\n );\n break;\n case \"ArrowDown\":\n focusAndUpdateIndex(\n focuses.next || focuses.first,\n evt.current,\n focusesList,\n );\n break;\n case \"Home\":\n focusAndUpdateIndex(focuses.first, evt.current, focusesList);\n break;\n case \"End\":\n focusAndUpdateIndex(focuses.last, evt.current, focusesList);\n break;\n default:\n }\n };\n\n const onSingleHandler = (evt: any) => {\n const childFocusIsInput = childFocus && childFocus.nodeName === \"INPUT\";\n\n if (\n !isOneOfKeys(evt, [\"Space\", \"Enter\"]) ||\n (childFocusIsInput && isKey(evt, \"Enter\"))\n ) {\n // nothing to do\n return;\n }\n\n // we'll do something with the key so prevent default and stop propagation\n evt.preventDefault();\n evt.stopPropagation();\n\n evt.currentTarget.click();\n };\n\n const onKeyDown = (evt: any) => {\n if (rootRef?.current == null) {\n // operating outside of a composite widget\n // nothing to manage, just style and trigger clicks\n onSingleHandler(evt);\n return;\n }\n\n // TODO keep the smart default, but allow to explicitly override if disabled elements should be focusable\n const isDisabledFocusable = strategy === \"menu\";\n const focusesList = getFocuses().filter(\n (el) =>\n isDisabledFocusable ||\n !el.classList.contains(classes?.disabled as string),\n );\n\n const currentFocus = focusesList.indexOf(evt.currentTarget);\n\n const focuses: Focuses = {\n first: focusesList[0],\n last: focusesList[focusesList.length - 1],\n previous: focusesList[currentFocus - 1],\n next: focusesList[currentFocus + 1],\n fall: focusesList[currentFocus + navigationJump],\n jump: focusesList[currentFocus - navigationJump],\n };\n\n if (strategy === \"grid\") {\n onGridKeyDownHandler(\n evt,\n focuses,\n focusesList,\n currentFocus,\n navigationJump,\n );\n return;\n }\n\n // TODO add property for specifying the composite widget orientation\n // TODO implement handler for horizontal orientation\n onVerticalArrangementHandler(evt, focuses, focusesList);\n };\n\n const onKeyUp = (evt: any) => {\n if (isBrowser(\"firefox\")) evt.preventDefault();\n };\n\n if (disabled) return children;\n\n const focusWrapper = (childrenToWrap: React.ReactNode) => (\n <div className={classes.externalReference}>\n {childrenToWrap}\n {showFocus && <div className={classes.falseFocus} />}\n </div>\n );\n\n return (\n <ConditionalWrapper condition={useFalseFocus} wrapper={focusWrapper}>\n {cloneElement(children, {\n className: cx(\n [classes.root, filterClass],\n {\n [classes.selected]: selected,\n [classes.disabled]: disabledClass,\n [classes.focusDisabled]: focusDisabled,\n },\n children.props.className,\n ),\n ref: config,\n onFocus,\n onBlur,\n onMouseDown,\n onKeyDown,\n onKeyUp,\n selected,\n })}\n </ConditionalWrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuDO,MAAM,UAAU,CAAC;AAAA,EACtB,SAAS;AAAA,EACT;AAAA,EACA,gBAAgB,CAAC;AAAA,EACjB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB;AAAA,EACA,iBAAiB;AACnB,MAAoB;AAClB,QAAM,CAAC,WAAW,YAAY,IAAI,SAAkB,KAAK;AACzD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAc;AAClD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AACtD,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAE9C,QAAM,aAAa,MAAM;AACjB,UAAA,UAAU,SAAS,UACrB,MAAM;AAAA,MACJ,QAAQ,QAAQ;AAAA,QACd,eAAe,cAAc,QAAQ;AAAA,MAAA;AAAA,IACvC,IAEF,CAAC;AACE,WAAA;AAAA,EACT;AAEA,QAAM,cAAc,CAAC,IAAS,WAAW,MAAM;AAC7C,QAAI,CAAC,GAAI;AACT,UAAM,eAAe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ACpD,uBAAa,UAAU;AAAA,IACtB,WAAW;AAAA,MACT,CAAC,QAAQ,MAAM,WAAW;AAAA,MAC1B;AAAA,QACE,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACpB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACpB,CAAC,QAAQ,aAAa,GAAG;AAAA,MAC3B;AAAA,MACA,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAA,GACH;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.js","sources":["../../../src/Grid/Grid.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport MuiGrid, { GridProps as MuiGridProps } from \"@mui/material/Grid\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { useWidth } from \"../hooks/useWidth\";\nimport { staticClasses, useClasses } from \"./Grid.styles\";\n\nexport { staticClasses as gridClasses };\n\nexport type HvGridClasses = ExtractNames<typeof useClasses>;\n\nconst BREAKPOINT_GUTTERS = {\n xs: 2,\n sm: 2,\n md: 4,\n lg: 4,\n xl: 4,\n};\n\nconst BREAKPOINT_COLUMNS = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 12,\n xl: 12,\n};\n\nexport type HvGridDirection =\n | \"row\"\n | \"row-reverse\"\n | \"column\"\n | \"column-reverse\";\n\nexport type HvGridSpacing =\n | \"xs\"\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"xl\"\n | \"auto\"\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 7\n | 8\n | 9\n | 10;\n\nexport interface HvGridProps extends Omit<MuiGridProps, \"classes\" | \"columns\"> {\n /**\n * If `true`, the component will have the flex *container* behavior.\n * You should be wrapping *items* with a *container*.\n */\n container?: boolean;\n /**\n * If `true`, the component will have the flex *item* behavior.\n * You should be wrapping *items* with a *container*.\n */\n item?: boolean;\n /**\n * Defines the space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n */\n spacing?: HvGridSpacing | number;\n /**\n * Defines the vertical space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n rowSpacing?: HvGridSpacing | number;\n /**\n * Defines the horizontal space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n columnSpacing?: HvGridSpacing | number;\n /**\n * The number of columns.\n * Defaults to a 12-column grid.\n * The value \"auto\" implements the Design System directives in terms of variable number of columns.\n * @default 12\n */\n columns?: \"auto\" | MuiGridProps[\"columns\"];\n /**\n * Defines the `flex-direction` style property.\n * It is applied for all screen sizes.\n */\n direction?: HvGridDirection;\n /**\n * Defines the `justify-content` style property.\n * It is applied for all screen sizes.\n */\n justify?:\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for all the screen sizes with the lowest priority.\n */\n xs?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `sm` breakpoint and wider screens if not overridden.\n */\n sm?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `md` breakpoint and wider screens if not overridden.\n */\n md?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `lg` breakpoint and wider screens if not overridden.\n */\n lg?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `xl` breakpoint and wider screens.\n */\n xl?: number | boolean;\n /**\n * Defines the `flex-wrap` style property.\n * It's applied for all screen sizes.\n */\n wrap?: \"nowrap\" | \"wrap\" | \"wrap-reverse\";\n /**\n * If `true`, it sets `min-width: 0` on the item.\n * Refer to the limitations section of the documentation to better understand the use case.\n */\n zeroMinWidth?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvGridClasses;\n}\n\nfunction getGridSpacing(spacing: HvGridProps[\"spacing\"]) {\n let gridSpacing: MuiGridProps[\"spacing\"];\n\n if (typeof spacing === \"string\") {\n if (spacing === \"auto\") {\n gridSpacing = BREAKPOINT_GUTTERS;\n } else {\n gridSpacing = BREAKPOINT_GUTTERS[spacing];\n }\n } else if (typeof spacing === \"object\") {\n gridSpacing = Object.keys(spacing).reduce<Record<string, number>>(\n (acc, bp) => {\n acc[bp] = BREAKPOINT_GUTTERS[spacing[bp]] ?? spacing[bp];\n return acc;\n },\n {},\n );\n } else if (spacing === 0) {\n gridSpacing = { xs: 0 };\n } else {\n gridSpacing = spacing;\n }\n\n return gridSpacing;\n}\n\nfunction getNumberOfColumns(columns: HvGridProps[\"columns\"]) {\n let numberOfColumns: MuiGridProps[\"columns\"];\n\n if (columns === \"auto\") {\n numberOfColumns = BREAKPOINT_COLUMNS;\n } else {\n numberOfColumns = columns;\n }\n\n return numberOfColumns;\n}\n\nfunction getContainerProps(\n spacing: HvGridProps[\"spacing\"],\n rowSpacing: HvGridProps[\"rowSpacing\"],\n columnSpacing: HvGridProps[\"columnSpacing\"],\n columns: HvGridProps[\"columns\"],\n) {\n const containerProps: Pick<\n MuiGridProps,\n \"container\" | \"spacing\" | \"rowSpacing\" | \"columnSpacing\" | \"columns\"\n > = { container: true };\n\n if (spacing != null) {\n containerProps.spacing = getGridSpacing(spacing);\n }\n if (rowSpacing != null) {\n containerProps.rowSpacing = getGridSpacing(rowSpacing);\n }\n if (columnSpacing != null) {\n containerProps.columnSpacing = getGridSpacing(columnSpacing);\n }\n if (columns != null) {\n containerProps.columns = getNumberOfColumns(columns);\n }\n\n return containerProps;\n}\n\nconst WidthGrid = forwardRef<\n // no-indent\n HTMLDivElement,\n HvGridProps\n>(function WidthGrid(props, ref) {\n const { container, spacing, rowSpacing, columnSpacing, columns, ...others } =\n props;\n\n const width = useWidth();\n\n const containerProps = container\n ? getContainerProps(\n spacing === \"auto\" ? width : spacing,\n rowSpacing === \"auto\" ? width : rowSpacing,\n columnSpacing === \"auto\" ? width : columnSpacing,\n columns,\n )\n : {};\n\n return <MuiGrid ref={ref} {...containerProps} {...others} />;\n});\n\n/**\n * The grid creates visual consistency between layouts while allowing flexibility\n * across a wide variety of designs. This component is based on a 12-column grid layout.\n *\n * It's based on the [Material UI Grid](https://mui.com/material-ui/react-grid/).\n *\n * The definitions were set following the Design System directives:\n *\n * | Breakpoint | Width (in px) | Gutters (in px) | Number of columns |\n * | ---------- | ------------- | --------------- | ----------------- |\n * | xs | [0-600[ | 16 | 4 |\n * | sm | [600-960[ | 16 | 8 |\n * | md | [960-1270[ | 32 | 12 |\n * | lg | [1270-1920[ | 32 | 12 |\n * | xl | [1920-...[ | 32 | 12 |\n *\n * However, the number of columns is set to 12 for all breakpoints, as it serves most\n * of the use cases and simplifies the implementation.\n * To opt-in to the Design System directives, you can set the `columns` prop to `auto`.\n *\n * Also, the Design System specifications are omissive about the horizontal gutters.\n * The HvGrid sets them to the same value as the vertical gutters, depending on the breakpoint.\n * It can be overridden by setting the `rowSpacing` prop.\n */\nexport const HvGrid = forwardRef<\n // no-indent\n HTMLDivElement,\n HvGridProps\n>(function HvGrid(props, ref) {\n const {\n item,\n container,\n spacing = \"auto\",\n rowSpacing,\n columnSpacing,\n columns,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvGrid\", props);\n\n const { classes } = useClasses(classesProp);\n\n // Fixes MUI error when using spacings as objects and the grid is an item and container\n // When set to \"auto\", the spacing changes depending on the screen's breakpoint\n // The condition avoids using useWidth and re-rendering the component unnecessarily\n if (\n container &&\n item &&\n (spacing === \"auto\" || rowSpacing === \"auto\" || columnSpacing === \"auto\")\n ) {\n return (\n <WidthGrid\n ref={ref}\n classes={classes}\n item={item}\n container={container}\n spacing={spacing}\n rowSpacing={rowSpacing}\n columnSpacing={columnSpacing}\n columns={columns}\n {...others}\n />\n );\n }\n\n const containerProps = container\n ? getContainerProps(spacing, rowSpacing, columnSpacing, columns)\n : {};\n\n return (\n <MuiGrid\n ref={ref}\n classes={classes}\n item={item}\n {...containerProps}\n {...others}\n />\n );\n});\n"],"names":["WidthGrid","HvGrid"],"mappings":";;;;;;;AAcA,MAAM,qBAAqB;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,qBAAqB;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAuHA,SAAS,eAAe,SAAiC;AACnD,MAAA;AAEA,MAAA,OAAO,YAAY,UAAU;AAC/B,QAAI,YAAY,QAAQ;AACR,oBAAA;AAAA,IAAA,OACT;AACL,oBAAc,mBAAmB,OAAO;AAAA,IAAA;AAAA,EAC1C,WACS,OAAO,YAAY,UAAU;AACxB,kBAAA,OAAO,KAAK,OAAO,EAAE;AAAA,MACjC,CAAC,KAAK,OAAO;AACP,YAAA,EAAE,IAAI,mBAAmB,QAAQ,EAAE,CAAC,KAAK,QAAQ,EAAE;AAChD,eAAA;AAAA,MACT;AAAA,MACA,CAAA;AAAA,IACF;AAAA,EAAA,WACS,YAAY,GAAG;AACV,kBAAA,EAAE,IAAI,EAAE;AAAA,EAAA,OACjB;AACS,kBAAA;AAAA,EAAA;AAGT,SAAA;AACT;AAEA,SAAS,mBAAmB,SAAiC;AACvD,MAAA;AAEJ,MAAI,YAAY,QAAQ;AACJ,sBAAA;AAAA,EAAA,OACb;AACa,sBAAA;AAAA,EAAA;AAGb,SAAA;AACT;AAEA,SAAS,kBACP,SACA,YACA,eACA,SACA;AACM,QAAA,iBAGF,EAAE,WAAW,KAAK;AAEtB,MAAI,WAAW,MAAM;AACJ,mBAAA,UAAU,eAAe,OA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,MACA;AAAA,MACC,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ,CAAC;"}
1
+ {"version":3,"file":"Grid.js","sources":["../../../src/Grid/Grid.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport MuiGrid, { GridProps as MuiGridProps } from \"@mui/material/Grid\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { useWidth } from \"../hooks/useWidth\";\nimport { staticClasses, useClasses } from \"./Grid.styles\";\n\nexport { staticClasses as gridClasses };\n\nexport type HvGridClasses = ExtractNames<typeof useClasses>;\n\nconst BREAKPOINT_GUTTERS = {\n xs: 2,\n sm: 2,\n md: 4,\n lg: 4,\n xl: 4,\n};\n\nconst BREAKPOINT_COLUMNS = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 12,\n xl: 12,\n};\n\nexport type HvGridDirection =\n | \"row\"\n | \"row-reverse\"\n | \"column\"\n | \"column-reverse\";\n\nexport type HvGridSpacing =\n | \"xs\"\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"xl\"\n | \"auto\"\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 7\n | 8\n | 9\n | 10;\n\nexport interface HvGridProps extends Omit<MuiGridProps, \"classes\" | \"columns\"> {\n /**\n * If `true`, the component will have the flex *container* behavior.\n * You should be wrapping *items* with a *container*.\n */\n container?: boolean;\n /**\n * If `true`, the component will have the flex *item* behavior.\n * You should be wrapping *items* with a *container*.\n */\n item?: boolean;\n /**\n * Defines the space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n */\n spacing?: HvGridSpacing | number;\n /**\n * Defines the vertical space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n rowSpacing?: HvGridSpacing | number;\n /**\n * Defines the horizontal space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n columnSpacing?: HvGridSpacing | number;\n /**\n * The number of columns.\n * Defaults to a 12-column grid.\n * The value \"auto\" implements the Design System directives in terms of variable number of columns.\n * @default 12\n */\n columns?: \"auto\" | MuiGridProps[\"columns\"];\n /**\n * Defines the `flex-direction` style property.\n * It is applied for all screen sizes.\n */\n direction?: HvGridDirection;\n /**\n * Defines the `justify-content` style property.\n * It is applied for all screen sizes.\n */\n justify?:\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for all the screen sizes with the lowest priority.\n */\n xs?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `sm` breakpoint and wider screens if not overridden.\n */\n sm?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `md` breakpoint and wider screens if not overridden.\n */\n md?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `lg` breakpoint and wider screens if not overridden.\n */\n lg?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `xl` breakpoint and wider screens.\n */\n xl?: number | boolean;\n /**\n * Defines the `flex-wrap` style property.\n * It's applied for all screen sizes.\n */\n wrap?: \"nowrap\" | \"wrap\" | \"wrap-reverse\";\n /**\n * If `true`, it sets `min-width: 0` on the item.\n * Refer to the limitations section of the documentation to better understand the use case.\n */\n zeroMinWidth?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvGridClasses;\n}\n\nfunction getGridSpacing(spacing: HvGridProps[\"spacing\"]) {\n let gridSpacing: MuiGridProps[\"spacing\"];\n\n if (typeof spacing === \"string\") {\n if (spacing === \"auto\") {\n gridSpacing = BREAKPOINT_GUTTERS;\n } else {\n gridSpacing = BREAKPOINT_GUTTERS[spacing];\n }\n } else if (typeof spacing === \"object\") {\n gridSpacing = Object.keys(spacing).reduce<Record<string, number>>(\n (acc, bp) => {\n acc[bp] = BREAKPOINT_GUTTERS[spacing[bp]] ?? spacing[bp];\n return acc;\n },\n {},\n );\n } else if (spacing === 0) {\n gridSpacing = { xs: 0 };\n } else {\n gridSpacing = spacing;\n }\n\n return gridSpacing;\n}\n\nfunction getNumberOfColumns(columns: HvGridProps[\"columns\"]) {\n let numberOfColumns: MuiGridProps[\"columns\"];\n\n if (columns === \"auto\") {\n numberOfColumns = BREAKPOINT_COLUMNS;\n } else {\n numberOfColumns = columns;\n }\n\n return numberOfColumns;\n}\n\nfunction getContainerProps(\n spacing: HvGridProps[\"spacing\"],\n rowSpacing: HvGridProps[\"rowSpacing\"],\n columnSpacing: HvGridProps[\"columnSpacing\"],\n columns: HvGridProps[\"columns\"],\n) {\n const containerProps: Pick<\n MuiGridProps,\n \"container\" | \"spacing\" | \"rowSpacing\" | \"columnSpacing\" | \"columns\"\n > = { container: true };\n\n if (spacing != null) {\n containerProps.spacing = getGridSpacing(spacing);\n }\n if (rowSpacing != null) {\n containerProps.rowSpacing = getGridSpacing(rowSpacing);\n }\n if (columnSpacing != null) {\n containerProps.columnSpacing = getGridSpacing(columnSpacing);\n }\n if (columns != null) {\n containerProps.columns = getNumberOfColumns(columns);\n }\n\n return containerProps;\n}\n\nconst WidthGrid = forwardRef<\n // no-indent\n HTMLDivElement,\n HvGridProps\n>(function WidthGrid(props, ref) {\n const { container, spacing, rowSpacing, columnSpacing, columns, ...others } =\n props;\n\n const width = useWidth();\n\n const containerProps = container\n ? getContainerProps(\n spacing === \"auto\" ? width : spacing,\n rowSpacing === \"auto\" ? width : rowSpacing,\n columnSpacing === \"auto\" ? width : columnSpacing,\n columns,\n )\n : {};\n\n return <MuiGrid ref={ref} {...containerProps} {...others} />;\n});\n\n/**\n * The grid creates visual consistency between layouts while allowing flexibility\n * across a wide variety of designs. This component is based on a 12-column grid layout.\n *\n * It's based on the [Material UI Grid](https://mui.com/material-ui/react-grid/).\n *\n * However, the number of columns is set to 12 for all breakpoints, as it serves most\n * of the use cases and simplifies the implementation.\n * To opt-in to the Design System directives, you can set the `columns` prop to `auto`.\n *\n * Also, the Design System specifications are omissive about the horizontal gutters.\n * The HvGrid sets them to the same value as the vertical gutters, depending on the breakpoint.\n * It can be overridden by setting the `rowSpacing` prop.\n */\nexport const HvGrid = forwardRef<\n // no-indent\n HTMLDivElement,\n HvGridProps\n>(function HvGrid(props, ref) {\n const {\n item,\n container,\n spacing = \"auto\",\n rowSpacing,\n columnSpacing,\n columns,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvGrid\", props);\n\n const { classes } = useClasses(classesProp);\n\n // Fixes MUI error when using spacings as objects and the grid is an item and container\n // When set to \"auto\", the spacing changes depending on the screen's breakpoint\n // The condition avoids using useWidth and re-rendering the component unnecessarily\n if (\n container &&\n item &&\n (spacing === \"auto\" || rowSpacing === \"auto\" || columnSpacing === \"auto\")\n ) {\n return (\n <WidthGrid\n ref={ref}\n classes={classes}\n item={item}\n container={container}\n spacing={spacing}\n rowSpacing={rowSpacing}\n columnSpacing={columnSpacing}\n columns={columns}\n {...others}\n />\n );\n }\n\n const containerProps = container\n ? getContainerProps(spacing, rowSpacing, columnSpacing, columns)\n : {};\n\n return (\n <MuiGrid\n ref={ref}\n classes={classes}\n item={item}\n {...containerProps}\n {...others}\n />\n );\n});\n"],"names":["WidthGrid","HvGrid"],"mappings":";;;;;;;AAcA,MAAM,qBAAqB;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,qBAAqB;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAuHA,SAAS,eAAe,SAAiC;AACnD,MAAA;AAEA,MAAA,OAAO,YAAY,U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AEF,CAAC;AAEL,6BAAQ,SAAQ,EAAA,KAAW,GAAG,gBAAiB,GAAG,QAAQ;AAC5D,CAAC;AAgBM,MAAM,SAAS,WAIpB,SAASC,QAAO,OAAO,KAAK;AACtB,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACD,gBAAgB,UAAU,KAAK;AAEnC,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAK1C,MACE,aACA,SACC,YAAY,UAAU,eAAe,UAAU,kBAAkB,SAClE;AAEE,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IACN;AAAA,EAAA;AAIE,QAAA,iBAAiB,YACnB,kBAAkB,SAAS,YAAY,eAAe,OAAO,IAC7D,CAAC;AAGH,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Kpi.js","sources":["../../../src/Kpi/Kpi.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { useLabels } from \"../hooks/useLabels\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { staticClasses, useClasses } from \"./Kpi.styles\";\n\nexport { staticClasses as kpiClasses };\n\nexport type HvKpiClasses = ExtractNames<typeof useClasses>;\n\nconst DEFAULT_LABELS = {\n /** The text at the top of the kpi. */\n title: \"\",\n /** The text in the middle of the kpi. */\n indicator: undefined as string | undefined,\n /** The text to the right of the indicator. */\n unit: undefined as string | undefined,\n /** The text to the right of the visual comparison. */\n comparisonIndicatorInfo: undefined as string | undefined,\n};\n\nexport type HvKpiLabelProps = Partial<typeof DEFAULT_LABELS>;\n\nexport interface HvKpiProps extends HvBaseProps<HTMLDivElement, \"children\"> {\n /**\n * An Element that will be rendered to the left of the kpi indicator text.\n */\n trendIndicator?: React.ReactNode;\n /**\n * An Element that will be rendered to the left of the kpi indicator text.\n */\n visualIndicator?: React.ReactNode;\n /**\n * An Element that will be rendered below the kpi indicator text.\n */\n visualComparison?: React.ReactNode;\n /**\n * The object that contains the different labels inside the kpi.\n */\n labels?: HvKpiLabelProps;\n /**\n * The typography variant used in the main text indicator of the KPI\n */\n indicatorTextVariant?: \"display\" | \"title1\" | \"title2\";\n /**\n * The typography variant used in the main text indicator of the KPI\n */\n indicatorUnitTextVariant?: \"title2\" | \"body\";\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvKpiClasses;\n}\n\n/**\n * Key Performance Indicator is a type of performance measurement. It monitors a business indicator\n * and its success/failure against a given target. KPIs are the first item read on a dashboard.\n * Communicates simple, immediate and vital information for operational decision making.\n */\nexport const HvKpi = (props: HvKpiProps) => {\n const {\n trendIndicator = null,\n visualIndicator = null,\n visualComparison = null,\n indicatorUnitTextVariant = \"title2\",\n indicatorTextVariant = \"title1\",\n labels: labelsProp,\n classes: classesProp,\n className,\n ...others\n } = useDefaultProps(\"HvKpi\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const InternalVisualComparison =\n typeof visualComparison === \"string\" ? HvTypography : \"div\";\n\n return (\n <div className={cx(classes.root, className)} {...others}>\n <div>\n <HvTypography variant=\"label\">{labels.title}</HvTypography>\n </div>\n <div className={classes.indicatorsContainer}>\n {visualIndicator && (\n <div\n className={cx(\n classes.visualIndicatorContainer,\n classes.spacingToTheRight,\n )}\n >\n {visualIndicator}\n </div>\n )}\n {labels.indicator && (\n <HvTypography\n className={cx(classes.spacingToTheRight, classes.indicatorText)}\n variant={indicatorTextVariant}\n >\n {labels.indicator}\n </HvTypography>\n )}\n {labels.unit && (\n <HvTypography\n className={classes.indicatorUnit}\n variant={indicatorUnitTextVariant}\n >\n {labels.unit}\n </HvTypography>\n )}\n </div>\n {visualComparison && (\n <div className={classes.comparisonComposition}>\n {trendIndicator && (\n <div className={cx(classes.trendLine, classes.spacingToTheRight)}>\n {trendIndicator}\n </div>\n )}\n <div>\n <div className={classes.comparisonContainer}>\n <InternalVisualComparison\n className={cx(classes.comparisons, classes.spacingToTheRight)}\n variant=\"label\"\n >\n {visualComparison}\n </InternalVisualComparison>\n </div>\n <div className={classes.comparisonContainer}>\n <HvTypography className={classes.comparisons} variant=\"caption2\">\n {labels.comparisonIndicatorInfo}\n </HvTypography>\n </div>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAcA,MAAM,iBAAiB;AAAA;AAAA,EAErB,OAAO;AAAA;AAAA,EAEP,WAAW;AAAA;AAAA,EAEX,MAAM;AAAA;AAAA,EAEN,yBAAyB;AAC3B;AAwCa,MAAA,QAAQ,CAAC,UAAsB;AACpC,QAAA;AAAA,IACJ,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,2BAA2B;AAAA,IAC3B,uBAAuB;AAAA,IACvB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,SAAS,KAAK;AAElC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,SAAS,UAAU,gBAAgB,UAAU;AAEnD,QAAM,2BACJ,OAAO,qBAAqB,WAAW,eAAe;AAGtD,SAAA,qBAAC,SAAI,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,QAC/C,UAAA;AAAA,IAAA,oBAAC,SACC,UAAC,oBAAA,cAAA,EAAa,SAAQ,SAAS,UAAA,OAAO,OAAM,EAC9C,CAAA;AAAA,IACC,qBAAA,OAAA,EAAI,WAAW,QAAQ,qBACrB,UAAA;AAAA,MACC,mBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW;AAAA,YACT,QAAQ;AAAA,YACR,QAAQ;AAAA,UACV;AAAA,UAEC,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,MAED,OAAO,aACN;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,GAAG,QAAQ,mBAAmB,QAAQ,aAAa;AAAA,UAC9D,SAAS;AAAA,UAER,UAAO,OAAA;AAAA,QAAA;AAAA,MACV;AAAA,MAED,OAAO,QACN;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,QAAQ;AAAA,UACnB,SAAS;AAAA,UAER,UAAO,OAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACV,GAEJ;AAAA,IACC,oBACC,qBAAC,OAAI,EAAA,WAAW,QAAQ,uBACrB,UAAA;AAAA,MACC,kBAAA,oBAAC,SAAI,WAAW,GAAG,QAAQ,WAAW,QAAQ,iBAAiB,GAC5D,UACH,eAAA,CAAA;AAAA,2BAED,OACC,EAAA,UAAA;AAAA,QAAC,oBAAA,OAAA,EAAI,WAAW,QAAQ,qBACtB,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW,GAAG,QAAQ,aAAa,QAAQ,iBAAiB;AAAA,YAC5D,SAAQ;AAAA,YAEP,UAAA;AAAA,UAAA;AAAA,QAAA,GAEL;AAAA,QACC,oBAAA,OAAA,EAAI,WAAW,QAAQ,qBACtB,UAAC,oBAAA,cAAA,EAAa,WAAW,QAAQ,aAAa,SAAQ,YACnD,UAAA,OAAO,yBACV,EACF,CAAA;AAAA,MAAA,EACF,CAAA;AAAA,IAAA,EACF,CAAA;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"Kpi.js","sources":["../../../src/Kpi/Kpi.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { useLabels } from \"../hooks/useLabels\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { staticClasses, useClasses } from \"./Kpi.styles\";\n\nexport { staticClasses as kpiClasses };\n\nexport type HvKpiClasses = ExtractNames<typeof useClasses>;\n\nconst DEFAULT_LABELS = {\n /** The text at the top of the kpi. */\n title: \"\",\n /** The text in the middle of the kpi. */\n indicator: undefined as string | undefined,\n /** The text to the right of the indicator. */\n unit: undefined as string | undefined,\n /** The text to the right of the visual comparison. */\n comparisonIndicatorInfo: undefined as string | undefined,\n};\n\nexport type HvKpiLabelProps = Partial<typeof DEFAULT_LABELS>;\n\nexport interface HvKpiProps extends HvBaseProps<HTMLDivElement, \"children\"> {\n /**\n * An Element that will be rendered to the left of the kpi indicator text.\n */\n trendIndicator?: React.ReactNode;\n /**\n * An Element that will be rendered to the left of the kpi indicator text.\n */\n visualIndicator?: React.ReactNode;\n /**\n * An Element that will be rendered below the kpi indicator text.\n */\n visualComparison?: React.ReactNode;\n /**\n * The object that contains the different labels inside the kpi.\n */\n labels?: HvKpiLabelProps;\n /**\n * The typography variant used in the main text indicator of the KPI\n */\n indicatorTextVariant?: \"display\" | \"title1\" | \"title2\";\n /**\n * The typography variant used in the main text indicator of the KPI\n */\n indicatorUnitTextVariant?: \"title2\" | \"body\";\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvKpiClasses;\n}\n\n/**\n * Key Performance Indicator is a type of performance measurement. It monitors a business indicator\n * and its success/failure against a given target. KPIs are the first item read on a dashboard.\n * Communicates simple, immediate and vital information for operational decision making.\n * @deprecated build KPIs with `HvCard`, or with your custom layouts\n */\nexport const HvKpi = (props: HvKpiProps) => {\n const {\n trendIndicator = null,\n visualIndicator = null,\n visualComparison = null,\n indicatorUnitTextVariant = \"title2\",\n indicatorTextVariant = \"title1\",\n labels: labelsProp,\n classes: classesProp,\n className,\n ...others\n } = useDefaultProps(\"HvKpi\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const InternalVisualComparison =\n typeof visualComparison === \"string\" ? HvTypography : \"div\";\n\n return (\n <div className={cx(classes.root, className)} {...others}>\n <div>\n <HvTypography variant=\"label\">{labels.title}</HvTypography>\n </div>\n <div className={classes.indicatorsContainer}>\n {visualIndicator && (\n <div\n className={cx(\n classes.visualIndicatorContainer,\n classes.spacingToTheRight,\n )}\n >\n {visualIndicator}\n </div>\n )}\n {labels.indicator && (\n <HvTypography\n className={cx(classes.spacingToTheRight, classes.indicatorText)}\n variant={indicatorTextVariant}\n >\n {labels.indicator}\n </HvTypography>\n )}\n {labels.unit && (\n <HvTypography\n className={classes.indicatorUnit}\n variant={indicatorUnitTextVariant}\n >\n {labels.unit}\n </HvTypography>\n )}\n </div>\n {visualComparison && (\n <div className={classes.comparisonComposition}>\n {trendIndicator && (\n <div className={cx(classes.trendLine, classes.spacingToTheRight)}>\n {trendIndicator}\n </div>\n )}\n <div>\n <div className={classes.comparisonContainer}>\n <InternalVisualComparison\n className={cx(classes.comparisons, classes.spacingToTheRight)}\n variant=\"label\"\n >\n {visualComparison}\n </InternalVisualComparison>\n </div>\n <div className={classes.comparisonContainer}>\n <HvTypography className={classes.comparisons} variant=\"caption2\">\n {labels.comparisonIndicatorInfo}\n </HvTypography>\n </div>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAcA,MAAM,iBAAiB;AAAA;AAAA,EAErB,OAAO;AAAA;AAAA,EAEP,WAAW;AAAA;AAAA,EAEX,MAAM;AAAA;AAAA,EAEN,yBAAyB;AAC3B;AAyCa,MAAA,QAAQ,CAAC,UAAsB;AACpC,QAAA;AAAA,IACJ,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,2BAA2B;AAAA,IAC3B,uBAAuB;AAAA,IACvB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBA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AA,QACC,oBAAA,OAAA,EAAI,WAAW,QAAQ,qBACtB,UAAC,oBAAA,cAAA,EAAa,WAAW,QAAQ,aAAa,SAAQ,YACnD,UAAA,OAAO,yBACV,EACF,CAAA;AAAA,MAAA,EACF,CAAA;AAAA,IAAA,EACF,CAAA;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","sources":["../../../src/Link/Link.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { staticClasses, useClasses } from \"./Link.styles\";\n\nexport { staticClasses as linkClasses };\n\nexport type HvLinkClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvLinkProps extends HvBaseProps<HTMLAnchorElement, \"onClick\"> {\n onClick?: (event: React.MouseEvent<HTMLAnchorElement>, data: any) => void;\n route?: string;\n data?: any;\n children: any;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvLinkClasses;\n}\n\nexport const HvLink = (props: HvLinkProps) => {\n const {\n onClick,\n classes: classesProp,\n className,\n route,\n data,\n children,\n ...others\n } = useDefaultProps(\"HvLink\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n return (\n <a\n href={route}\n onClick={(event) => {\n if (!onClick) return;\n\n event.preventDefault();\n onClick?.(event, data);\n }}\n className={cx(classes.a, className)}\n {...others}\n >\n {children}\n </a>\n );\n};\n"],"names":[],"mappings":";;;;AAqBa,MAAA,SAAS,CAAC,UAAuB;AACtC,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,UAAU,KAAK;AAEnC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAG5C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAM;AAAA,MACN,SAAS,CAAC,UAAU;AAClB,YAAI,CAAC,QAAS;AAEd,cAAM,eAAe;AACrB,kBAAU,OAAO,IAAI;AAAA,MACvB;AAAA,MACA,WAAW,GAAG,QAAQ,GAAG,SAAS;AAAA,MACjC,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
1
+ {"version":3,"file":"Link.js","sources":["../../../src/Link/Link.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { staticClasses, useClasses } from \"./Link.styles\";\n\nexport { staticClasses as linkClasses };\n\nexport type HvLinkClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvLinkProps extends HvBaseProps<HTMLAnchorElement, \"onClick\"> {\n onClick?: (event: React.MouseEvent<HTMLAnchorElement>, data: any) => void;\n route?: string;\n data?: any;\n children: any;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvLinkClasses;\n}\n\n/** @deprecated use `<HvTypography link component=\"a\" />` instead */\nexport const HvLink = (props: HvLinkProps) => {\n const {\n onClick,\n classes: classesProp,\n className,\n route,\n data,\n children,\n ...others\n } = useDefaultProps(\"HvLink\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n return (\n <a\n href={route}\n onClick={(event) => {\n if (!onClick) return;\n\n event.preventDefault();\n onClick?.(event, data);\n }}\n className={cx(classes.a, className)}\n {...others}\n >\n {children}\n </a>\n );\n};\n"],"names":[],"mappings":";;;;AAsBa,MAAA,SAAS,CAAC,UAAuB;AACtC,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,UAAU,KAAK;AAEnC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAG5C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAM;AAAA,MACN,SAAS,CAAC,UAAU;AAClB,YAAI,CAAC,QAAS;AAEd,cAAM,eAAe;AACrB,kBAAU,OAAO,IAAI;AAAA,MACvB;AAAA,MACA,WAAW,GAAG,QAAQ,GAAG,SAAS;AAAA,MACjC,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sources":["../../../src/List/List.tsx"],"sourcesContent":["import {\n AriaRole,\n forwardRef,\n isValidElement,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { FixedSizeList } from \"react-window\";\nimport { DropRightXS } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../CheckBox\";\nimport { HvLink } from \"../Link\";\nimport {\n HvListContainer,\n HvListContainerProps,\n HvListItem,\n} from \"../ListContainer\";\nimport { HvOverflowTooltip } from \"../OverflowTooltip\";\nimport { HvRadio } from \"../Radio\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./List.styles\";\nimport { HvListLabels, HvListValue } from \"./types\";\nimport { useSelectableList } from \"./useSelectableList\";\nimport { parseList } from \"./utils\";\n\nexport { staticClasses as listClasses };\n\nexport type HvListClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListProps\n extends HvBaseProps<HTMLUListElement, \"onChange\" | \"onClick\"> {\n /**\n * A list containing the elements to be rendered.\n *\n * - id: The id of the item.\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - isHidden: Is item visible.\n * - icon: The icon.\n * - showNavIcon: If true renders the navigation icon on the right.\n * - path: The path to navigate to.\n */\n values: HvListValue[];\n /** If true renders a multi select list. */\n multiSelect?: boolean;\n /**\n * If true renders select all option for multi selection lists with selectors.\n * note: It will only be rendered if multiSelect and useSelector props are set to true.\n */\n showSelectAll?: boolean;\n /** An object containing all the labels for the dropdown. */\n labels?: HvListLabels;\n /** If true renders list items with radio or checkbox selectors. */\n useSelector?: boolean;\n /** Call back fired when list item is selected. Returns selection state. */\n onChange?: (value: HvListValue[]) => void;\n /** Call back fired when list item is selected. Returns selected item. */\n onClick?: (\n event:\n | React.ChangeEvent<HTMLInputElement>\n | React.MouseEvent<HTMLLIElement>,\n value: HvListValue,\n ) => void;\n /** If `true` the list items will show the selection state. */\n selectable?: boolean;\n /** If `true`, selection can be toggled when single selection. */\n singleSelectionToggle?: boolean;\n /** If `true` the list will be rendered without vertical spacing. */\n condensed?: boolean;\n /** If `true` the dropdown will show tooltips when user mouseenter text in list. @deprecated this is always enabled */\n hasTooltips?: boolean;\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 height?: number;\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 virtualized?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListClasses;\n}\n\nconst DEFAULT_LABELS = {\n selectAll: \"Select All\",\n selectionConjunction: \"/\",\n};\n\n/**\n * Component used to show a set of related data to the user.\n */\nexport const HvList = (props: HvListProps) => {\n const {\n id,\n classes: classesProp,\n className,\n multiSelect = false,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n hasTooltips = false,\n showSelectAll = false,\n labels = DEFAULT_LABELS,\n useSelector = false,\n selectable = true,\n singleSelectionToggle = true,\n condensed = false,\n onChange,\n onClick,\n values: valuesProp = [],\n height,\n virtualized = false,\n ...others\n } = useDefaultProps(\"HvList\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [list, setList, selection] = useSelectableList(valuesProp);\n const listRef = useRef<any>(null);\n\n useEffect(() => {\n const passedProps = { multiSelect, selectable, singleSelectionToggle };\n const parsedList: HvListValue[] = parseList(\n undefined,\n passedProps,\n undefined,\n valuesProp,\n );\n\n setList(parsedList);\n }, [valuesProp, multiSelect, selectable, singleSelectionToggle, setList]);\n\n const [role, itemRole] = useMemo<[AriaRole, AriaRole]>(() => {\n // selectors are responsible for the role & selection state\n if (selectable && useSelector) return [\"list\", \"listitem\"];\n\n if (selectable) return [\"listbox\", \"option\"];\n return [\"menu\", \"menuitem\"];\n }, [selectable, useSelector]);\n\n const handleSelect = (\n evt: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLLIElement>,\n item: HvListValue,\n ) => {\n if (!item.path) evt.preventDefault();\n if (item.disabled) return;\n\n const passedProps = { multiSelect, selectable, singleSelectionToggle };\n const parsedList = parseList(item, passedProps, undefined, list);\n setList(parsedList);\n\n onClick?.(evt, item);\n onChange?.(parsedList);\n };\n\n const handleSelectAll = () => {\n const passedProps = { multiSelect, selectable, singleSelectionToggle };\n const anySelectableSelected = list.some(\n (elem) => elem.selected || elem.disabled,\n );\n const parsedList = parseList(\n undefined,\n passedProps,\n !anySelectableSelected,\n list,\n );\n setList(parsedList);\n\n onChange?.(parsedList);\n };\n\n const renderLeftIcon = (item: HvListValue) => {\n return isValidElement(item.icon)\n ? item.icon\n : typeof item.icon === \"function\"\n ? item.icon?.({\n isSelected: item.selected,\n isDisabled: item.disabled,\n })\n : null;\n };\n\n const renderSelectAll = () => {\n const { selectAll, selectionConjunction } = labels;\n\n const anySelected = !!selection?.length;\n const allSelected = selection.length === list.length;\n\n const selectionLabel = (\n <HvTypography component=\"span\">\n {!anySelected ? (\n <>\n <b>{selectAll}</b>\n {` (${list.length})`}\n </>\n ) : (\n <>\n <b>{selection.length}</b>\n {`\\xa0${selectionConjunction}\\xa0`}\n {list.length}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={selectionLabel}\n onChange={handleSelectAll}\n className={classes.selectAllSelector}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n );\n };\n\n const renderItemText = (item: HvListValue) => {\n return !multiSelect && item.path ? (\n <HvLink route={item.path} classes={{ a: classes.link }}>\n <HvOverflowTooltip data={item.label} />\n </HvLink>\n ) : (\n <HvOverflowTooltip data={item.label} />\n );\n };\n\n const renderSelectItem = (item: HvListValue, itemId?: string) => {\n if (!useSelector) return renderItemText(item);\n\n const Component = multiSelect ? HvCheckBox : HvRadio;\n\n return (\n <Component\n id={setId(itemId, \"selector\")}\n label={<HvOverflowTooltip data={item.label} />}\n checked={item.selected || false}\n disabled={item.disabled}\n onChange={multiSelect ? (evt) => handleSelect(evt, item) : undefined}\n classes={{\n root: classes.selectorRoot,\n container: classes.selectorContainer,\n label: classes.truncate,\n }}\n />\n );\n };\n\n const renderListItem = (item: HvListValue, i: number, otherProps = {}) => {\n const itemId = setId(id, \"item\", i);\n const selected = item.selected || false;\n\n const startAdornment =\n !useSelector && item.icon ? renderLeftIcon(item) : null;\n\n return (\n <HvListItem\n key={i}\n id={itemId}\n role={itemRole}\n disabled={item.disabled || undefined}\n className={classes.item}\n classes={{\n selected: cx({\n [classes.itemSelector]: useSelector || multiSelect,\n }),\n }}\n selected={multiSelect || selected ? selected : undefined}\n onClick={(evt) => handleSelect(evt, item)}\n startAdornment={startAdornment}\n endAdornment={\n item.showNavIcon && (\n <DropRightXS className={classes.box} iconSize=\"XS\" />\n )\n }\n {...otherProps}\n >\n {renderSelectItem(item, itemId)}\n </HvListItem>\n );\n };\n\n const filteredList = list.filter((it) => !it.isHidden);\n const anySelected = list\n .map((item) => item.selected && !item.disabled)\n .reduce((result, selected) => result || selected, false);\n\n const selectedItemIndex = list.findIndex((item) => item.selected);\n useEffect(() => {\n if (selectedItemIndex >= 0 && listRef.current !== null) {\n listRef.current.scrollToItem(selectedItemIndex);\n }\n }, [listRef, selectedItemIndex]);\n\n const renderVirtualizedListItem = ({\n index,\n style,\n }: {\n index: number;\n style: Record<string, any>;\n }) => {\n const item = filteredList[index];\n const tabIndex =\n item.tabIndex ||\n (!anySelected && index === 0) ||\n (item.selected && !item.disabled)\n ? 0\n : -1;\n\n return renderListItem(item, index, {\n style: {\n ...style,\n top: `${parseFloat(style.top) + 5}px`,\n left: `${parseFloat(style.left) + 5}px`,\n width: `calc(${parseFloat(style.width)}% - 10px)`,\n },\n tabIndex,\n interactive: true,\n condensed,\n disableGutters: useSelector,\n });\n };\n\n const ariaMultiSelectable = (role === \"listbox\" && multiSelect) || undefined;\n\n const ListContainer = useMemo(() => {\n // eslint-disable-next-line react/display-name\n return forwardRef<HTMLUListElement, HvListContainerProps>(\n ({ ...rest }, ref) => (\n <HvListContainer\n id={id}\n className={cx(classes.root, className)}\n role={role}\n interactive\n condensed={condensed}\n disableGutters={useSelector}\n aria-multiselectable={ariaMultiSelectable}\n ref={ref}\n {...rest}\n />\n ),\n );\n }, [\n cx,\n id,\n useSelector,\n className,\n classes.root,\n role,\n condensed,\n ariaMultiSelectable,\n ]);\n\n // Render nothing if there are no items\n if (filteredList.length === 0) return null;\n\n return (\n <>\n {multiSelect && useSelector && showSelectAll && renderSelectAll()}\n\n {!virtualized ? (\n <HvListContainer\n id={id}\n className={cx(classes.root, className)}\n role={role}\n interactive\n condensed={condensed}\n disableGutters={useSelector}\n aria-multiselectable={ariaMultiSelectable}\n {...others}\n >\n {filteredList.map((item, i) => renderListItem(item, i))}\n </HvListContainer>\n ) : (\n <FixedSizeList\n ref={listRef}\n className={classes.virtualizedRoot}\n height={(height || 0) + 5}\n width=\"100%\"\n itemCount={filteredList.length}\n itemSize={condensed ? 32 : 40}\n innerElementType={ListContainer}\n {...(others as any)}\n >\n {renderVirtualizedListItem}\n </FixedSizeList>\n )}\n </>\n );\n};\n"],"names":["anySelected"],"mappings":";;;;;;;;;;;;;;;;;AAuFA,MAAM,iBAAiB;AAAA,EACrB,WAAW;AAAA,EACX,sBAAsB;AACxB;AAKa,MAAA,SAAS,CAAC,UAAuB;AACtC,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,cAAc;AAAA;AAAA,IAEd,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,aAAa;AAAA,IACb,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AA;AAAA,IAGV;AAAA,EAAA,GACC;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAGG,MAAA,aAAa,WAAW,EAAU,QAAA;AAEtC,SAEK,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAe,eAAA,eAAe,iBAAiB,gBAAgB;AAAA,IAE/D,CAAC,cACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QACrC;AAAA,QACA,aAAW;AAAA,QACX;AAAA,QACA,gBAAgB;AAAA,QAChB,wBAAsB;AAAA,QACrB,GAAG;AAAA,QAEH,UAAA,aAAa,IAAI,CAAC,MAAM,MAAM,eAAe,MAAM,CAAC,CAAC;AAAA,MAAA;AAAA,IAAA,IAGxD;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,WAAW,QAAQ;AAAA,QACnB,SAAS,UAAU,KAAK;AAAA,QACxB,OAAM;AAAA,QACN,WAAW,aAAa;AAAA,QACxB,UAAU,YAAY,KAAK;AAAA,QAC3B,kBAAkB;AAAA,QACjB,GAAI;AAAA,QAEJ,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"List.js","sources":["../../../src/List/List.tsx"],"sourcesContent":["import {\n AriaRole,\n forwardRef,\n isValidElement,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { FixedSizeList } from \"react-window\";\nimport { DropRightXS } from \"@hitachivantara/uikit-react-icons\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../CheckBox\";\nimport { HvLink } from \"../Link\";\nimport {\n HvListContainer,\n HvListContainerProps,\n HvListItem,\n} from \"../ListContainer\";\nimport { HvOverflowTooltip } from \"../OverflowTooltip\";\nimport { HvRadio } from \"../Radio\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvTypography } from \"../Typography\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./List.styles\";\nimport { HvListLabels, HvListValue } from \"./types\";\nimport { useSelectableList } from \"./useSelectableList\";\nimport { parseList } from \"./utils\";\n\nexport { staticClasses as listClasses };\n\nexport type HvListClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListProps\n extends HvBaseProps<HTMLUListElement, \"onChange\" | \"onClick\"> {\n /**\n * A list containing the elements to be rendered.\n *\n * - id: The id of the item.\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - isHidden: Is item visible.\n * - icon: The icon.\n * - showNavIcon: If true renders the navigation icon on the right.\n * - path: The path to navigate to.\n */\n values: HvListValue[];\n /** If true renders a multi select list. */\n multiSelect?: boolean;\n /**\n * If true renders select all option for multi selection lists with selectors.\n * note: It will only be rendered if multiSelect and useSelector props are set to true.\n */\n showSelectAll?: boolean;\n /** An object containing all the labels for the dropdown. */\n labels?: HvListLabels;\n /** If true renders list items with radio or checkbox selectors. */\n useSelector?: boolean;\n /** Call back fired when list item is selected. Returns selection state. */\n onChange?: (value: HvListValue[]) => void;\n /** Call back fired when list item is selected. Returns selected item. */\n onClick?: (\n event:\n | React.ChangeEvent<HTMLInputElement>\n | React.MouseEvent<HTMLLIElement>,\n value: HvListValue,\n ) => void;\n /** If `true` the list items will show the selection state. */\n selectable?: boolean;\n /** If `true`, selection can be toggled when single selection. */\n singleSelectionToggle?: boolean;\n /** If `true` the list will be rendered without vertical spacing. */\n condensed?: boolean;\n /** If `true` the dropdown will show tooltips when user mouseenter text in list. @deprecated this is always enabled */\n hasTooltips?: boolean;\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 height?: number;\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 virtualized?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListClasses;\n}\n\nconst DEFAULT_LABELS = {\n selectAll: \"Select All\",\n selectionConjunction: \"/\",\n};\n\n/**\n * Component used to show a set of related data to the user.\n * @deprecated use `HvListContainer` + `HvListItem` instead\n */\nexport const HvList = (props: HvListProps) => {\n const {\n id,\n classes: classesProp,\n className,\n multiSelect = false,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n hasTooltips = false,\n showSelectAll = false,\n labels = DEFAULT_LABELS,\n useSelector = false,\n selectable = true,\n singleSelectionToggle = true,\n condensed = false,\n onChange,\n onClick,\n values: valuesProp = [],\n height,\n virtualized = false,\n ...others\n } = useDefaultProps(\"HvList\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [list, setList, selection] = useSelectableList(valuesProp);\n const listRef = useRef<any>(null);\n\n useEffect(() => {\n const passedProps = { multiSelect, selectable, singleSelectionToggle };\n const parsedList: HvListValue[] = parseList(\n undefined,\n passedProps,\n undefined,\n valuesProp,\n );\n\n setList(parsedList);\n }, [valuesProp, multiSelect, selectable, singleSelectionToggle, setList]);\n\n const [role, itemRole] = useMemo<[AriaRole, AriaRole]>(() => {\n // selectors are responsible for the role & selection state\n if (selectable && useSelector) return [\"list\", \"listitem\"];\n\n if (selectable) return [\"listbox\", \"option\"];\n return [\"menu\", \"menuitem\"];\n }, [selectable, useSelector]);\n\n const handleSelect = (\n evt: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLLIElement>,\n item: HvListValue,\n ) => {\n if (!item.path) evt.preventDefault();\n if (item.disabled) return;\n\n const passedProps = { multiSelect, selectable, singleSelectionToggle };\n const parsedList = parseList(item, passedProps, undefined, list);\n setList(parsedList);\n\n onClick?.(evt, item);\n onChange?.(parsedList);\n };\n\n const handleSelectAll = () => {\n const passedProps = { multiSelect, selectable, singleSelectionToggle };\n const anySelectableSelected = list.some(\n (elem) => elem.selected || elem.disabled,\n );\n const parsedList = parseList(\n undefined,\n passedProps,\n !anySelectableSelected,\n list,\n );\n setList(parsedList);\n\n onChange?.(parsedList);\n };\n\n const renderLeftIcon = (item: HvListValue) => {\n return isValidElement(item.icon)\n ? item.icon\n : typeof item.icon === \"function\"\n ? item.icon?.({\n isSelected: item.selected,\n isDisabled: item.disabled,\n })\n : null;\n };\n\n const renderSelectAll = () => {\n const { selectAll, selectionConjunction } = labels;\n\n const anySelected = !!selection?.length;\n const allSelected = selection.length === list.length;\n\n const selectionLabel = (\n <HvTypography component=\"span\">\n {!anySelected ? (\n <>\n <b>{selectAll}</b>\n {` (${list.length})`}\n </>\n ) : (\n <>\n <b>{selection.length}</b>\n {`\\xa0${selectionConjunction}\\xa0`}\n {list.length}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={selectionLabel}\n onChange={handleSelectAll}\n className={classes.selectAllSelector}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n );\n };\n\n const renderItemText = (item: HvListValue) => {\n return !multiSelect && item.path ? (\n <HvLink route={item.path} classes={{ a: classes.link }}>\n <HvOverflowTooltip data={item.label} />\n </HvLink>\n ) : (\n <HvOverflowTooltip data={item.label} />\n );\n };\n\n const renderSelectItem = (item: HvListValue, itemId?: string) => {\n if (!useSelector) return renderItemText(item);\n\n const Component = multiSelect ? HvCheckBox : HvRadio;\n\n return (\n <Component\n id={setId(itemId, \"selector\")}\n label={<HvOverflowTooltip data={item.label} />}\n checked={item.selected || false}\n disabled={item.disabled}\n onChange={multiSelect ? (evt) => handleSelect(evt, item) : undefined}\n classes={{\n root: classes.selectorRoot,\n container: classes.selectorContainer,\n label: classes.truncate,\n }}\n />\n );\n };\n\n const renderListItem = (item: HvListValue, i: number, otherProps = {}) => {\n const itemId = setId(id, \"item\", i);\n const selected = item.selected || false;\n\n const startAdornment =\n !useSelector && item.icon ? renderLeftIcon(item) : null;\n\n return (\n <HvListItem\n key={i}\n id={itemId}\n role={itemRole}\n disabled={item.disabled || undefined}\n className={classes.item}\n classes={{\n selected: cx({\n [classes.itemSelector]: useSelector || multiSelect,\n }),\n }}\n selected={multiSelect || selected ? selected : undefined}\n onClick={(evt) => handleSelect(evt, item)}\n startAdornment={startAdornment}\n endAdornment={\n item.showNavIcon && (\n <DropRightXS className={classes.box} iconSize=\"XS\" />\n )\n }\n {...otherProps}\n >\n {renderSelectItem(item, itemId)}\n </HvListItem>\n );\n };\n\n const filteredList = list.filter((it) => !it.isHidden);\n const anySelected = list\n .map((item) => item.selected && !item.disabled)\n .reduce((result, selected) => result || selected, false);\n\n const selectedItemIndex = list.findIndex((item) => item.selected);\n useEffect(() => {\n if (selectedItemIndex >= 0 && listRef.current !== null) {\n listRef.current.scrollToItem(selectedItemIndex);\n }\n }, [listRef, selectedItemIndex]);\n\n const renderVirtualizedListItem = ({\n index,\n style,\n }: {\n index: number;\n style: Record<string, any>;\n }) => {\n const item = filteredList[index];\n const tabIndex =\n item.tabIndex ||\n (!anySelected && index === 0) ||\n (item.selected && !item.disabled)\n ? 0\n : -1;\n\n return renderListItem(item, index, {\n style: {\n ...style,\n top: `${parseFloat(style.top) + 5}px`,\n left: `${parseFloat(style.left) + 5}px`,\n width: `calc(${parseFloat(style.width)}% - 10px)`,\n },\n tabIndex,\n interactive: true,\n condensed,\n disableGutters: useSelector,\n });\n };\n\n const ariaMultiSelectable = (role === \"listbox\" && multiSelect) || undefined;\n\n const ListContainer = useMemo(() => {\n // eslint-disable-next-line react/display-name\n return forwardRef<HTMLUListElement, HvListContainerProps>(\n ({ ...rest }, ref) => (\n <HvListContainer\n id={id}\n className={cx(classes.root, className)}\n role={role}\n interactive\n condensed={condensed}\n disableGutters={useSelector}\n aria-multiselectable={ariaMultiSelectable}\n ref={ref}\n {...rest}\n />\n ),\n );\n }, [\n cx,\n id,\n useSelector,\n className,\n classes.root,\n role,\n condensed,\n ariaMultiSelectable,\n ]);\n\n // Render nothing if there are no items\n if (filteredList.length === 0) return null;\n\n return (\n <>\n {multiSelect && useSelector && showSelectAll && renderSelectAll()}\n\n {!virtualized ? (\n <HvListContainer\n id={id}\n className={cx(classes.root, className)}\n role={role}\n interactive\n condensed={condensed}\n disableGutters={useSelector}\n aria-multiselectable={ariaMultiSelectable}\n {...others}\n >\n {filteredList.map((item, i) => renderListItem(item, i))}\n </HvListContainer>\n ) : (\n <FixedSizeList\n ref={listRef}\n className={classes.virtualizedRoot}\n height={(height || 0) + 5}\n width=\"100%\"\n itemCount={filteredList.length}\n itemSize={condensed ? 32 : 40}\n innerElementType={ListContainer}\n {...(others as any)}\n >\n {renderVirtualizedListItem}\n </FixedSizeList>\n )}\n </>\n );\n};\n"],"names":["anySelected"],"mappings":";;;;;;;;;;;;;;;;;AAuFA,MAAM,iBAAiB;AAAA,EACrB,WAAW;AAAA,EACX,sBAAsB;AACxB;AAMa,MAAA,SAAS,CAAC,UAAuB;AACtC,QAAA;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,cAAc;AAAA;AAAA,IAEd,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,aAAa;AAAA,IACb,wBAAwB;AAAA,IACxB,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,QAAQ,aAAa,CAAC;AAAA,IACtB;AAAA,IACA,cAAc;AAAA,IACd,GAAG;AAAA,EAAA,IACD,gBAAgB,UAAU,KAAK;AAEnC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAE9C,QAAM,CAAC,MAAM,SAAS,SAAS,IAAI,kBAAkB,UAAU;AACzD,QAAA,UAAU,OAAY,IAAI;AAEhC,YAAU,MAAM;AACd,UAAM,cAAc,EAAE,aAAa,YAAY,sBAAsB;AACrE,UAAM,aAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,YAAQ,UAAU;AAAA,EAAA,GACjB,CAAC,YAAY,aAAa,YAAY,uBAAuB,OAAO,CAAC;AAExE,QAAM,CAA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;AAAA,MAAA;AAAA,IAAA,IAGxD;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,WAAW,QAAQ;AAAA,QACnB,SAAS,UAAU,KAAK;AAAA,QACxB,OAAM;AAAA,QACN,WAAW,aAAa;AAAA,QACxB,UAAU,YAAY,KAAK;AAAA,QAC3B,kBAAkB;AAAA,QACjB,GAAI;AAAA,QAEJ,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GAEJ;AAEJ;"}
@@ -1,9 +1,9 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
3
- import { setId } from "../../../utils/setId.js";
3
+ import { setId } from "../../utils/setId.js";
4
4
  import { useClasses } from "./HorizontalScrollListItem.styles.js";
5
5
  import { staticClasses } from "./HorizontalScrollListItem.styles.js";
6
- import { HvOverflowTooltip } from "../../../OverflowTooltip/OverflowTooltip.js";
6
+ import { HvOverflowTooltip } from "../../OverflowTooltip/OverflowTooltip.js";
7
7
  const HvHorizontalScrollListItem = (props) => {
8
8
  const {
9
9
  id,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalScrollListItem.js","sources":["../../../../src/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport {\n HvOverflowTooltip,\n HvOverflowTooltipProps,\n} from \"../../OverflowTooltip\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { setId } from \"../../utils/setId\";\nimport { staticClasses, useClasses } from \"./HorizontalScrollListItem.styles\";\n\nexport { staticClasses as horizontalScrollListItemClasses };\n\nexport type HvHorizontalScrollListItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvHorizontalScrollListItemProps\n extends HvBaseProps<HTMLDivElement | HTMLAnchorElement> {\n /** The text to render. */\n label?: React.ReactNode;\n /** Whether the element is selected. */\n selected?: boolean;\n tooltipPlacement: HvOverflowTooltipProps[\"placement\"];\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvHorizontalScrollListItemClasses;\n\n /**\n * The link to be set in the href attribute of the anchor element.\n *\n * If this is not set, the element will be rendered as a div with a button role.\n */\n href?: string;\n /** @deprecated remove in v6 */\n iconClasses?: string;\n}\n\n/**\n * HvHorizontalScrollListItem a focusable item to be used as part of the horizontal scroll\n */\nexport const HvHorizontalScrollListItem = (\n props: HvHorizontalScrollListItemProps,\n) => {\n const {\n id,\n className,\n classes: classesProp,\n selected,\n label,\n tooltipPlacement,\n href,\n iconClasses,\n ...others\n } = useDefaultProps(\"HvHorizontalScrollListItem\", props);\n const { classes, cx } = useClasses(classesProp);\n const buttonId = setId(id, \"button\");\n\n const Component = href != null ? \"a\" : \"div\";\n\n return (\n <li id={id} className={cx(classes.root, className)} aria-current={selected}>\n <Component\n id={buttonId}\n role={href == null ? \"button\" : undefined}\n tabIndex={0}\n className={classes.button}\n href={href}\n {...others}\n >\n <HvOverflowTooltip\n className={cx(classes.text, { [classes.selected]: selected })}\n placement={tooltipPlacement}\n data={label}\n />\n <div\n aria-hidden\n className={cx(classes.bullet, iconClasses, {\n [classes.bulletSelected]: selected,\n })}\n >\n <span />\n </div>\n </Component>\n </li>\n );\n};\n"],"names":[],"mappings":";;;;;;AAwCa,MAAA,6BAA6B,CACxC,UACG;AACG,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,8BAA8B,KAAK;AACvD,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AACxC,QAAA,WAAW,MAAM,IAAI,QAAQ;AAE7B,QAAA,YAAY,QAAQ,OAAO,MAAM;AAGrC,SAAA,oBAAC,MAAG,EAAA,IAAQ,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAG,gBAAc,UAChE,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI;AAAA,MACJ,MAAM,QAAQ,OAAO,WAAW;AAAA,MAChC,UAAU;AAAA,MACV,WAAW,QAAQ;AAAA,MACnB;AAAA,MACC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW,GAAG,QAAQ,MAAM,EAAE,CAAC,QAAQ,QAAQ,GAAG,UAAU;AAAA,YAC5D,WAAW;AAAA,YACX,MAAM;AAAA,UAAA;AAAA,QACR;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAW;AAAA,YACX,WAAW,GAAG,QAAQ,QAAQ,aAAa;AAAA,cACzC,CAAC,QAAQ,cAAc,GAAG;AAAA,YAAA,CAC3B;AAAA,YAED,8BAAC,QAAK,CAAA,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -1,6 +1,6 @@
1
1
  import { createClasses } from "@hitachivantara/uikit-react-utils";
2
2
  import { theme } from "@hitachivantara/uikit-styles";
3
- import { outlineStyles } from "../../../utils/focusUtils.js";
3
+ import { outlineStyles } from "../../utils/focusUtils.js";
4
4
  const name = "HvHorizontalScrollListItem";
5
5
  const { staticClasses, useClasses } = createClasses(name, {
6
6
  root: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalScrollListItem.styles.js","sources":["../../../../src/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../../utils/focusUtils\";\n\nconst name = \"HvHorizontalScrollListItem\";\n\nexport const { staticClasses, useClasses } = createClasses(name, {\n root: {\n padding: theme.spacing(\"xs\", 0),\n maxWidth: 120,\n },\n button: {\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n \"&:focus-visible\": {\n ...outlineStyles,\n },\n },\n text: {\n margin: theme.spacing(\"xs\", \"xs\", \"0\"),\n },\n selected: {\n fontWeight: theme.typography.label.fontWeight,\n },\n bullet: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n minHeight: 24,\n height: 24,\n width: 24,\n fontSize: 4,\n color: theme.colors.secondary_60,\n\n \"& > span\": {\n margin: \"auto\",\n width: \"1em\",\n height: \"1em\",\n backgroundColor: \"currentcolor\",\n borderRadius: \"50%\",\n },\n },\n bulletSelected: {\n fontSize: 6,\n color: theme.colors.secondary,\n },\n});\n"],"names":[],"mappings":";;;AAKA,MAAM,OAAO;AAEN,MAAM,EAAE,eAAe,eAAe,cAAc,MAAM;AAAA,EAC/D,MAAM;AAAA,IACJ,SAAS,MAAM,QAAQ,MAAM,CAAC;AAAA,IAC9B,UAAU;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,mBAAmB;AAAA,MACjB,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EACA,MAAM;AAAA,IACJ,QAAQ,MAAM,QAAQ,MAAM,MAAM,GAAG;AAAA,EACvC;AAAA,EACA,UAAU;AAAA,IACR,YAAY,MAAM,WAAW,MAAM;AAAA,EACrC;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,OAAO,MAAM,OAAO;AAAA,IAEpB,YAAY;AAAA,MACV,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,iBAAiB;AAAA,MACjB,cAAc;AAAA,IAAA;AAAA,EAElB;AAAA,EACA,gBAAgB;AAAA,IACd,UAAU;AAAA,IACV,OAAO,MAAM,OAAO;AAAA,EAAA;AAExB,CAAC;"}
@@ -3,9 +3,9 @@ import { useTheme } from "@mui/material/styles";
3
3
  import useMediaQuery from "@mui/material/useMediaQuery";
4
4
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
5
5
  import { theme } from "@hitachivantara/uikit-styles";
6
- import { isKey } from "../../utils/keyboardUtils.js";
7
- import { setId } from "../../utils/setId.js";
8
- import { useScrollTo } from "../useScrollTo.js";
6
+ import { useScrollTo } from "../hooks/useScrollTo.js";
7
+ import { isKey } from "../utils/keyboardUtils.js";
8
+ import { setId } from "../utils/setId.js";
9
9
  import { useClasses } from "./ScrollToHorizontal.styles.js";
10
10
  import { staticClasses } from "./ScrollToHorizontal.styles.js";
11
11
  import { HvHorizontalScrollListItem } from "./HorizontalScrollListItem/HorizontalScrollListItem.js";
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollToHorizontal.js","sources":["../../../../src/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvBaseProps } from \"../../types/generic\";\nimport { isKey } from \"../../utils/keyboardUtils\";\nimport { setId } from \"../../utils/setId\";\nimport { HvScrollToOption, HvScrollToTooltipPositions } from \"../types\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = (props: HvScrollToHorizontalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n // @ts-ignore\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n } = useDefaultProps(\"HvScrollToHorizontal\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange,\n );\n\n const tabs = elements.map((option, index) => (\n <HvHorizontalScrollListItem\n id={setId(id, `item-${index}`)}\n onClick={(event) => {\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") !== true) return;\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onEnter?.(event, index);\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipPlacement={tooltipPosition}\n selected={selectedIndex === index}\n key={option.key || option.label}\n label={option.label}\n iconClasses={cx({\n [classes.selected]: selectedIndex === index,\n [classes.notSelected]: selectedIndex !== index,\n [classes.notSelectedRoot]: selectedIndex !== index,\n })}\n />\n ));\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n }),\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n },\n className,\n )}\n id={id}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useMuiTheme"],"mappings":";;;;;;;;;;;AAsGa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA;AAAA,IAEA,OAAO;AAAA,IACP,iBAAiB,OAAO,SAAS;AAAA,IACjC,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,GAAG;AAAA,EAAA,IACD,gBAAgB,wBAAwB,KAAK;AAEjD,QAAM,EAAE,SAAS,KAAK,GAAG,IAAI,WAAW,WAAW;AACnD,QAAM,WAAWA,SAAY;AAE7B,QAAM,SAAS,cAAc,SAAS,YAAY,KAAK,IAAI,CAAC;AAC5D,QAAM,OAAO,cAAc,SAAS,YAAY,GAAG,IAAI,CAAC;AAExD,QAAM,CAAC,eAAe,aAAa,QAAQ,IAAI;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,OAAO,SAAS,IAAI,CAAC,QAAQ,UACjC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI,MAAM,IAAI,QAAQ,KAAK,EAAE;AAAA,MAC7B,SAAS,CAAC,UAAU;AAClB,cAAM,eAAe;AAET,oBAAA,OAAO,OAAO,OAAO,OAAO,MAAM,WAAW,OAAO,KAAK,CAAC;AACtE,kBAAU,OAAO,KA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orizontal.tsx"],"sourcesContent":["import { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { useScrollTo } from \"../hooks/useScrollTo\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvScrollToOption, HvScrollToTooltipPositions } from \"../types/scroll\";\nimport { isKey } from \"../utils/keyboardUtils\";\nimport { setId } from \"../utils/setId\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToOption[];\n /**\n * Should the active element be reflected in the URL.\n *\n * @default true\n *\n * @deprecated Use `navigationMode` instead.\n * */\n href?: boolean;\n /**\n * The navigation mode to be used when the user clicks on a tab element.\n * - `push` will add a new entry to the history stack.\n * - `replace` will replace the current entry on the history stack.\n * - `none` will not add any entry to the history stack.\n *\n * Defaults to `push`, unless the deprecated `href` prop is set to `false`, in which case it defaults to `none`.\n *\n * When set to `none`, then each element will render a button instead of a link.\n *\n * @default \"push\"\n */\n navigationMode?: \"push\" | \"replace\" | \"none\";\n /**\n * When set to `true`, the generated links will be relative (e.g. `#section`).\n * Relative URLs take into account not only the current location, but also the base URL if it is set (i.e. a `<base>` tag).\n * This can lead to unexpected behavior.\n *\n * When set to `false`, the links will be generated from the current location's full URL (e.g. `http://example.com/hello/world?value=123#section`).\n *\n * @default false\n */\n relativeLinks?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (\n event: React.MouseEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (\n event: React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = (props: HvScrollToHorizontalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n // @ts-ignore\n href = true,\n navigationMode = href ? \"push\" : \"none\",\n relativeLinks = false,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n } = useDefaultProps(\"HvScrollToHorizontal\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const [selectedIndex, setScrollTo, elements] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n navigationMode,\n relativeLinks,\n offset,\n options,\n onChange,\n );\n\n const tabs = elements.map((option, index) => (\n <HvHorizontalScrollListItem\n id={setId(id, `item-${index}`)}\n onClick={(event) => {\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") !== true) return;\n event.preventDefault();\n\n setScrollTo(event, option.value, index, () => onChange?.(event, index));\n onEnter?.(event, index);\n }}\n href={navigationMode !== \"none\" ? option.href : undefined}\n tooltipPlacement={tooltipPosition}\n selected={selectedIndex === index}\n key={option.key || option.label}\n label={option.label}\n iconClasses={cx({\n [classes.selected]: selectedIndex === index,\n [classes.notSelected]: selectedIndex !== index,\n [classes.notSelectedRoot]: selectedIndex !== index,\n })}\n />\n ));\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n }),\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n },\n className,\n )}\n id={id}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["useMuiTheme"],"mappings":";;;;;;;;;;;AAsGa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IACJ;AAAA,IACA,uBAAuB;AAAA,IACvB;AAAA;AAAA,IAEA,OAAO;AAAA,IACP,iBAAiB,OAAO,SAAS;AAAA,IACjC,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,SAAS;AAAA,IACT,W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