@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,88 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { forwardRef, useEffect } from 'react';
3
+ import { TextField as TextField$1, Input } from 'react-aria-components';
4
+ import clsx from 'clsx';
5
+ import { FieldLabel } from '../FieldLabel/FieldLabel.esm.js';
6
+ import { FieldError } from '../FieldError/FieldError.esm.js';
7
+ import { useStyles } from '../../hooks/useStyles.esm.js';
8
+
9
+ const TextField = forwardRef(
10
+ (props, ref) => {
11
+ const {
12
+ className,
13
+ icon,
14
+ size = "small",
15
+ label,
16
+ secondaryLabel,
17
+ description,
18
+ isRequired,
19
+ "aria-label": ariaLabel,
20
+ "aria-labelledby": ariaLabelledBy,
21
+ placeholder,
22
+ ...rest
23
+ } = props;
24
+ useEffect(() => {
25
+ if (!label && !ariaLabel && !ariaLabelledBy) {
26
+ console.warn(
27
+ "TextField requires either a visible label, aria-label, or aria-labelledby for accessibility"
28
+ );
29
+ }
30
+ }, [label, ariaLabel, ariaLabelledBy]);
31
+ const { classNames, dataAttributes } = useStyles("TextField", {
32
+ size
33
+ });
34
+ const secondaryLabelText = secondaryLabel || (isRequired ? "Required" : null);
35
+ return /* @__PURE__ */ jsxs(
36
+ TextField$1,
37
+ {
38
+ className: clsx(classNames.root, className),
39
+ ...dataAttributes,
40
+ "aria-label": ariaLabel,
41
+ "aria-labelledby": ariaLabelledBy,
42
+ ...rest,
43
+ ref,
44
+ children: [
45
+ /* @__PURE__ */ jsx(
46
+ FieldLabel,
47
+ {
48
+ label,
49
+ secondaryLabel: secondaryLabelText,
50
+ description
51
+ }
52
+ ),
53
+ /* @__PURE__ */ jsxs(
54
+ "div",
55
+ {
56
+ className: classNames.inputWrapper,
57
+ "data-size": dataAttributes["data-size"],
58
+ children: [
59
+ icon && /* @__PURE__ */ jsx(
60
+ "div",
61
+ {
62
+ className: classNames.inputIcon,
63
+ "data-size": dataAttributes["data-size"],
64
+ "aria-hidden": "true",
65
+ children: icon
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsx(
69
+ Input,
70
+ {
71
+ className: classNames.input,
72
+ ...icon && { "data-icon": true },
73
+ placeholder
74
+ }
75
+ )
76
+ ]
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsx(FieldError, {})
80
+ ]
81
+ }
82
+ );
83
+ }
84
+ );
85
+ TextField.displayName = "TextField";
86
+
87
+ export { TextField };
88
+ //# sourceMappingURL=TextField.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextField.esm.js","sources":["../../../src/components/TextField/TextField.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, useEffect } from 'react';\nimport { Input, TextField as AriaTextField } from 'react-aria-components';\nimport clsx from 'clsx';\nimport { FieldLabel } from '../FieldLabel';\nimport { FieldError } from '../FieldError';\n\nimport type { TextFieldProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\n\n/** @public */\nexport const TextField = forwardRef<HTMLDivElement, TextFieldProps>(\n (props, ref) => {\n const {\n className,\n icon,\n size = 'small',\n label,\n secondaryLabel,\n description,\n isRequired,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n placeholder,\n ...rest\n } = props;\n\n useEffect(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n 'TextField requires either a visible label, aria-label, or aria-labelledby for accessibility',\n );\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n const { classNames, dataAttributes } = useStyles('TextField', {\n size,\n });\n\n // If a secondary label is provided, use it. Otherwise, use 'Required' if the field is required.\n const secondaryLabelText =\n secondaryLabel || (isRequired ? 'Required' : null);\n\n return (\n <AriaTextField\n className={clsx(classNames.root, className)}\n {...dataAttributes}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n {...rest}\n ref={ref}\n >\n <FieldLabel\n label={label}\n secondaryLabel={secondaryLabelText}\n description={description}\n />\n <div\n className={classNames.inputWrapper}\n data-size={dataAttributes['data-size']}\n >\n {icon && (\n <div\n className={classNames.inputIcon}\n data-size={dataAttributes['data-size']}\n aria-hidden=\"true\"\n >\n {icon}\n </div>\n )}\n <Input\n className={classNames.input}\n {...(icon && { 'data-icon': true })}\n placeholder={placeholder}\n />\n </div>\n <FieldError />\n </AriaTextField>\n );\n },\n);\n\nTextField.displayName = 'TextField';\n"],"names":["AriaTextField"],"mappings":";;;;;;;;AA0BO,MAAM,SAAY,GAAA,UAAA;AAAA,EACvB,CAAC,OAAO,GAAQ,KAAA;AACd,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,IAAA;AAAA,MACA,IAAO,GAAA,OAAA;AAAA,MACP,KAAA;AAAA,MACA,cAAA;AAAA,MACA,WAAA;AAAA,MACA,UAAA;AAAA,MACA,YAAc,EAAA,SAAA;AAAA,MACd,iBAAmB,EAAA,cAAA;AAAA,MACnB,WAAA;AAAA,MACA,GAAG;AAAA,KACD,GAAA,KAAA;AAEJ,IAAA,SAAA,CAAU,MAAM;AACd,MAAA,IAAI,CAAC,KAAA,IAAS,CAAC,SAAA,IAAa,CAAC,cAAgB,EAAA;AAC3C,QAAQ,OAAA,CAAA,IAAA;AAAA,UACN;AAAA,SACF;AAAA;AACF,KACC,EAAA,CAAC,KAAO,EAAA,SAAA,EAAW,cAAc,CAAC,CAAA;AAErC,IAAA,MAAM,EAAE,UAAA,EAAY,cAAe,EAAA,GAAI,UAAU,WAAa,EAAA;AAAA,MAC5D;AAAA,KACD,CAAA;AAGD,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+ import { Tooltip as Tooltip$1, OverlayArrow, TooltipTrigger as TooltipTrigger$1 } from 'react-aria-components';
4
+ import clsx from 'clsx';
5
+ import { useStyles } from '../../hooks/useStyles.esm.js';
6
+
7
+ const TooltipTrigger = (props) => {
8
+ const { delay = 600 } = props;
9
+ return /* @__PURE__ */ jsx(TooltipTrigger$1, { delay, ...props });
10
+ };
11
+ const Tooltip = forwardRef(
12
+ ({ className, children, ...rest }, ref) => {
13
+ const { classNames } = useStyles("Tooltip");
14
+ return /* @__PURE__ */ jsxs(
15
+ Tooltip$1,
16
+ {
17
+ className: clsx(classNames.tooltip, className),
18
+ ...rest,
19
+ ref,
20
+ children: [
21
+ /* @__PURE__ */ jsx(OverlayArrow, { className: classNames.arrow, children: /* @__PURE__ */ jsx("svg", { width: 8, height: 8, viewBox: "0 0 8 8", children: /* @__PURE__ */ jsx("path", { d: "M0 0 L4 4 L8 0" }) }) }),
22
+ children
23
+ ]
24
+ }
25
+ );
26
+ }
27
+ );
28
+ Tooltip.displayName = Tooltip.displayName;
29
+
30
+ export { Tooltip, TooltipTrigger };
31
+ //# sourceMappingURL=Tooltip.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.esm.js","sources":["../../../src/components/Tooltip/Tooltip.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 {\n OverlayArrow,\n Tooltip as AriaTooltip,\n TooltipTrigger as AriaTooltipTrigger,\n TooltipTriggerComponentProps,\n} from 'react-aria-components';\nimport clsx from 'clsx';\nimport { TooltipProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\n\n/** @public */\nexport const TooltipTrigger = (props: TooltipTriggerComponentProps) => {\n const { delay = 600 } = props;\n\n return <AriaTooltipTrigger delay={delay} {...props} />;\n};\n\n/** @public */\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(\n ({ className, children, ...rest }, ref) => {\n const { classNames } = useStyles('Tooltip');\n\n return (\n <AriaTooltip\n className={clsx(classNames.tooltip, className)}\n {...rest}\n ref={ref}\n >\n <OverlayArrow className={classNames.arrow}>\n <svg width={8} height={8} viewBox=\"0 0 8 8\">\n <path d=\"M0 0 L4 4 L8 0\" />\n </svg>\n </OverlayArrow>\n {children}\n </AriaTooltip>\n );\n },\n);\n\nTooltip.displayName = Tooltip.displayName;\n"],"names":["AriaTooltipTrigger","AriaTooltip"],"mappings":";;;;;;AA4Ba,MAAA,cAAA,GAAiB,CAAC,KAAwC,KAAA;AACrE,EAAM,MAAA,EAAE,KAAQ,GAAA,GAAA,EAAQ,GAAA,KAAA;AAExB,EAAA,uBAAQ,GAAA,CAAAA,gBAAA,EAAA,EAAmB,KAAe,EAAA,GAAG,KAAO,EAAA,CAAA;AACtD;AAGO,MAAM,OAAU,GAAA,UAAA;AAAA,EACrB,CAAC,EAAE,SAAA,EAAW,UAAU,GAAG,IAAA,IAAQ,GAAQ,KAAA;AACzC,IAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,SAAS,CAAA;AAE1C,IACE,uBAAA,IAAA;AAAA,MAACC,SAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAA,IAAA,CAAK,UAAW,CAAA,OAAA,EAAS,SAAS,CAAA;AAAA,QAC5C,GAAG,IAAA;AAAA,QACJ,GAAA;AAAA,QAEA,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,gBAAa,SAAW,EAAA,UAAA,CAAW,KAClC,EAAA,QAAA,kBAAA,GAAA,CAAC,SAAI,KAAO,EAAA,CAAA,EAAG,MAAQ,EAAA,CAAA,EAAG,SAAQ,SAChC,EAAA,QAAA,kBAAA,GAAA,CAAC,UAAK,CAAE,EAAA,gBAAA,EAAiB,GAC3B,CACF,EAAA,CAAA;AAAA,UACC;AAAA;AAAA;AAAA,KACH;AAAA;AAGN;AAEA,OAAA,CAAQ,cAAc,OAAQ,CAAA,WAAA;;;;"}
@@ -0,0 +1,43 @@
1
+ import { useMediaQuery } from './useMediaQuery.esm.js';
2
+
3
+ const breakpoints = [
4
+ { name: "Initial", id: "initial", value: 0 },
5
+ { name: "Extra Small", id: "xs", value: 640 },
6
+ { name: "Small", id: "sm", value: 768 },
7
+ { name: "Medium", id: "md", value: 1024 },
8
+ { name: "Large", id: "lg", value: 1280 },
9
+ { name: "Extra Large", id: "xl", value: 1536 }
10
+ ];
11
+ const useBreakpoint = () => {
12
+ const matches = breakpoints.map((breakpoint2) => {
13
+ return useMediaQuery(`(min-width: ${breakpoint2.value}px)`);
14
+ });
15
+ const upMatches = new Map(
16
+ breakpoints.map((bp) => [bp.id, useMediaQuery(`(min-width: ${bp.value}px)`)])
17
+ );
18
+ const downMatches = new Map(
19
+ breakpoints.map((bp) => [
20
+ bp.id,
21
+ useMediaQuery(`(max-width: ${bp.value - 1}px)`)
22
+ ])
23
+ );
24
+ let breakpoint = breakpoints[0].id;
25
+ for (let i = matches.length - 1; i >= 0; i--) {
26
+ if (matches[i]) {
27
+ breakpoint = breakpoints[i].id;
28
+ break;
29
+ }
30
+ }
31
+ return {
32
+ breakpoint,
33
+ up: (key) => {
34
+ return upMatches.get(key) ?? false;
35
+ },
36
+ down: (key) => {
37
+ return downMatches.get(key) ?? false;
38
+ }
39
+ };
40
+ };
41
+
42
+ export { breakpoints, useBreakpoint };
43
+ //# sourceMappingURL=useBreakpoint.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBreakpoint.esm.js","sources":["../../src/hooks/useBreakpoint.ts"],"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 */\nimport { useMediaQuery } from './useMediaQuery';\nimport type { Breakpoint } from '../types';\n\nexport const breakpoints: { name: string; id: Breakpoint; value: number }[] = [\n { name: 'Initial', id: 'initial', value: 0 },\n { name: 'Extra Small', id: 'xs', value: 640 },\n { name: 'Small', id: 'sm', value: 768 },\n { name: 'Medium', id: 'md', value: 1024 },\n { name: 'Large', id: 'lg', value: 1280 },\n { name: 'Extra Large', id: 'xl', value: 1536 },\n];\n\n/** @public */\nexport const useBreakpoint = () => {\n // Call all media queries at the top level\n const matches = breakpoints.map(breakpoint => {\n return useMediaQuery(`(min-width: ${breakpoint.value}px)`);\n });\n\n // Pre-calculate all the up/down values we need\n const upMatches = new Map(\n breakpoints.map(bp => [bp.id, useMediaQuery(`(min-width: ${bp.value}px)`)]),\n );\n\n const downMatches = new Map(\n breakpoints.map(bp => [\n bp.id,\n useMediaQuery(`(max-width: ${bp.value - 1}px)`),\n ]),\n );\n\n let breakpoint: Breakpoint = breakpoints[0].id;\n for (let i = matches.length - 1; i >= 0; i--) {\n if (matches[i]) {\n breakpoint = breakpoints[i].id;\n break;\n }\n }\n\n return {\n breakpoint,\n up: (key: Breakpoint): boolean => {\n return upMatches.get(key) ?? false;\n },\n down: (key: Breakpoint): boolean => {\n return downMatches.get(key) ?? false;\n },\n };\n};\n"],"names":["breakpoint"],"mappings":";;AAkBO,MAAM,WAAiE,GAAA;AAAA,EAC5E,EAAE,IAAM,EAAA,SAAA,EAAW,EAAI,EAAA,SAAA,EAAW,OAAO,CAAE,EAAA;AAAA,EAC3C,EAAE,IAAM,EAAA,aAAA,EAAe,EAAI,EAAA,IAAA,EA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AAA;AACd,MAAa,UAAA,GAAA,WAAA,CAAY,CAAC,CAAE,CAAA,EAAA;AAC5B,MAAA;AAAA;AACF;AAGF,EAAO,OAAA;AAAA,IACL,UAAA;AAAA,IACA,EAAA,EAAI,CAAC,GAA6B,KAAA;AAChC,MAAO,OAAA,SAAA,CAAU,GAAI,CAAA,GAAG,CAAK,IAAA,KAAA;AAAA,KAC/B;AAAA,IACA,IAAA,EAAM,CAAC,GAA6B,KAAA;AAClC,MAAO,OAAA,WAAA,CAAY,GAAI,CAAA,GAAG,CAAK,IAAA,KAAA;AAAA;AACjC,GACF;AACF;;;;"}
@@ -0,0 +1,6 @@
1
+ import { useLayoutEffect, useEffect } from 'react';
2
+
3
+ const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
4
+
5
+ export { useIsomorphicLayoutEffect };
6
+ //# sourceMappingURL=useIsomorphicLayoutEffect.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.esm.js","sources":["../../src/hooks/useIsomorphicLayoutEffect.ts"],"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 */\nimport { useEffect, useLayoutEffect } from 'react';\n\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n"],"names":[],"mappings":";;AAiBO,MAAM,yBACX,GAAA,OAAO,MAAW,KAAA,WAAA,GAAc,eAAkB,GAAA;;;;"}
@@ -0,0 +1,44 @@
1
+ import { useState } from 'react';
2
+ import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.esm.js';
3
+
4
+ const IS_SERVER = typeof window === "undefined";
5
+ function useMediaQuery(query, {
6
+ defaultValue = false,
7
+ initializeWithValue = true
8
+ } = {}) {
9
+ const getMatches = (query2) => {
10
+ if (IS_SERVER) {
11
+ return defaultValue;
12
+ }
13
+ return window.matchMedia(query2).matches;
14
+ };
15
+ const [matches, setMatches] = useState(() => {
16
+ if (initializeWithValue) {
17
+ return getMatches(query);
18
+ }
19
+ return defaultValue;
20
+ });
21
+ function handleChange() {
22
+ setMatches(getMatches(query));
23
+ }
24
+ useIsomorphicLayoutEffect(() => {
25
+ const matchMedia = window.matchMedia(query);
26
+ handleChange();
27
+ if (matchMedia.addListener) {
28
+ matchMedia.addListener(handleChange);
29
+ } else {
30
+ matchMedia.addEventListener("change", handleChange);
31
+ }
32
+ return () => {
33
+ if (matchMedia.removeListener) {
34
+ matchMedia.removeListener(handleChange);
35
+ } else {
36
+ matchMedia.removeEventListener("change", handleChange);
37
+ }
38
+ };
39
+ }, [query]);
40
+ return matches;
41
+ }
42
+
43
+ export { useMediaQuery };
44
+ //# sourceMappingURL=useMediaQuery.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaQuery.esm.js","sources":["../../src/hooks/useMediaQuery.ts"],"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 */\nimport { useState } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\ntype UseMediaQueryOptions = {\n defaultValue?: boolean;\n initializeWithValue?: boolean;\n};\n\nconst IS_SERVER = typeof window === 'undefined';\n\nexport function useMediaQuery(\n query: string,\n {\n defaultValue = false,\n initializeWithValue = true,\n }: UseMediaQueryOptions = {},\n): boolean {\n const getMatches = (query: string): boolean => {\n if (IS_SERVER) {\n return defaultValue;\n }\n return window.matchMedia(query).matches;\n };\n\n const [matches, setMatches] = useState<boolean>(() => {\n if (initializeWithValue) {\n return getMatches(query);\n }\n return defaultValue;\n });\n\n // Handles the change event of the media query.\n function handleChange() {\n setMatches(getMatches(query));\n }\n\n useIsomorphicLayoutEffect(() => {\n const matchMedia = window.matchMedia(query);\n\n // Triggered at the first client-side load and if query changes\n handleChange();\n\n // Use deprecated `addListener` and `removeListener` to support Safari < 14 (#135)\n if (matchMedia.addListener) {\n matchMedia.addListener(handleChange);\n } else {\n matchMedia.addEventListener('change', handleChange);\n }\n\n return () => {\n if (matchMedia.removeListener) {\n matchMedia.removeListener(handleChange);\n } else {\n matchMedia.removeEventListener('change', handleChange);\n }\n };\n }, [query]);\n\n return matches;\n}\n"],"names":["query"],"mappings":";;;AAwBA,MAAM,SAAA,GAAY,OAAO,MAAW,KAAA,WAAA;AAE7B,SAAS,cACd,KACA,EAAA;AAAA,EACE,YAAe,GAAA,KAAA;AAAA,EACf,mBAAsB,GAAA;AACxB,CAAA,GAA0B,EACjB,EAAA;AACT,EAAM,MAAA,UAAA,GAAa,CAACA,MAA2B,KAAA;AAC7C,IAAA,IAAI,SAAW,EAAA;AACb,MAAO,OAAA,YAAA;AAAA;AAET,IAAO,OAAA,MAAA,CAAO,UAAWA,CAAAA,MAAK,CAAE,CAAA,OAAA;AAAA,GAClC;AAEA,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAkB,MAAM;AACpD,IAAA,IAAI,mBAAqB,EAAA;AACvB,MAAA,OAAO,WAAW,KAAK,CAAA;AAAA;AAEzB,IAAO,OAAA,YAAA;AAAA,GACR,CAAA;AAGD,EAAA,SAAS,YAAe,GAAA;AACtB,IAAW,UAAA,CAAA,UAAA,CAAW,KAAK,CAAC,CAAA;AAAA;AAG9B,EAAA,yBAAA,CAA0B,MAAM;AAC9B,IAAM,MAAA,UAAA,GAAa,MAAO,CAAA,UAAA,CAAW,KAAK,CAAA;AAG1C,IAAa,YAAA,EAAA;AAGb,IAAA,IAAI,WAAW,WAAa,EAAA;AAC1B,MAAA,UAAA,CAAW,YAAY,YAAY,CAAA;AAAA,KAC9B,MAAA;AACL,MAAW,UAAA,CAAA,gBAAA,CAAiB,UAAU,YAAY,CAAA;AAAA;AAGpD,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,WAAW,cAAgB,EAAA;AAC7B,QAAA,UAAA,CAAW,eAAe,YAAY,CAAA;AAAA,OACjC,MAAA;AACL,QAAW,UAAA,CAAA,mBAAA,CAAoB,UAAU,YAAY,CAAA;AAAA;AACvD,KACF;AAAA,GACF,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAO,OAAA,OAAA;AACT;;;;"}
@@ -0,0 +1,46 @@
1
+ import { useBreakpoint, breakpoints } from './useBreakpoint.esm.js';
2
+ import { componentDefinitions } from '../utils/componentDefinitions.esm.js';
3
+
4
+ function resolveResponsiveValue(value, breakpoint) {
5
+ if (typeof value === "string") {
6
+ return value;
7
+ }
8
+ if (typeof value === "object" && value !== null) {
9
+ const index = breakpoints.findIndex((b) => b.id === breakpoint);
10
+ for (let i = index; i >= 0; i--) {
11
+ if (value[breakpoints[i].id]) {
12
+ return value[breakpoints[i].id];
13
+ }
14
+ }
15
+ for (let i = 0; i < breakpoints.length; i++) {
16
+ if (value[breakpoints[i].id]) {
17
+ return value[breakpoints[i].id];
18
+ }
19
+ }
20
+ }
21
+ return void 0;
22
+ }
23
+ function useStyles(componentName, props = {}) {
24
+ const { breakpoint } = useBreakpoint();
25
+ const classNames = componentDefinitions[componentName].classNames;
26
+ const dataAttributes = {};
27
+ const resolvedProps = {};
28
+ for (const [key, value] of Object.entries(props)) {
29
+ if (value !== void 0 && value !== null) {
30
+ const resolvedValue = resolveResponsiveValue(value, breakpoint);
31
+ if (resolvedValue !== void 0) {
32
+ resolvedProps[key] = resolvedValue;
33
+ dataAttributes[`data-${key}`] = resolvedValue;
34
+ }
35
+ }
36
+ }
37
+ return {
38
+ classNames,
39
+ dataAttributes,
40
+ resolvedProps
41
+ // Also return resolved props for convenience
42
+ };
43
+ }
44
+
45
+ export { useStyles };
46
+ //# sourceMappingURL=useStyles.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStyles.esm.js","sources":["../../src/hooks/useStyles.ts"],"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 */\nimport { useBreakpoint, breakpoints } from './useBreakpoint';\nimport { componentDefinitions } from '../utils/componentDefinitions';\nimport type { ComponentDefinitionName, ComponentClassNames } from '../types';\n\n/**\n * Resolve a responsive value based on the current breakpoint\n * @param value - The responsive value (string or object with breakpoint keys)\n * @param breakpoint - The current breakpoint\n * @returns The resolved value for the current breakpoint\n */\nfunction resolveResponsiveValue(\n value: string | Record<string, string>,\n breakpoint: string,\n): string | undefined {\n if (typeof value === 'string') {\n return value;\n }\n\n if (typeof value === 'object' && value !== null) {\n const index = breakpoints.findIndex(b => b.id === breakpoint);\n\n // Look for value at current breakpoint or smaller\n for (let i = index; i >= 0; i--) {\n if (value[breakpoints[i].id]) {\n return value[breakpoints[i].id];\n }\n }\n\n // If no value found, check from smallest breakpoint up\n for (let i = 0; i < breakpoints.length; i++) {\n if (value[breakpoints[i].id]) {\n return value[breakpoints[i].id];\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * React hook to get class names and data attributes for a component with responsive support\n * @param componentName - The name of the component\n * @param props - Object with prop values (can be responsive)\n * @returns Object with classNames and dataAttributes\n */\nexport function useStyles<T extends ComponentDefinitionName>(\n componentName: T,\n props: Record<string, any> = {},\n): {\n classNames: ComponentClassNames<T>;\n dataAttributes: Record<string, string>;\n resolvedProps: Record<string, string>;\n} {\n const { breakpoint } = useBreakpoint();\n const classNames = componentDefinitions[componentName]\n .classNames as ComponentClassNames<T>;\n\n // Resolve responsive values and generate data attributes\n const dataAttributes: Record<string, string> = {};\n const resolvedProps: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(props)) {\n if (value !== undefined && value !== null) {\n const resolvedValue = resolveResponsiveValue(value, breakpoint);\n if (resolvedValue !== undefined) {\n resolvedProps[key] = resolvedValue;\n dataAttributes[`data-${key}`] = resolvedValue;\n }\n }\n }\n\n return {\n classNames,\n dataAttributes,\n resolvedProps, // Also return resolved props for convenience\n };\n}\n"],"names":[],"mappings":";;;AAyBA,SAAS,sBAAA,CACP,OACA,UACoB,EAAA;AACpB,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,IAAO,OAAA,KAAA;AAAA;AAGT,EAAA,IAAI,OAAO,KAAA,KAAU,QAAY,IAAA,KAAA,KAAU,IAAM,EAAA;AAC/C,IAAA,MAAM,QAAQ,WAAY,CAAA,SAAA,CAAU,CAAK,CAAA,KAAA,CAAA,CAAE,OAAO,UAAU,CAAA;AAG5D,IAAA,KAAA,IAAS,CAAI,GAAA,KAAA,EAAO,CAAK,IAAA,CAAA,EAAG,CAAK,EAAA,EAAA;AAC/B,MAAA,IAAI,KAAM,CAAA,WAAA,CAAY,CAAC,CAAA,CAAE,EAAE,CAAG,EAAA;AAC5B,QAAA,OAAO,KAAM,CAAA,WAAA,CAAY,CAAC,CAAA,CAAE,EAAE,CAAA;AAAA;AAChC;AAIF,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,WAAA,CAAY,QAAQ,CAAK,EAAA,EAAA;AAC3C,MAAA,IAAI,KAAM,CAAA,WAAA,CA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