@backstage/ui 0.0.0-nightly-20250722024836

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 (135) hide show
  1. package/CHANGELOG.md +294 -0
  2. package/README.md +18 -0
  3. package/css/styles.css +10823 -0
  4. package/dist/components/Avatar/Avatar.esm.js +29 -0
  5. package/dist/components/Avatar/Avatar.esm.js.map +1 -0
  6. package/dist/components/Box/Box.esm.js +34 -0
  7. package/dist/components/Box/Box.esm.js.map +1 -0
  8. package/dist/components/Box/Box.props.esm.js +7 -0
  9. package/dist/components/Box/Box.props.esm.js.map +1 -0
  10. package/dist/components/Button/Button.esm.js +41 -0
  11. package/dist/components/Button/Button.esm.js.map +1 -0
  12. package/dist/components/ButtonIcon/ButtonIcon.esm.js +37 -0
  13. package/dist/components/ButtonIcon/ButtonIcon.esm.js.map +1 -0
  14. package/dist/components/ButtonLink/ButtonLink.esm.js +42 -0
  15. package/dist/components/ButtonLink/ButtonLink.esm.js.map +1 -0
  16. package/dist/components/Card/Card.esm.js +53 -0
  17. package/dist/components/Card/Card.esm.js.map +1 -0
  18. package/dist/components/Checkbox/Checkbox.esm.js +74 -0
  19. package/dist/components/Checkbox/Checkbox.esm.js.map +1 -0
  20. package/dist/components/Collapsible/Collapsible.esm.js +50 -0
  21. package/dist/components/Collapsible/Collapsible.esm.js.map +1 -0
  22. package/dist/components/Container/Container.esm.js +35 -0
  23. package/dist/components/Container/Container.esm.js.map +1 -0
  24. package/dist/components/DataTable/DataTable.esm.js +26 -0
  25. package/dist/components/DataTable/DataTable.esm.js.map +1 -0
  26. package/dist/components/DataTable/Pagination/DataTablePagination.esm.js +84 -0
  27. package/dist/components/DataTable/Pagination/DataTablePagination.esm.js.map +1 -0
  28. package/dist/components/DataTable/Root/DataTableRoot.esm.js +24 -0
  29. package/dist/components/DataTable/Root/DataTableRoot.esm.js.map +1 -0
  30. package/dist/components/DataTable/Table/DataTableTable.esm.js +64 -0
  31. package/dist/components/DataTable/Table/DataTableTable.esm.js.map +1 -0
  32. package/dist/components/FieldError/FieldError.esm.js +22 -0
  33. package/dist/components/FieldError/FieldError.esm.js.map +1 -0
  34. package/dist/components/FieldLabel/FieldLabel.esm.js +27 -0
  35. package/dist/components/FieldLabel/FieldLabel.esm.js.map +1 -0
  36. package/dist/components/Flex/Flex.esm.js +26 -0
  37. package/dist/components/Flex/Flex.esm.js.map +1 -0
  38. package/dist/components/Flex/Flex.props.esm.js +31 -0
  39. package/dist/components/Flex/Flex.props.esm.js.map +1 -0
  40. package/dist/components/Grid/Grid.esm.js +43 -0
  41. package/dist/components/Grid/Grid.esm.js.map +1 -0
  42. package/dist/components/Grid/Grid.props.esm.js +58 -0
  43. package/dist/components/Grid/Grid.props.esm.js.map +1 -0
  44. package/dist/components/Header/Header.esm.js +27 -0
  45. package/dist/components/Header/Header.esm.js.map +1 -0
  46. package/dist/components/Header/HeaderToolbar.esm.js +121 -0
  47. package/dist/components/Header/HeaderToolbar.esm.js.map +1 -0
  48. package/dist/components/HeaderPage/HeaderPage.esm.js +48 -0
  49. package/dist/components/HeaderPage/HeaderPage.esm.js.map +1 -0
  50. package/dist/components/Heading/Heading.esm.js +37 -0
  51. package/dist/components/Heading/Heading.esm.js.map +1 -0
  52. package/dist/components/Icon/Icon.esm.js +29 -0
  53. package/dist/components/Icon/Icon.esm.js.map +1 -0
  54. package/dist/components/Icon/context.esm.js +10 -0
  55. package/dist/components/Icon/context.esm.js.map +1 -0
  56. package/dist/components/Icon/icons.esm.js +63 -0
  57. package/dist/components/Icon/icons.esm.js.map +1 -0
  58. package/dist/components/Icon/provider.esm.js +12 -0
  59. package/dist/components/Icon/provider.esm.js.map +1 -0
  60. package/dist/components/Link/Link.esm.js +63 -0
  61. package/dist/components/Link/Link.esm.js.map +1 -0
  62. package/dist/components/Menu/Combobox.esm.js +212 -0
  63. package/dist/components/Menu/Combobox.esm.js.map +1 -0
  64. package/dist/components/Menu/Menu.esm.js +224 -0
  65. package/dist/components/Menu/Menu.esm.js.map +1 -0
  66. package/dist/components/RadioGroup/RadioGroup.esm.js +71 -0
  67. package/dist/components/RadioGroup/RadioGroup.esm.js.map +1 -0
  68. package/dist/components/ScrollArea/ScrollArea.esm.js +63 -0
  69. package/dist/components/ScrollArea/ScrollArea.esm.js.map +1 -0
  70. package/dist/components/SearchField/SearchField.esm.js +107 -0
  71. package/dist/components/SearchField/SearchField.esm.js.map +1 -0
  72. package/dist/components/Select/Select.esm.js +89 -0
  73. package/dist/components/Select/Select.esm.js.map +1 -0
  74. package/dist/components/Select/Select.styles.css.esm.js +7 -0
  75. package/dist/components/Select/Select.styles.css.esm.js.map +1 -0
  76. package/dist/components/Skeleton/Skeleton.esm.js +22 -0
  77. package/dist/components/Skeleton/Skeleton.esm.js.map +1 -0
  78. package/dist/components/Switch/Switch.esm.js +18 -0
  79. package/dist/components/Switch/Switch.esm.js.map +1 -0
  80. package/dist/components/Table/Table.esm.js +68 -0
  81. package/dist/components/Table/Table.esm.js.map +1 -0
  82. package/dist/components/Table/TableCell/TableCell.esm.js +13 -0
  83. package/dist/components/Table/TableCell/TableCell.esm.js.map +1 -0
  84. package/dist/components/Table/TableCellLink/TableCellLink.esm.js +28 -0
  85. package/dist/components/Table/TableCellLink/TableCellLink.esm.js.map +1 -0
  86. package/dist/components/Table/TableCellProfile/TableCellProfile.esm.js +40 -0
  87. package/dist/components/Table/TableCellProfile/TableCellProfile.esm.js.map +1 -0
  88. package/dist/components/Table/TableCellText/TableCellText.esm.js +27 -0
  89. package/dist/components/Table/TableCellText/TableCellText.esm.js.map +1 -0
  90. package/dist/components/Tabs/Tabs.esm.js +127 -0
  91. package/dist/components/Tabs/Tabs.esm.js.map +1 -0
  92. package/dist/components/Tabs/TabsIndicators.esm.js +140 -0
  93. package/dist/components/Tabs/TabsIndicators.esm.js.map +1 -0
  94. package/dist/components/Text/Text.esm.js +39 -0
  95. package/dist/components/Text/Text.esm.js.map +1 -0
  96. package/dist/components/TextField/TextField.esm.js +88 -0
  97. package/dist/components/TextField/TextField.esm.js.map +1 -0
  98. package/dist/components/Tooltip/Tooltip.esm.js +31 -0
  99. package/dist/components/Tooltip/Tooltip.esm.js.map +1 -0
  100. package/dist/hooks/useBreakpoint.esm.js +43 -0
  101. package/dist/hooks/useBreakpoint.esm.js.map +1 -0
  102. package/dist/hooks/useIsomorphicLayoutEffect.esm.js +6 -0
  103. package/dist/hooks/useIsomorphicLayoutEffect.esm.js.map +1 -0
  104. package/dist/hooks/useMediaQuery.esm.js +44 -0
  105. package/dist/hooks/useMediaQuery.esm.js.map +1 -0
  106. package/dist/hooks/useStyles.esm.js +46 -0
  107. package/dist/hooks/useStyles.esm.js.map +1 -0
  108. package/dist/index.d.ts +1399 -0
  109. package/dist/index.esm.js +40 -0
  110. package/dist/index.esm.js.map +1 -0
  111. package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js +29 -0
  112. package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js.map +1 -0
  113. package/dist/props/display.props.esm.js +12 -0
  114. package/dist/props/display.props.esm.js.map +1 -0
  115. package/dist/props/gap-props.esm.js +15 -0
  116. package/dist/props/gap-props.esm.js.map +1 -0
  117. package/dist/props/height.props.esm.js +23 -0
  118. package/dist/props/height.props.esm.js.map +1 -0
  119. package/dist/props/margin.props.esm.js +54 -0
  120. package/dist/props/margin.props.esm.js.map +1 -0
  121. package/dist/props/padding.props.esm.js +54 -0
  122. package/dist/props/padding.props.esm.js.map +1 -0
  123. package/dist/props/position.props.esm.js +18 -0
  124. package/dist/props/position.props.esm.js.map +1 -0
  125. package/dist/props/prop-def.esm.js +4 -0
  126. package/dist/props/prop-def.esm.js.map +1 -0
  127. package/dist/props/spacing.props.esm.js +28 -0
  128. package/dist/props/spacing.props.esm.js.map +1 -0
  129. package/dist/props/width.props.esm.js +23 -0
  130. package/dist/props/width.props.esm.js.map +1 -0
  131. package/dist/utils/componentDefinitions.esm.js +272 -0
  132. package/dist/utils/componentDefinitions.esm.js.map +1 -0
  133. package/dist/utils/extractProps.esm.js +49 -0
  134. package/dist/utils/extractProps.esm.js.map +1 -0
  135. package/package.json +93 -0
@@ -0,0 +1,22 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useStyles } from '../../hooks/useStyles.esm.js';
3
+
4
+ const Skeleton = (props) => {
5
+ const { width = 80, height = 24, rounded = false, ...rest } = props;
6
+ const { classNames } = useStyles("Skeleton");
7
+ return /* @__PURE__ */ jsx(
8
+ "div",
9
+ {
10
+ className: classNames.root,
11
+ "data-rounded": rounded,
12
+ style: {
13
+ width,
14
+ height
15
+ },
16
+ ...rest
17
+ }
18
+ );
19
+ };
20
+
21
+ export { Skeleton };
22
+ //# sourceMappingURL=Skeleton.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.esm.js","sources":["../../../src/components/Skeleton/Skeleton.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useStyles } from '../../hooks/useStyles';\nimport { SkeletonProps } from './types';\n\n/** @public */\nexport const Skeleton = (props: SkeletonProps) => {\n const { width = 80, height = 24, rounded = false, ...rest } = props;\n const { classNames } = useStyles('Skeleton');\n\n return (\n <div\n className={classNames.root}\n data-rounded={rounded}\n style={{\n width,\n height,\n }}\n {...rest}\n />\n );\n};\n"],"names":[],"mappings":";;;AAoBa,MAAA,QAAA,GAAW,CAAC,KAAyB,KAAA;AAChD,EAAM,MAAA,EAAE,QAAQ,EAAI,EAAA,MAAA,GAAS,IAAI,OAAU,GAAA,KAAA,EAAO,GAAG,IAAA,EAAS,GAAA,KAAA;AAC9D,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,UAAU,CAAA;AAE3C,EACE,uBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAW,UAAW,CAAA,IAAA;AAAA,MACtB,cAAc,EAAA,OAAA;AAAA,MACd,KAAO,EAAA;AAAA,QACL,KAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
@@ -0,0 +1,18 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import { Switch as Switch$1 } from 'react-aria-components';
4
+ import { useStyles } from '../../hooks/useStyles.esm.js';
5
+
6
+ const Switch = forwardRef(
7
+ ({ label, ...props }, ref) => {
8
+ const { classNames } = useStyles("Switch");
9
+ return /* @__PURE__ */ jsxs(Switch$1, { className: classNames.root, ref, ...props, children: [
10
+ /* @__PURE__ */ jsx("div", { className: classNames.indicator }),
11
+ label
12
+ ] });
13
+ }
14
+ );
15
+ Switch.displayName = "Switch";
16
+
17
+ export { Switch };
18
+ //# sourceMappingURL=Switch.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.esm.js","sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport { Switch as AriaSwitch } from 'react-aria-components';\nimport type { SwitchProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\n\n/** @public */\nexport const Switch = forwardRef<HTMLLabelElement, SwitchProps>(\n ({ label, ...props }, ref) => {\n const { classNames } = useStyles('Switch');\n\n return (\n <AriaSwitch className={classNames.root} ref={ref} {...props}>\n <div className={classNames.indicator} />\n {label}\n </AriaSwitch>\n );\n },\n);\n\nSwitch.displayName = 'Switch';\n"],"names":["AriaSwitch"],"mappings":";;;;;AAsBO,MAAM,MAAS,GAAA,UAAA;AAAA,EACpB,CAAC,EAAE,KAAA,EAAO,GAAG,KAAA,IAAS,GAAQ,KAAA;AAC5B,IAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,QAAQ,CAAA;AAEzC,IAAA,4BACGA,QAAW,EAAA,EAAA,SAAA,EAAW,WAAW,IAAM,EAAA,GAAA,EAAW,GAAG,KACpD,EAAA,QAAA,EAAA;AAAA,sBAAC,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,UAAA,CAAW,SAAW,EAAA,CAAA;AAAA,MACrC;AAAA,KACH,EAAA,CAAA;AAAA;AAGN;AAEA,MAAA,CAAO,WAAc,GAAA,QAAA;;;;"}
@@ -0,0 +1,68 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import { TableCell } from './TableCell/TableCell.esm.js';
5
+ import { TableCellText } from './TableCellText/TableCellText.esm.js';
6
+ import { TableCellLink } from './TableCellLink/TableCellLink.esm.js';
7
+ import { TableCellProfile } from './TableCellProfile/TableCellProfile.esm.js';
8
+ import { useStyles } from '../../hooks/useStyles.esm.js';
9
+
10
+ const TableRoot = forwardRef(({ className, ...props }, ref) => {
11
+ const { classNames } = useStyles("Table");
12
+ return /* @__PURE__ */ jsx("table", { ref, className: clsx(classNames.root, className), ...props });
13
+ });
14
+ TableRoot.displayName = "TableRoot";
15
+ const TableHeader = forwardRef(({ className, ...props }, ref) => {
16
+ const { classNames } = useStyles("Table");
17
+ return /* @__PURE__ */ jsx(
18
+ "thead",
19
+ {
20
+ ref,
21
+ className: clsx(classNames.header, className),
22
+ ...props
23
+ }
24
+ );
25
+ });
26
+ TableHeader.displayName = "TableHeader";
27
+ const TableBody = forwardRef(({ className, ...props }, ref) => {
28
+ const { classNames } = useStyles("Table");
29
+ return /* @__PURE__ */ jsx("tbody", { ref, className: clsx(classNames.body, className), ...props });
30
+ });
31
+ TableBody.displayName = "TableBody";
32
+ const TableRow = forwardRef(({ className, ...props }, ref) => {
33
+ const { classNames } = useStyles("Table");
34
+ return /* @__PURE__ */ jsx("tr", { ref, className: clsx(classNames.row, className), ...props, children: props.children });
35
+ });
36
+ TableRow.displayName = "TableRow";
37
+ const TableHead = forwardRef(({ className, ...props }, ref) => {
38
+ const { classNames } = useStyles("Table");
39
+ return /* @__PURE__ */ jsx("th", { ref, className: clsx(classNames.head, className), ...props });
40
+ });
41
+ TableHead.displayName = "TableHead";
42
+ const TableCaption = forwardRef(({ className, ...props }, ref) => {
43
+ const { classNames } = useStyles("Table");
44
+ return /* @__PURE__ */ jsx(
45
+ "caption",
46
+ {
47
+ ref,
48
+ className: clsx(classNames.caption, className),
49
+ ...props
50
+ }
51
+ );
52
+ });
53
+ TableCaption.displayName = "TableCaption";
54
+ const Table = {
55
+ Root: TableRoot,
56
+ Header: TableHeader,
57
+ Body: TableBody,
58
+ Head: TableHead,
59
+ Row: TableRow,
60
+ Cell: TableCell,
61
+ CellText: TableCellText,
62
+ CellLink: TableCellLink,
63
+ CellProfile: TableCellProfile,
64
+ Caption: TableCaption
65
+ };
66
+
67
+ export { Table };
68
+ //# sourceMappingURL=Table.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.esm.js","sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport { TableCell } from './TableCell/TableCell';\nimport { TableCellText } from './TableCellText/TableCellText';\nimport { TableCellLink } from './TableCellLink/TableCellLink';\nimport { TableCellProfile } from './TableCellProfile/TableCellProfile';\nimport { useStyles } from '../../hooks/useStyles';\n\nconst TableRoot = forwardRef<\n HTMLTableElement,\n React.HTMLAttributes<HTMLTableElement>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <table ref={ref} className={clsx(classNames.root, className)} {...props} />\n );\n});\nTableRoot.displayName = 'TableRoot';\n\nconst TableHeader = forwardRef<\n HTMLTableSectionElement,\n React.HTMLAttributes<HTMLTableSectionElement>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <thead\n ref={ref}\n className={clsx(classNames.header, className)}\n {...props}\n />\n );\n});\nTableHeader.displayName = 'TableHeader';\n\nconst TableBody = forwardRef<\n HTMLTableSectionElement,\n React.HTMLAttributes<HTMLTableSectionElement>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <tbody ref={ref} className={clsx(classNames.body, className)} {...props} />\n );\n});\nTableBody.displayName = 'TableBody';\n\nconst TableRow = forwardRef<\n HTMLTableRowElement,\n React.HTMLAttributes<HTMLTableRowElement>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <tr ref={ref} className={clsx(classNames.row, className)} {...props}>\n {props.children}\n </tr>\n );\n});\nTableRow.displayName = 'TableRow';\n\nconst TableHead = forwardRef<\n HTMLTableCellElement,\n React.ThHTMLAttributes<HTMLTableCellElement>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <th ref={ref} className={clsx(classNames.head, className)} {...props} />\n );\n});\nTableHead.displayName = 'TableHead';\n\nconst TableCaption = forwardRef<\n HTMLTableCaptionElement,\n React.HTMLAttributes<HTMLTableCaptionElement>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <caption\n ref={ref}\n className={clsx(classNames.caption, className)}\n {...props}\n />\n );\n});\nTableCaption.displayName = 'TableCaption';\n\n/**\n * Table component for displaying tabular data\n * @public\n */\nexport const Table = {\n Root: TableRoot,\n Header: TableHeader,\n Body: TableBody,\n Head: TableHead,\n Row: TableRow,\n Cell: TableCell,\n CellText: TableCellText,\n CellLink: TableCellLink,\n CellProfile: TableCellProfile,\n Caption: TableCaption,\n};\n"],"names":[],"mappings":";;;;;;;;;AAwBA,MAAM,SAAA,GAAY,WAGhB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,OAAO,CAAA;AAExC,EACE,uBAAA,GAAA,CAAC,OAAM,EAAA,EAAA,GAAA,EAAU,SAAW,EAAA,IAAA,CAAK,WAAW,IAAM,EAAA,SAAS,CAAI,EAAA,GAAG,KAAO,EAAA,CAAA;AAE7E,CAAC,CAAA;AACD,SAAA,CAAU,WAAc,GAAA,WAAA;AAExB,MAAM,WAAA,GAAc,WAGlB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,OAAO,CAAA;AAExC,EACE,uBAAA,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,MAAA,EAAQ,SAAS,CAAA;AAAA,MAC3C,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC,CAAA;AACD,WAAA,CAAY,WAAc,GAAA,aAAA;AAE1B,MAAM,SAAA,GAAY,WAGhB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,E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AAA,EAAS,SAAS,CAAA;AAAA,MAC5C,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC,CAAA;AACD,YAAA,CAAa,WAAc,GAAA,cAAA;AAMpB,MAAM,KAAQ,GAAA;AAAA,EACnB,IAAM,EAAA,SAAA;AAAA,EACN,MAAQ,EAAA,WAAA;AAAA,EACR,IAAM,EAAA,SAAA;AAAA,EACN,IAAM,EAAA,SAAA;AAAA,EACN,GAAK,EAAA,QAAA;AAAA,EACL,IAAM,EAAA,SAAA;AAAA,EACN,QAAU,EAAA,aAAA;AAAA,EACV,QAAU,EAAA,aAAA;AAAA,EACV,WAAa,EAAA,gBAAA;AAAA,EACb,OAAS,EAAA;AACX;;;;"}
@@ -0,0 +1,13 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import { useStyles } from '../../../hooks/useStyles.esm.js';
5
+
6
+ const TableCell = forwardRef(({ className, ...props }, ref) => {
7
+ const { classNames } = useStyles("Table");
8
+ return /* @__PURE__ */ jsx("td", { ref, className: clsx(classNames.cell, className), ...props });
9
+ });
10
+ TableCell.displayName = "TableCell";
11
+
12
+ export { TableCell };
13
+ //# sourceMappingURL=TableCell.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableCell.esm.js","sources":["../../../../src/components/Table/TableCell/TableCell.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport { useStyles } from '../../../hooks/useStyles';\n\n/** @public */\nconst TableCell = forwardRef<\n HTMLTableCellElement,\n React.TdHTMLAttributes<HTMLTableCellElement>\n>(({ className, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <td ref={ref} className={clsx(classNames.cell, className)} {...props} />\n );\n});\nTableCell.displayName = 'TableCell';\n\nexport { TableCell };\n"],"names":[],"mappings":";;;;;AAqBM,MAAA,SAAA,GAAY,WAGhB,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAQ,KAAA;AAClC,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,OAAO,CAAA;AAExC,EACE,uBAAA,GAAA,CAAC,IAAG,EAAA,EAAA,GAAA,EAAU,SAAW,EAAA,IAAA,CAAK,WAAW,IAAM,EAAA,SAAS,CAAI,EAAA,GAAG,KAAO,EAAA,CAAA;AAE1E,CAAC;AACD,SAAA,CAAU,WAAc,GAAA,WAAA;;;;"}
@@ -0,0 +1,28 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import { Text } from '../../Text/Text.esm.js';
5
+ import { Link } from '../../Link/Link.esm.js';
6
+ import { useStyles } from '../../../hooks/useStyles.esm.js';
7
+
8
+ const TableCellLink = forwardRef(
9
+ ({ className, title, description, href, render, ...props }, ref) => {
10
+ const { classNames } = useStyles("Table");
11
+ return /* @__PURE__ */ jsxs(
12
+ "div",
13
+ {
14
+ ref,
15
+ className: clsx(classNames.cellLink, className),
16
+ ...props,
17
+ children: [
18
+ title && /* @__PURE__ */ jsx(Link, { href, children: title }),
19
+ description && /* @__PURE__ */ jsx(Text, { variant: "body", color: "secondary", children: description })
20
+ ]
21
+ }
22
+ );
23
+ }
24
+ );
25
+ TableCellLink.displayName = "TableCellLink";
26
+
27
+ export { TableCellLink };
28
+ //# sourceMappingURL=TableCellLink.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableCellLink.esm.js","sources":["../../../../src/components/Table/TableCellLink/TableCellLink.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport { TableCellLinkProps } from './types';\nimport { Text } from '../../Text/Text';\nimport { Link } from '../../Link/Link';\nimport { useStyles } from '../../../hooks/useStyles';\n\n/** @public */\nconst TableCellLink = forwardRef<HTMLDivElement, TableCellLinkProps>(\n ({ className, title, description, href, render, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <div\n ref={ref}\n className={clsx(classNames.cellLink, className)}\n {...props}\n >\n {title && <Link href={href}>{title}</Link>}\n {description && (\n <Text variant=\"body\" color=\"secondary\">\n {description}\n </Text>\n )}\n </div>\n );\n },\n);\nTableCellLink.displayName = 'TableCellLink';\n\nexport { TableCellLink };\n"],"names":[],"mappings":";;;;;;;AAwBA,MAAM,aAAgB,GAAA,UAAA;AAAA,EACpB,CAAC,EAAE,SAAA,EAAW,KAAO,EAAA,WAAA,EAAa,MAAM,MAAQ,EAAA,GAAG,KAAM,EAAA,EAAG,GAAQ,KAAA;AAClE,IAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,OAAO,CAAA;AAExC,IACE,uBAAA,IAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,QAAA,EAAU,SAAS,CAAA;AAAA,QAC7C,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAS,KAAA,oBAAA,GAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAa,QAAM,EAAA,KAAA,EAAA,CAAA;AAAA,UAClC,+BACE,GAAA,CAAA,IAAA,EAAA,EAAK,SAAQ,MAAO,EAAA,KAAA,EAAM,aACxB,QACH,EAAA,WAAA,EAAA;AAAA;AAAA;AAAA,KAEJ;AAAA;AAGN;AACA,aAAA,CAAc,WAAc,GAAA,eAAA;;;;"}
@@ -0,0 +1,40 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import { Text } from '../../Text/Text.esm.js';
5
+ import { Link } from '../../Link/Link.esm.js';
6
+ import { Avatar } from '@base-ui-components/react/avatar';
7
+ import { useStyles } from '../../../hooks/useStyles.esm.js';
8
+
9
+ const TableCellProfile = forwardRef(
10
+ ({ className, src, name, to, withImage = true, ...rest }, ref) => {
11
+ const { classNames } = useStyles("Table");
12
+ return /* @__PURE__ */ jsxs(
13
+ "div",
14
+ {
15
+ ref,
16
+ className: clsx(classNames.cellProfile, className),
17
+ ...rest,
18
+ children: [
19
+ withImage && /* @__PURE__ */ jsxs(Avatar.Root, { className: classNames.cellProfileAvatar, children: [
20
+ /* @__PURE__ */ jsx(
21
+ Avatar.Image,
22
+ {
23
+ src,
24
+ width: "20",
25
+ height: "20",
26
+ className: classNames.cellProfileAvatarImage
27
+ }
28
+ ),
29
+ /* @__PURE__ */ jsx(Avatar.Fallback, { className: classNames.cellProfileAvatarFallback, children: (name || "").split(" ").map((word) => word[0]).join("").toLocaleUpperCase("en-US").slice(0, 1) })
30
+ ] }),
31
+ name && to ? /* @__PURE__ */ jsx(Link, { href: to, children: name }) : /* @__PURE__ */ jsx(Text, { variant: "body", children: name })
32
+ ]
33
+ }
34
+ );
35
+ }
36
+ );
37
+ TableCellProfile.displayName = "TableCellProfile";
38
+
39
+ export { TableCellProfile };
40
+ //# sourceMappingURL=TableCellProfile.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableCellProfile.esm.js","sources":["../../../../src/components/Table/TableCellProfile/TableCellProfile.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport { TableCellProfileProps } from './types';\nimport { Text } from '../../Text/Text';\nimport { Link } from '../../Link/Link';\nimport { Avatar } from '@base-ui-components/react/avatar';\nimport { useStyles } from '../../../hooks/useStyles';\n\n/** @public */\nconst TableCellProfile = forwardRef<HTMLDivElement, TableCellProfileProps>(\n ({ className, src, name, to, withImage = true, ...rest }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <div\n ref={ref}\n className={clsx(classNames.cellProfile, className)}\n {...rest}\n >\n {withImage && (\n <Avatar.Root className={classNames.cellProfileAvatar}>\n <Avatar.Image\n src={src}\n width=\"20\"\n height=\"20\"\n className={classNames.cellProfileAvatarImage}\n />\n <Avatar.Fallback className={classNames.cellProfileAvatarFallback}>\n {(name || '')\n .split(' ')\n .map(word => word[0])\n .join('')\n .toLocaleUpperCase('en-US')\n .slice(0, 1)}\n </Avatar.Fallback>\n </Avatar.Root>\n )}\n {name && to ? (\n <Link href={to}>{name}</Link>\n ) : (\n <Text variant=\"body\">{name}</Text>\n )}\n </div>\n );\n },\n);\nTableCellProfile.displayName = 'TableCellProfile';\n\nexport { TableCellProfile };\n"],"names":[],"mappings":";;;;;;;;AAyBA,MAAM,gBAAmB,GAAA,UAAA;AAAA,EACvB,CAAC,EAAE,SAAA,EAAW,GAAK,EAAA,IAAA,EAAM,EAAI,EAAA,SAAA,GAAY,IAAM,EAAA,GAAG,IAAK,EAAA,EAAG,GAAQ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x } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import { Text } from '../../Text/Text.esm.js';
5
+ import { useStyles } from '../../../hooks/useStyles.esm.js';
6
+
7
+ const TableCellText = forwardRef(
8
+ ({ className, title, description, ...props }, ref) => {
9
+ const { classNames } = useStyles("Table");
10
+ return /* @__PURE__ */ jsxs(
11
+ "div",
12
+ {
13
+ ref,
14
+ className: clsx(classNames.cellText, className),
15
+ ...props,
16
+ children: [
17
+ title && /* @__PURE__ */ jsx(Text, { variant: "body", children: title }),
18
+ description && /* @__PURE__ */ jsx(Text, { variant: "body", color: "secondary", children: description })
19
+ ]
20
+ }
21
+ );
22
+ }
23
+ );
24
+ TableCellText.displayName = "TableCellText";
25
+
26
+ export { TableCellText };
27
+ //# sourceMappingURL=TableCellText.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableCellText.esm.js","sources":["../../../../src/components/Table/TableCellText/TableCellText.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport { TableCellTextProps } from './types';\nimport { Text } from '../../Text/Text';\nimport { useStyles } from '../../../hooks/useStyles';\n\n/** @public */\nconst TableCellText = forwardRef<HTMLDivElement, TableCellTextProps>(\n ({ className, title, description, ...props }, ref) => {\n const { classNames } = useStyles('Table');\n\n return (\n <div\n ref={ref}\n className={clsx(classNames.cellText, className)}\n {...props}\n >\n {title && <Text variant=\"body\">{title}</Text>}\n {description && (\n <Text variant=\"body\" color=\"secondary\">\n {description}\n </Text>\n )}\n </div>\n );\n },\n);\nTableCellText.displayName = 'TableCellText';\n\nexport { TableCellText };\n"],"names":[],"mappings":";;;;;;AAuBA,MAAM,aAAgB,GAAA,UAAA;AAAA,EACpB,CAAC,EAAE,SAAW,EAAA,KAAA,EAAO,aAAa,GAAG,KAAA,IAAS,GAAQ,KAAA;AACpD,IAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,OAAO,CAAA;AAExC,IACE,uBAAA,IAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,QAAA,EAAU,SAAS,CAAA;AAAA,QAC7C,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,KAAA,oBAAU,GAAA,CAAA,IAAA,EAAA,EAAK,OAAQ,EAAA,MAAA,EAAQ,QAAM,EAAA,KAAA,EAAA,CAAA;AAAA,UACrC,+BACE,GAAA,CAAA,IAAA,EAAA,EAAK,SAAQ,MAAO,EAAA,KAAA,EAAM,aACxB,QACH,EAAA,WAAA,EAAA;AAAA;AAAA;AAAA,KAEJ;AAAA;AAGN;AACA,aAAA,CAAc,WAAc,GAAA,eAAA;;;;"}
@@ -0,0 +1,127 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { createContext, useRef, useState, Children, isValidElement, cloneElement, useContext } from 'react';
3
+ import { useNavigate, useLocation, useHref } from 'react-router-dom';
4
+ import { TabsIndicators } from './TabsIndicators.esm.js';
5
+ import { RouterProvider, Tabs as Tabs$1, TabList as TabList$1, Tab as Tab$1, TabPanel as TabPanel$1 } from 'react-aria-components';
6
+ import { useStyles } from '../../hooks/useStyles.esm.js';
7
+
8
+ const TabsContext = createContext(void 0);
9
+ const useTabsContext = () => {
10
+ const context = useContext(TabsContext);
11
+ if (!context) {
12
+ throw new Error("Tab components must be used within a Tabs component");
13
+ }
14
+ return context;
15
+ };
16
+ const Tabs = (props) => {
17
+ const { children, ...rest } = props;
18
+ const { classNames } = useStyles("Tabs");
19
+ const tabsRef = useRef(null);
20
+ const tabRefs = useRef(/* @__PURE__ */ new Map());
21
+ const [hoveredKey, setHoveredKey] = useState(null);
22
+ const prevHoveredKey = useRef(null);
23
+ let navigate = useNavigate();
24
+ const location = useLocation();
25
+ const setTabRef = (key, element) => {
26
+ if (element) {
27
+ tabRefs.current.set(key, element);
28
+ } else {
29
+ tabRefs.current.delete(key);
30
+ }
31
+ };
32
+ const computedSelectedKey = (() => {
33
+ const childrenArray = Children.toArray(children);
34
+ for (const child of childrenArray) {
35
+ if (isValidElement(child) && child.type === TabList) {
36
+ const tabListChildren = Children.toArray(child.props.children);
37
+ for (const tabChild of tabListChildren) {
38
+ if (isValidElement(tabChild) && tabChild.props.href === location.pathname) {
39
+ return tabChild.props.id;
40
+ }
41
+ }
42
+ }
43
+ }
44
+ return void 0;
45
+ })();
46
+ if (!children) return null;
47
+ const contextValue = {
48
+ tabsRef,
49
+ tabRefs,
50
+ hoveredKey,
51
+ prevHoveredKey,
52
+ setHoveredKey,
53
+ setTabRef
54
+ };
55
+ return /* @__PURE__ */ jsx(TabsContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(RouterProvider, { navigate, useHref, children: /* @__PURE__ */ jsx(
56
+ Tabs$1,
57
+ {
58
+ className: classNames.tabs,
59
+ keyboardActivation: "manual",
60
+ selectedKey: computedSelectedKey,
61
+ ref: tabsRef,
62
+ ...rest,
63
+ children
64
+ }
65
+ ) }) });
66
+ };
67
+ const TabList = (props) => {
68
+ const { children, ...rest } = props;
69
+ const { classNames } = useStyles("Tabs");
70
+ const { setHoveredKey, tabRefs, tabsRef, hoveredKey, prevHoveredKey } = useTabsContext();
71
+ const handleHover = (key) => {
72
+ setHoveredKey(key);
73
+ };
74
+ const enhancedChildren = Children.map(children, (child) => {
75
+ if (isValidElement(child)) {
76
+ return cloneElement(child, {
77
+ onHoverStart: () => handleHover(child.props.id),
78
+ onHoverEnd: () => handleHover(null)
79
+ });
80
+ }
81
+ return child;
82
+ });
83
+ return /* @__PURE__ */ jsxs("div", { className: classNames.tabListWrapper, children: [
84
+ /* @__PURE__ */ jsx(
85
+ TabList$1,
86
+ {
87
+ className: classNames.tabList,
88
+ "aria-label": "Toolbar tabs",
89
+ ...rest,
90
+ children: enhancedChildren
91
+ }
92
+ ),
93
+ /* @__PURE__ */ jsx(
94
+ TabsIndicators,
95
+ {
96
+ tabRefs,
97
+ tabsRef,
98
+ hoveredKey,
99
+ prevHoveredKey
100
+ }
101
+ )
102
+ ] });
103
+ };
104
+ const Tab = (props) => {
105
+ const { href, children, id, ...rest } = props;
106
+ const { classNames } = useStyles("Tabs");
107
+ const { setTabRef } = useTabsContext();
108
+ return /* @__PURE__ */ jsx(
109
+ Tab$1,
110
+ {
111
+ id,
112
+ className: classNames.tab,
113
+ ref: (el) => setTabRef(id, el),
114
+ href,
115
+ ...rest,
116
+ children
117
+ }
118
+ );
119
+ };
120
+ const TabPanel = (props) => {
121
+ const { children, ...rest } = props;
122
+ const { classNames } = useStyles("Tabs");
123
+ return /* @__PURE__ */ jsx(TabPanel$1, { className: classNames.panel, ...rest, children });
124
+ };
125
+
126
+ export { Tab, TabList, TabPanel, Tabs };
127
+ //# sourceMappingURL=Tabs.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.esm.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useRef,\n useState,\n Children,\n cloneElement,\n isValidElement,\n ReactNode,\n createContext,\n useContext,\n} from 'react';\nimport type {\n TabsProps,\n TabListProps,\n TabPanelProps,\n TabsContextValue,\n} from './types';\nimport { useLocation, useNavigate, useHref } from 'react-router-dom';\nimport { TabsIndicators } from './TabsIndicators';\nimport {\n Tabs as AriaTabs,\n TabList as AriaTabList,\n Tab as AriaTab,\n TabPanel as AriaTabPanel,\n RouterProvider,\n TabProps as AriaTabProps,\n} from 'react-aria-components';\n\nimport { useStyles } from '../../hooks/useStyles';\n\nconst TabsContext = createContext<TabsContextValue | undefined>(undefined);\n\nconst useTabsContext = () => {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error('Tab components must be used within a Tabs component');\n }\n return context;\n};\n\n/**\n * A component that renders a list of tabs.\n *\n * @public\n */\nexport const Tabs = (props: TabsProps) => {\n const { children, ...rest } = props;\n const { classNames } = useStyles('Tabs');\n const tabsRef = useRef<HTMLDivElement>(null);\n const tabRefs = useRef<Map<string, HTMLDivElement>>(new Map());\n const [hoveredKey, setHoveredKey] = useState<string | null>(null);\n const prevHoveredKey = useRef<string | null>(null);\n let navigate = useNavigate();\n const location = useLocation();\n\n const setTabRef = (key: string, element: HTMLDivElement | null) => {\n if (element) {\n tabRefs.current.set(key, element);\n } else {\n tabRefs.current.delete(key);\n }\n };\n\n // If selectedKey is not provided, try to determine it from the current route\n const computedSelectedKey = (() => {\n const childrenArray = Children.toArray(children as ReactNode);\n for (const child of childrenArray) {\n if (isValidElement(child) && child.type === TabList) {\n const tabListChildren = Children.toArray(child.props.children);\n for (const tabChild of tabListChildren) {\n if (\n isValidElement(tabChild) &&\n tabChild.props.href === location.pathname\n ) {\n return tabChild.props.id;\n }\n }\n }\n }\n return undefined;\n })();\n\n if (!children) return null;\n\n const contextValue: TabsContextValue = {\n tabsRef,\n tabRefs,\n hoveredKey,\n prevHoveredKey,\n setHoveredKey,\n setTabRef,\n };\n\n return (\n <TabsContext.Provider value={contextValue}>\n <RouterProvider navigate={navigate} useHref={useHref}>\n <AriaTabs\n className={classNames.tabs}\n keyboardActivation=\"manual\"\n selectedKey={computedSelectedKey}\n ref={tabsRef}\n {...rest}\n >\n {children as ReactNode}\n </AriaTabs>\n </RouterProvider>\n </TabsContext.Provider>\n );\n};\n\n/**\n * A component that renders a list of tabs.\n *\n * @public\n */\nexport const TabList = (props: TabListProps) => {\n const { children, ...rest } = props;\n const { classNames } = useStyles('Tabs');\n const { setHoveredKey, tabRefs, tabsRef, hoveredKey, prevHoveredKey } =\n useTabsContext();\n\n const handleHover = (key: string | null) => {\n setHoveredKey(key);\n };\n\n // Clone children with additional props for hover and ref management\n const enhancedChildren = Children.map(children as ReactNode, child => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n onHoverStart: () => handleHover(child.props.id as string),\n onHoverEnd: () => handleHover(null),\n } as Partial<AriaTabProps>);\n }\n return child;\n });\n\n return (\n <div className={classNames.tabListWrapper}>\n <AriaTabList\n className={classNames.tabList}\n aria-label=\"Toolbar tabs\"\n {...rest}\n >\n {enhancedChildren}\n </AriaTabList>\n <TabsIndicators\n tabRefs={tabRefs}\n tabsRef={tabsRef}\n hoveredKey={hoveredKey}\n prevHoveredKey={prevHoveredKey}\n />\n </div>\n );\n};\n\n/**\n * A component that renders a tab.\n *\n * @public\n */\nexport const Tab = (props: AriaTabProps) => {\n const { href, children, id, ...rest } = props;\n const { classNames } = useStyles('Tabs');\n const { setTabRef } = useTabsContext();\n\n return (\n <AriaTab\n id={id}\n className={classNames.tab}\n ref={el => setTabRef(id as string, el as HTMLDivElement)}\n href={href}\n {...rest}\n >\n {children}\n </AriaTab>\n );\n};\n\n/**\n * A component that renders the content of a tab.\n *\n * @public\n */\nexport const TabPanel = (props: TabPanelProps) => {\n const { children, ...rest } = props;\n const { classNames } = useStyles('Tabs');\n\n return (\n <AriaTabPanel className={classNames.panel} {...rest}>\n {children}\n </AriaTabPanel>\n );\n};\n"],"names":["AriaTabs","AriaTabList","AriaTab","AriaTabPanel"],"mappings":";;;;;;;AA6CA,MAAM,WAAA,GAAc,cAA4C,KAA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ACvD,IAAA;AAAA,MACC,GAAG,IAAA;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ;AAOa,MAAA,QAAA,GAAW,CAAC,KAAyB,KAAA;AAChD,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,IAAA,EAAS,GAAA,KAAA;AAC9B,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,MAAM,CAAA;AAEvC,EAAA,2BACGC,UAAa,EAAA,EAAA,SAAA,EAAW,WAAW,KAAQ,EAAA,GAAG,MAC5C,QACH,EAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,140 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { TabListStateContext } from 'react-aria-components';
3
+ import { useStyles } from '../../hooks/useStyles.esm.js';
4
+ import { useContext, useRef, useCallback, useEffect } from 'react';
5
+
6
+ const TabsIndicators = (props) => {
7
+ const { tabRefs, tabsRef, hoveredKey, prevHoveredKey } = props;
8
+ const { classNames } = useStyles("Tabs");
9
+ const state = useContext(TabListStateContext);
10
+ const prevSelectedKey = useRef(null);
11
+ const updateCSSVariables = useCallback(() => {
12
+ if (!tabsRef.current) return;
13
+ const tabsRect = tabsRef.current.getBoundingClientRect();
14
+ if (state?.selectedKey) {
15
+ const activeTab = tabRefs.current.get(state.selectedKey.toString());
16
+ if (activeTab) {
17
+ const activeRect = activeTab.getBoundingClientRect();
18
+ const relativeLeft = activeRect.left - tabsRect.left;
19
+ const relativeTop = activeRect.top - tabsRect.top;
20
+ const isFirstActiveTab = prevSelectedKey.current === null;
21
+ if (isFirstActiveTab) {
22
+ tabsRef.current.style.setProperty(
23
+ "--active-transition-duration",
24
+ "0s"
25
+ );
26
+ requestAnimationFrame(() => {
27
+ if (tabsRef.current) {
28
+ tabsRef.current.style.setProperty(
29
+ "--active-transition-duration",
30
+ "0.25s"
31
+ );
32
+ }
33
+ });
34
+ } else {
35
+ tabsRef.current.style.setProperty(
36
+ "--active-transition-duration",
37
+ "0.25s"
38
+ );
39
+ }
40
+ prevSelectedKey.current = state.selectedKey.toString();
41
+ tabsRef.current.style.setProperty(
42
+ "--active-tab-left",
43
+ `${relativeLeft}px`
44
+ );
45
+ tabsRef.current.style.setProperty(
46
+ "--active-tab-right",
47
+ `${relativeLeft + activeRect.width}px`
48
+ );
49
+ tabsRef.current.style.setProperty(
50
+ "--active-tab-top",
51
+ `${relativeTop}px`
52
+ );
53
+ tabsRef.current.style.setProperty(
54
+ "--active-tab-bottom",
55
+ `${relativeTop + activeRect.height}px`
56
+ );
57
+ tabsRef.current.style.setProperty(
58
+ "--active-tab-width",
59
+ `${activeRect.width}px`
60
+ );
61
+ tabsRef.current.style.setProperty(
62
+ "--active-tab-height",
63
+ `${activeRect.height}px`
64
+ );
65
+ }
66
+ }
67
+ if (hoveredKey) {
68
+ const hoveredTab = tabRefs.current.get(hoveredKey);
69
+ if (hoveredTab) {
70
+ const hoveredRect = hoveredTab.getBoundingClientRect();
71
+ const relativeLeft = hoveredRect.left - tabsRect.left;
72
+ const relativeTop = hoveredRect.top - tabsRect.top;
73
+ tabsRef.current.style.setProperty(
74
+ "--hovered-tab-left",
75
+ `${relativeLeft}px`
76
+ );
77
+ tabsRef.current.style.setProperty(
78
+ "--hovered-tab-right",
79
+ `${relativeLeft + hoveredRect.width}px`
80
+ );
81
+ tabsRef.current.style.setProperty(
82
+ "--hovered-tab-top",
83
+ `${relativeTop}px`
84
+ );
85
+ tabsRef.current.style.setProperty(
86
+ "--hovered-tab-bottom",
87
+ `${relativeTop + hoveredRect.height}px`
88
+ );
89
+ tabsRef.current.style.setProperty(
90
+ "--hovered-tab-width",
91
+ `${hoveredRect.width}px`
92
+ );
93
+ tabsRef.current.style.setProperty(
94
+ "--hovered-tab-height",
95
+ `${hoveredRect.height}px`
96
+ );
97
+ const isNewHoverSession = prevHoveredKey.current === null;
98
+ if (isNewHoverSession) {
99
+ tabsRef.current.style.setProperty(
100
+ "--hovered-transition-duration",
101
+ "0s"
102
+ );
103
+ requestAnimationFrame(() => {
104
+ if (tabsRef.current) {
105
+ tabsRef.current.style.setProperty(
106
+ "--hovered-transition-duration",
107
+ "0.2s"
108
+ );
109
+ }
110
+ });
111
+ } else {
112
+ tabsRef.current.style.setProperty(
113
+ "--hovered-transition-duration",
114
+ "0.2s"
115
+ );
116
+ }
117
+ prevHoveredKey.current = hoveredKey;
118
+ tabsRef.current.style.setProperty("--hovered-tab-opacity", "1");
119
+ }
120
+ } else {
121
+ tabsRef.current.style.setProperty("--hovered-tab-opacity", "0");
122
+ prevHoveredKey.current = null;
123
+ }
124
+ }, [state?.selectedKey, hoveredKey, tabRefs.current]);
125
+ useEffect(() => {
126
+ updateCSSVariables();
127
+ }, [updateCSSVariables, tabRefs.current.size]);
128
+ useEffect(() => {
129
+ const handleResize = () => updateCSSVariables();
130
+ window.addEventListener("resize", handleResize);
131
+ return () => window.removeEventListener("resize", handleResize);
132
+ }, [updateCSSVariables]);
133
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
134
+ /* @__PURE__ */ jsx("div", { className: classNames.tabActive }),
135
+ /* @__PURE__ */ jsx("div", { className: classNames.tabHovered })
136
+ ] });
137
+ };
138
+
139
+ export { TabsIndicators };
140
+ //# sourceMappingURL=TabsIndicators.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabsIndicators.esm.js","sources":["../../../src/components/Tabs/TabsIndicators.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TabListStateContext } from 'react-aria-components';\nimport { useStyles } from '../../hooks/useStyles';\nimport { useContext, useEffect, useCallback, useRef } from 'react';\nimport type { TabsIndicatorsProps } from './types';\n\n/**\n * A component that renders the indicators for the toolbar.\n *\n * @internal\n */\nexport const TabsIndicators = (props: TabsIndicatorsProps) => {\n const { tabRefs, tabsRef, hoveredKey, prevHoveredKey } = props;\n const { classNames } = useStyles('Tabs');\n const state = useContext(TabListStateContext);\n const prevSelectedKey = useRef<string | null>(null);\n\n const updateCSSVariables = useCallback(() => {\n if (!tabsRef.current) return;\n\n const tabsRect = tabsRef.current.getBoundingClientRect();\n\n // Set active tab variables\n if (state?.selectedKey) {\n const activeTab = tabRefs.current.get(state.selectedKey.toString());\n\n if (activeTab) {\n const activeRect = activeTab.getBoundingClientRect();\n const relativeLeft = activeRect.left - tabsRect.left;\n const relativeTop = activeRect.top - tabsRect.top;\n\n // Control transition timing based on whether this is the first time setting active tab\n const isFirstActiveTab = prevSelectedKey.current === null;\n\n if (isFirstActiveTab) {\n // First time setting active tab: no transitions for position\n tabsRef.current.style.setProperty(\n '--active-transition-duration',\n '0s',\n );\n // Enable transitions on next frame for future tab switches\n requestAnimationFrame(() => {\n if (tabsRef.current) {\n tabsRef.current.style.setProperty(\n '--active-transition-duration',\n '0.25s',\n );\n }\n });\n } else {\n // Switching between tabs: full transitions\n tabsRef.current.style.setProperty(\n '--active-transition-duration',\n '0.25s',\n );\n }\n\n // Update previous selected key for next time\n prevSelectedKey.current = state.selectedKey.toString();\n\n tabsRef.current.style.setProperty(\n '--active-tab-left',\n `${relativeLeft}px`,\n );\n tabsRef.current.style.setProperty(\n '--active-tab-right',\n `${relativeLeft + activeRect.width}px`,\n );\n tabsRef.current.style.setProperty(\n '--active-tab-top',\n `${relativeTop}px`,\n );\n tabsRef.current.style.setProperty(\n '--active-tab-bottom',\n `${relativeTop + activeRect.height}px`,\n );\n tabsRef.current.style.setProperty(\n '--active-tab-width',\n `${activeRect.width}px`,\n );\n tabsRef.current.style.setProperty(\n '--active-tab-height',\n `${activeRect.height}px`,\n );\n }\n }\n\n // Set hovered tab variables\n if (hoveredKey) {\n const hoveredTab = tabRefs.current.get(hoveredKey);\n if (hoveredTab) {\n const hoveredRect = hoveredTab.getBoundingClientRect();\n const relativeLeft = hoveredRect.left - tabsRect.left;\n const relativeTop = hoveredRect.top - tabsRect.top;\n\n tabsRef.current.style.setProperty(\n '--hovered-tab-left',\n `${relativeLeft}px`,\n );\n tabsRef.current.style.setProperty(\n '--hovered-tab-right',\n `${relativeLeft + hoveredRect.width}px`,\n );\n tabsRef.current.style.setProperty(\n '--hovered-tab-top',\n `${relativeTop}px`,\n );\n tabsRef.current.style.setProperty(\n '--hovered-tab-bottom',\n `${relativeTop + hoveredRect.height}px`,\n );\n tabsRef.current.style.setProperty(\n '--hovered-tab-width',\n `${hoveredRect.width}px`,\n );\n tabsRef.current.style.setProperty(\n '--hovered-tab-height',\n `${hoveredRect.height}px`,\n );\n // Control transition timing based on whether this is a new hover session\n const isNewHoverSession = prevHoveredKey.current === null;\n\n if (isNewHoverSession) {\n // Starting new hover session: no transitions for position\n tabsRef.current.style.setProperty(\n '--hovered-transition-duration',\n '0s',\n );\n // Enable transitions on next frame for future tab switches\n requestAnimationFrame(() => {\n if (tabsRef.current) {\n tabsRef.current.style.setProperty(\n '--hovered-transition-duration',\n '0.2s',\n );\n }\n });\n } else {\n // Moving between tabs in same session: full transitions\n tabsRef.current.style.setProperty(\n '--hovered-transition-duration',\n '0.2s',\n );\n }\n\n // Update previous hover key for next time\n prevHoveredKey.current = hoveredKey;\n\n tabsRef.current.style.setProperty('--hovered-tab-opacity', '1');\n }\n } else {\n // When not hovering, hide with opacity and reset for next hover session\n tabsRef.current.style.setProperty('--hovered-tab-opacity', '0');\n\n // Reset previous hover key so next hover is treated as new session\n prevHoveredKey.current = null;\n }\n }, [state?.selectedKey, hoveredKey, tabRefs.current]);\n\n useEffect(() => {\n updateCSSVariables();\n }, [updateCSSVariables, tabRefs.current.size]);\n\n useEffect(() => {\n const handleResize = () => updateCSSVariables();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, [updateCSSVariables]);\n\n return (\n <>\n <div className={classNames.tabActive} />\n <div className={classNames.tabHovered} />\n </>\n );\n};\n"],"names":[],"mappings":";;;;;AA0Ba,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAA,MAAM,EAAE,OAAA,EAAS,OAAS,EAAA,UAAA,EAAY,gBAAmB,GAAA,KAAA;AACzD,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,MAAM,CAAA;AACvC,EAAM,MAAA,KAAA,GAAQ,WAAW,mBAAmB,CAAA;AAC5C,EAAM,MAAA,eAAA,GAAkB,OAAsB,IAAI,CAAA;AAElD,EAAM,MAAA,kBAAA,GAAqB,YAAY,MAAM;AAC3C,IAAI,IAAA,CAAC,QAAQ,OAAS,EAAA;AAEtB,IAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,OAAA,CAAQ,qBAAsB,EAAA;AAGvD,IAAA,IAAI,OAAO,WAAa,EAAA;AACtB,MAAA,MAAM,YAAY,OAAQ,CAAA,OAAA,CAAQ,IAAI,KAAM,CAAA,WAAA,CAAY,UAAU,CAAA;AAElE,MAAA,IAAI,SAAW,EAAA;AACb,QAAM,MAAA,UAAA,GAAa,UAAU,qBAAsB,EAAA;AACnD,QAAM,MAAA,YAAA,GAAe,UAAW,CAAA,IAAA,GAAO,QAAS,CAAA,IAAA;AAChD,QAAM,MAAA,WAAA,GAAc,UAAW,CAAA,GAAA,GAAM,QAAS,CAAA,GAAA;AAG9C,QAAM,MAAA,gBAAA,GAAmB,gBAAgB,OAAY,KAAA,IAAA;AAErD,QAAA,IAAI,gBAAkB,EAAA;AAEpB,UAAA,OAAA,CAAQ,QAAQ,KAAM,CAAA,WAAA;AAAA,YACpB,8BAAA;AAAA,YACA;AAAA,WACF;AAEA,UAAA,qBAAA,CAAsB,MAAM;AAC1B,YAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,cAAA,OAAA,CAAQ,QAAQ,KAAM,CAAA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+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import clsx from 'clsx';
4
+ import { useStyles } from '../../hooks/useStyles.esm.js';
5
+
6
+ function TextComponent({
7
+ as,
8
+ variant = "body",
9
+ weight = "regular",
10
+ color = "primary",
11
+ className,
12
+ truncate,
13
+ style,
14
+ ...restProps
15
+ }, ref) {
16
+ const Component = as || "p";
17
+ const { classNames, dataAttributes } = useStyles("Text", {
18
+ variant,
19
+ weight,
20
+ color
21
+ });
22
+ return /* @__PURE__ */ jsx(
23
+ Component,
24
+ {
25
+ ref,
26
+ className: clsx(classNames.root, className),
27
+ "data-truncate": truncate,
28
+ ...dataAttributes,
29
+ style,
30
+ ...restProps
31
+ }
32
+ );
33
+ }
34
+ TextComponent.displayName = "Text";
35
+ const Text = forwardRef(TextComponent);
36
+ Text.displayName = "Text";
37
+
38
+ export { Text };
39
+ //# sourceMappingURL=Text.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.esm.js","sources":["../../../src/components/Text/Text.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport type { ElementType } from 'react';\nimport type { TextProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\n\nfunction TextComponent<T extends ElementType = 'p'>(\n {\n as,\n variant = 'body',\n weight = 'regular',\n color = 'primary',\n className,\n truncate,\n style,\n ...restProps\n }: TextProps<T>,\n ref: React.Ref<any>,\n) {\n const Component = as || 'p';\n\n const { classNames, dataAttributes } = useStyles('Text', {\n variant,\n weight,\n color,\n });\n\n return (\n <Component\n ref={ref}\n className={clsx(classNames.root, className)}\n data-truncate={truncate}\n {...dataAttributes}\n style={style}\n {...restProps}\n />\n );\n}\n\nTextComponent.displayName = 'Text';\n\n/** @public */\nexport const Text = forwardRef(TextComponent) as {\n <T extends ElementType = 'p'>(\n props: TextProps<T> & { ref?: React.ComponentPropsWithRef<T>['ref'] },\n ): React.ReactElement<TextProps<T>, T>;\n displayName: string;\n};\n\nText.displayName = 'Text';\n"],"names":[],"mappings":";;;;;AAsBA,SAAS,aACP,CAAA;AAAA,EACE,EAAA;AAAA,EACA,OAAU,GAAA,MAAA;AAAA,EACV,MAAS,GAAA,SAAA;AAAA,EACT,KAAQ,GAAA,SAAA;AAAA,EACR,SAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAG;AACL,CAAA,EACA,GACA,EAAA;AACA,EAAA,MAAM,YAAY,EAAM,IAAA,GAAA;AAExB,EAAA,MAAM,EAAE,UAAA,EAAY,cAAe,EAAA,GAAI,UAAU,MAAQ,EAAA;AAAA,IACvD,OAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EACE,uBAAA,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,IAAA,EAAM,SAAS,CAAA;AAAA,MAC1C,eAAe,EAAA,QAAA;AAAA,MACd,GAAG,cAAA;AAAA,MACJ,KAAA;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,aAAA,CAAc,WAAc,GAAA,MAAA;AAGf,MAAA,IAAA,GAAO,WAAW,aAAa;AAO5C,IAAA,CAAK,WAAc,GAAA,MAAA;;;;"}