@backstage/ui 0.11.0-next.0 → 0.11.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/css/styles.css +36 -12
  3. package/dist/components/Box/Box.esm.js +13 -6
  4. package/dist/components/Box/Box.esm.js.map +1 -1
  5. package/dist/components/Box/Box.module.css.esm.js +1 -1
  6. package/dist/components/Box/definition.esm.js +4 -1
  7. package/dist/components/Box/definition.esm.js.map +1 -1
  8. package/dist/components/Button/Button.esm.js +12 -1
  9. package/dist/components/Button/Button.esm.js.map +1 -1
  10. package/dist/components/Button/Button.module.css.esm.js +1 -1
  11. package/dist/components/Flex/Flex.esm.js +14 -6
  12. package/dist/components/Flex/Flex.esm.js.map +1 -1
  13. package/dist/components/Flex/Flex.module.css.esm.js +1 -1
  14. package/dist/components/Flex/definition.esm.js +4 -1
  15. package/dist/components/Flex/definition.esm.js.map +1 -1
  16. package/dist/components/Grid/Grid.esm.js +27 -12
  17. package/dist/components/Grid/Grid.esm.js.map +1 -1
  18. package/dist/components/Grid/Grid.module.css.esm.js +2 -2
  19. package/dist/components/Grid/definition.esm.js +8 -2
  20. package/dist/components/Grid/definition.esm.js.map +1 -1
  21. package/dist/components/Link/Link.esm.js +9 -6
  22. package/dist/components/Link/Link.esm.js.map +1 -1
  23. package/dist/components/Table/Table.module.css.esm.js +1 -1
  24. package/dist/components/Table/components/Table.esm.js +154 -15
  25. package/dist/components/Table/components/Table.esm.js.map +1 -1
  26. package/dist/components/Table/components/TableRoot.esm.js +26 -0
  27. package/dist/components/Table/components/TableRoot.esm.js.map +1 -0
  28. package/dist/components/Table/definition.esm.js +3 -0
  29. package/dist/components/Table/definition.esm.js.map +1 -1
  30. package/dist/components/Table/hooks/useCompletePagination.esm.js +106 -0
  31. package/dist/components/Table/hooks/useCompletePagination.esm.js.map +1 -0
  32. package/dist/components/Table/hooks/useCursorPagination.esm.js +58 -0
  33. package/dist/components/Table/hooks/useCursorPagination.esm.js.map +1 -0
  34. package/dist/components/Table/hooks/useDebouncedReload.esm.js +17 -0
  35. package/dist/components/Table/hooks/useDebouncedReload.esm.js.map +1 -0
  36. package/dist/components/Table/hooks/useOffsetPagination.esm.js +64 -0
  37. package/dist/components/Table/hooks/useOffsetPagination.esm.js.map +1 -0
  38. package/dist/components/Table/hooks/usePageCache.esm.js +168 -0
  39. package/dist/components/Table/hooks/usePageCache.esm.js.map +1 -0
  40. package/dist/components/Table/hooks/useQueryState.esm.js +42 -0
  41. package/dist/components/Table/hooks/useQueryState.esm.js.map +1 -0
  42. package/dist/components/Table/hooks/useStableCallback.esm.js +10 -0
  43. package/dist/components/Table/hooks/useStableCallback.esm.js.map +1 -0
  44. package/dist/components/Table/hooks/useTable.esm.js +80 -99
  45. package/dist/components/Table/hooks/useTable.esm.js.map +1 -1
  46. package/dist/components/TablePagination/TablePagination.esm.js +76 -101
  47. package/dist/components/TablePagination/TablePagination.esm.js.map +1 -1
  48. package/dist/components/ToggleButton/ToggleButton.esm.js +51 -0
  49. package/dist/components/ToggleButton/ToggleButton.esm.js.map +1 -0
  50. package/dist/components/ToggleButton/ToggleButton.module.css.esm.js +8 -0
  51. package/dist/components/ToggleButton/ToggleButton.module.css.esm.js.map +1 -0
  52. package/dist/components/ToggleButton/definition.esm.js +12 -0
  53. package/dist/components/ToggleButton/definition.esm.js.map +1 -0
  54. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.esm.js +33 -0
  55. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.esm.js.map +1 -0
  56. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.module.css.esm.js +8 -0
  57. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.module.css.esm.js.map +1 -0
  58. package/dist/components/ToggleButtonGroup/definition.esm.js +11 -0
  59. package/dist/components/ToggleButtonGroup/definition.esm.js.map +1 -0
  60. package/dist/hooks/useSurface.esm.js +74 -0
  61. package/dist/hooks/useSurface.esm.js.map +1 -0
  62. package/dist/index.d.ts +306 -92
  63. package/dist/index.esm.js +5 -0
  64. package/dist/index.esm.js.map +1 -1
  65. package/package.json +5 -4
@@ -4,111 +4,86 @@ import { useStyles } from '../../hooks/useStyles.esm.js';
4
4
  import { TablePaginationDefinition } from './definition.esm.js';
5
5
  import styles from './TablePagination.module.css.esm.js';
6
6
  import { RiArrowLeftSLine, RiArrowRightSLine } from '@remixicon/react';
7
+ import { useId } from 'react';
7
8
  import { Select } from '../Select/Select.esm.js';
8
9
  import { ButtonIcon } from '../ButtonIcon/ButtonIcon.esm.js';
9
10
  import { Text } from '../Text/Text.esm.js';
10
11
 
11
- function TablePagination(props) {
12
- const { classNames, cleanedProps } = useStyles(TablePaginationDefinition, {
13
- showPageSizeOptions: true,
14
- ...props
15
- });
16
- const {
17
- className,
18
- offset,
19
- pageSize,
20
- rowCount,
21
- onNextPage,
22
- onPreviousPage,
23
- onPageSizeChange,
24
- setOffset,
25
- setPageSize,
26
- showPageSizeOptions,
27
- ...rest
28
- } = cleanedProps;
29
- const currentOffset = offset ?? 0;
30
- const currentPageSize = pageSize ?? 10;
31
- const fromCount = currentOffset + 1;
32
- const toCount = Math.min(currentOffset + currentPageSize, rowCount ?? 0);
33
- const nextPage = () => {
34
- const totalRows = rowCount ?? 0;
35
- const nextOffset = currentOffset + currentPageSize;
36
- if (nextOffset < totalRows) {
37
- onNextPage?.();
38
- setOffset?.(nextOffset);
39
- }
40
- };
41
- const previousPage = () => {
42
- if (currentOffset > 0) {
43
- onPreviousPage?.();
44
- const prevOffset = Math.max(0, currentOffset - currentPageSize);
45
- setOffset?.(prevOffset);
46
- }
47
- };
48
- return /* @__PURE__ */ jsxs(
49
- "div",
50
- {
51
- className: clsx(classNames.root, styles[classNames.root], className),
52
- ...rest,
53
- children: [
54
- /* @__PURE__ */ jsx("div", { className: clsx(classNames.left, styles[classNames.left]), children: showPageSizeOptions && /* @__PURE__ */ jsx(
55
- Select,
56
- {
57
- name: "pageSize",
58
- size: "small",
59
- placeholder: "Show 10 results",
60
- options: [
61
- { label: "Show 5 results", value: "5" },
62
- { label: "Show 10 results", value: "10" },
63
- { label: "Show 20 results", value: "20" },
64
- { label: "Show 30 results", value: "30" },
65
- { label: "Show 40 results", value: "40" },
66
- { label: "Show 50 results", value: "50" }
67
- ],
68
- selectedKey: pageSize?.toString(),
69
- onSelectionChange: (value) => {
70
- const newPageSize = Number(value);
71
- setPageSize?.(newPageSize);
72
- onPageSizeChange?.(newPageSize);
73
- },
74
- className: clsx(classNames.select, styles[classNames.select])
75
- }
76
- ) }),
77
- /* @__PURE__ */ jsxs("div", { className: clsx(classNames.right, styles[classNames.right]), children: [
78
- /* @__PURE__ */ jsx(
79
- Text,
80
- {
81
- as: "p",
82
- variant: "body-medium",
83
- children: `${fromCount} - ${toCount} of ${rowCount}`
84
- }
85
- ),
86
- /* @__PURE__ */ jsx(
87
- ButtonIcon,
88
- {
89
- variant: "secondary",
90
- size: "small",
91
- onClick: previousPage,
92
- isDisabled: currentOffset === 0,
93
- icon: /* @__PURE__ */ jsx(RiArrowLeftSLine, {}),
94
- "aria-label": "Previous"
95
- }
96
- ),
97
- /* @__PURE__ */ jsx(
98
- ButtonIcon,
99
- {
100
- variant: "secondary",
101
- size: "small",
102
- onClick: nextPage,
103
- isDisabled: rowCount !== void 0 && currentOffset + currentPageSize >= rowCount,
104
- icon: /* @__PURE__ */ jsx(RiArrowRightSLine, {}),
105
- "aria-label": "Next"
106
- }
107
- )
108
- ] })
109
- ]
110
- }
111
- );
12
+ function TablePagination({
13
+ pageSize,
14
+ offset,
15
+ totalCount,
16
+ hasNextPage,
17
+ hasPreviousPage,
18
+ onNextPage,
19
+ onPreviousPage,
20
+ onPageSizeChange,
21
+ showPageSizeOptions = true,
22
+ getLabel
23
+ }) {
24
+ const { classNames } = useStyles(TablePaginationDefinition, {});
25
+ const labelId = useId();
26
+ const hasItems = totalCount !== void 0 && totalCount !== 0;
27
+ let label = `${totalCount} items`;
28
+ if (getLabel) {
29
+ label = getLabel({ pageSize, offset, totalCount });
30
+ } else if (offset !== void 0) {
31
+ const fromCount = offset + 1;
32
+ const toCount = Math.min(offset + pageSize, totalCount ?? 0);
33
+ label = `${fromCount} - ${toCount} of ${totalCount}`;
34
+ }
35
+ return /* @__PURE__ */ jsxs("div", { className: clsx(classNames.root, styles[classNames.root]), children: [
36
+ /* @__PURE__ */ jsx("div", { className: clsx(classNames.left, styles[classNames.left]), children: showPageSizeOptions && /* @__PURE__ */ jsx(
37
+ Select,
38
+ {
39
+ name: "pageSize",
40
+ size: "small",
41
+ "aria-label": "Select table page size",
42
+ placeholder: "Show 10 results",
43
+ options: [
44
+ { label: "Show 5 results", value: "5" },
45
+ { label: "Show 10 results", value: "10" },
46
+ { label: "Show 20 results", value: "20" },
47
+ { label: "Show 30 results", value: "30" },
48
+ { label: "Show 40 results", value: "40" },
49
+ { label: "Show 50 results", value: "50" }
50
+ ],
51
+ defaultValue: pageSize.toString(),
52
+ onChange: (value) => {
53
+ const newPageSize = Number(value);
54
+ onPageSizeChange?.(newPageSize);
55
+ },
56
+ className: clsx(classNames.select, styles[classNames.select])
57
+ }
58
+ ) }),
59
+ /* @__PURE__ */ jsxs("div", { className: clsx(classNames.right, styles[classNames.right]), children: [
60
+ hasItems && /* @__PURE__ */ jsx(Text, { as: "p", variant: "body-medium", id: labelId, children: label }),
61
+ /* @__PURE__ */ jsx(
62
+ ButtonIcon,
63
+ {
64
+ variant: "secondary",
65
+ size: "small",
66
+ onClick: onPreviousPage,
67
+ isDisabled: !hasPreviousPage,
68
+ icon: /* @__PURE__ */ jsx(RiArrowLeftSLine, {}),
69
+ "aria-label": "Previous table page",
70
+ "aria-describedby": hasItems ? labelId : void 0
71
+ }
72
+ ),
73
+ /* @__PURE__ */ jsx(
74
+ ButtonIcon,
75
+ {
76
+ variant: "secondary",
77
+ size: "small",
78
+ onClick: onNextPage,
79
+ isDisabled: !hasNextPage,
80
+ icon: /* @__PURE__ */ jsx(RiArrowRightSLine, {}),
81
+ "aria-label": "Next table page",
82
+ "aria-describedby": hasItems ? labelId : void 0
83
+ }
84
+ )
85
+ ] })
86
+ ] });
112
87
  }
113
88
 
114
89
  export { TablePagination };
@@ -1 +1 @@
1
- {"version":3,"file":"TablePagination.esm.js","sources":["../../../src/components/TablePagination/TablePagination.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 clsx from 'clsx';\nimport { Text, ButtonIcon, Select } from '../..';\nimport type { TablePaginationProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\nimport { TablePaginationDefinition } from './definition';\nimport styles from './TablePagination.module.css';\nimport { RiArrowLeftSLine, RiArrowRightSLine } from '@remixicon/react';\n\n/**\n * Pagination controls for Table components with page navigation and size selection.\n *\n * @public\n */\nexport function TablePagination(props: TablePaginationProps) {\n const { classNames, cleanedProps } = useStyles(TablePaginationDefinition, {\n showPageSizeOptions: true,\n ...props,\n });\n const {\n className,\n offset,\n pageSize,\n rowCount,\n onNextPage,\n onPreviousPage,\n onPageSizeChange,\n setOffset,\n setPageSize,\n showPageSizeOptions,\n ...rest\n } = cleanedProps;\n\n const currentOffset = offset ?? 0;\n const currentPageSize = pageSize ?? 10;\n\n const fromCount = currentOffset + 1;\n const toCount = Math.min(currentOffset + currentPageSize, rowCount ?? 0);\n\n const nextPage = () => {\n const totalRows = rowCount ?? 0;\n const nextOffset = currentOffset + currentPageSize;\n\n // Check if there are more items to navigate to\n if (nextOffset < totalRows) {\n onNextPage?.(); // Analytics tracking\n setOffset?.(nextOffset); // Navigate to next page\n }\n };\n\n const previousPage = () => {\n // Check if we can go to previous page\n if (currentOffset > 0) {\n onPreviousPage?.(); // Analytics tracking\n const prevOffset = Math.max(0, currentOffset - currentPageSize);\n setOffset?.(prevOffset); // Navigate to previous page\n }\n };\n\n return (\n <div\n className={clsx(classNames.root, styles[classNames.root], className)}\n {...rest}\n >\n <div className={clsx(classNames.left, styles[classNames.left])}>\n {showPageSizeOptions && (\n <Select\n name=\"pageSize\"\n size=\"small\"\n placeholder=\"Show 10 results\"\n options={[\n { label: 'Show 5 results', value: '5' },\n { label: 'Show 10 results', value: '10' },\n { label: 'Show 20 results', value: '20' },\n { label: 'Show 30 results', value: '30' },\n { label: 'Show 40 results', value: '40' },\n { label: 'Show 50 results', value: '50' },\n ]}\n selectedKey={pageSize?.toString()}\n onSelectionChange={value => {\n const newPageSize = Number(value);\n setPageSize?.(newPageSize);\n onPageSizeChange?.(newPageSize);\n }}\n className={clsx(classNames.select, styles[classNames.select])}\n />\n )}\n </div>\n <div className={clsx(classNames.right, styles[classNames.right])}>\n <Text\n as=\"p\"\n variant=\"body-medium\"\n >{`${fromCount} - ${toCount} of ${rowCount}`}</Text>\n <ButtonIcon\n variant=\"secondary\"\n size=\"small\"\n onClick={previousPage}\n isDisabled={currentOffset === 0}\n icon={<RiArrowLeftSLine />}\n aria-label=\"Previous\"\n />\n <ButtonIcon\n variant=\"secondary\"\n size=\"small\"\n onClick={nextPage}\n isDisabled={\n rowCount !== undefined &&\n currentOffset + currentPageSize >= rowCount\n }\n icon={<RiArrowRightSLine />}\n aria-label=\"Next\"\n />\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA6BO,SAAS,gBAAgB,KAAA,EAA6B;AAC3D,EAAA,MAAM,EAAE,UAAA,EAAY,YAAA,EAAa,GAAI,UAAU,yBAAA,EAA2B;AAAA,IACxE,mBAAA,EAAqB,IAAA;AAAA,IACrB,GAAG;AAAA,GACJ,CAAA;AACD,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA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A,GAAA,EAAM,OAAO,OAAO,QAAQ,CAAA;AAAA;AAAA,WAAG;AAAA,0BAC7C,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,OAAA,EAAQ,WAAA;AAAA,cACR,IAAA,EAAK,OAAA;AAAA,cACL,OAAA,EAAS,YAAA;AAAA,cACT,YAAY,aAAA,KAAkB,CAAA;AAAA,cAC9B,IAAA,sBAAO,gBAAA,EAAA,EAAiB,CAAA;AAAA,cACxB,YAAA,EAAW;AAAA;AAAA,WACb;AAAA,0BACA,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,OAAA,EAAQ,WAAA;AAAA,cACR,IAAA,EAAK,OAAA;AAAA,cACL,OAAA,EAAS,QAAA;AAAA,cACT,UAAA,EACE,QAAA,KAAa,MAAA,IACb,aAAA,GAAgB,eAAA,IAAmB,QAAA;AAAA,cAErC,IAAA,sBAAO,iBAAA,EAAA,EAAkB,CAAA;AAAA,cACzB,YAAA,EAAW;AAAA;AAAA;AACb,SAAA,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"TablePagination.esm.js","sources":["../../../src/components/TablePagination/TablePagination.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 clsx from 'clsx';\nimport { Text, ButtonIcon, Select } from '../..';\nimport type { TablePaginationProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\nimport { TablePaginationDefinition } from './definition';\nimport styles from './TablePagination.module.css';\nimport { RiArrowLeftSLine, RiArrowRightSLine } from '@remixicon/react';\nimport { useId } from 'react';\n\n/**\n * Pagination controls for Table components with page navigation and size selection.\n *\n * @public\n */\nexport function TablePagination({\n pageSize,\n offset,\n totalCount,\n hasNextPage,\n hasPreviousPage,\n onNextPage,\n onPreviousPage,\n onPageSizeChange,\n showPageSizeOptions = true,\n getLabel,\n}: TablePaginationProps) {\n const { classNames } = useStyles(TablePaginationDefinition, {});\n const labelId = useId();\n\n const hasItems = totalCount !== undefined && totalCount !== 0;\n\n let label = `${totalCount} items`;\n if (getLabel) {\n label = getLabel({ pageSize, offset, totalCount });\n } else if (offset !== undefined) {\n const fromCount = offset + 1;\n const toCount = Math.min(offset + pageSize, totalCount ?? 0);\n label = `${fromCount} - ${toCount} of ${totalCount}`;\n }\n\n return (\n <div className={clsx(classNames.root, styles[classNames.root])}>\n <div className={clsx(classNames.left, styles[classNames.left])}>\n {showPageSizeOptions && (\n <Select\n name=\"pageSize\"\n size=\"small\"\n aria-label=\"Select table page size\"\n placeholder=\"Show 10 results\"\n options={[\n { label: 'Show 5 results', value: '5' },\n { label: 'Show 10 results', value: '10' },\n { label: 'Show 20 results', value: '20' },\n { label: 'Show 30 results', value: '30' },\n { label: 'Show 40 results', value: '40' },\n { label: 'Show 50 results', value: '50' },\n ]}\n defaultValue={pageSize.toString()}\n onChange={value => {\n const newPageSize = Number(value);\n onPageSizeChange?.(newPageSize);\n }}\n className={clsx(classNames.select, styles[classNames.select])}\n />\n )}\n </div>\n <div className={clsx(classNames.right, styles[classNames.right])}>\n {hasItems && (\n <Text as=\"p\" variant=\"body-medium\" id={labelId}>\n {label}\n </Text>\n )}\n <ButtonIcon\n variant=\"secondary\"\n size=\"small\"\n onClick={onPreviousPage}\n isDisabled={!hasPreviousPage}\n icon={<RiArrowLeftSLine />}\n aria-label=\"Previous table page\"\n aria-describedby={hasItems ? labelId : undefined}\n />\n <ButtonIcon\n variant=\"secondary\"\n size=\"small\"\n onClick={onNextPage}\n isDisabled={!hasNextPage}\n icon={<RiArrowRightSLine />}\n aria-label=\"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AAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,OAAA,EAAQ,WAAA;AAAA,UACR,IAAA,EAAK,OAAA;AAAA,UACL,OAAA,EAAS,cAAA;AAAA,UACT,YAAY,CAAC,eAAA;AAAA,UACb,IAAA,sBAAO,gBAAA,EAAA,EAAiB,CAAA;AAAA,UACxB,YAAA,EAAW,qBAAA;AAAA,UACX,kBAAA,EAAkB,WAAW,OAAA,GAAU;AAAA;AAAA,OACzC;AAAA,sBACA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,OAAA,EAAQ,WAAA;AAAA,UACR,IAAA,EAAK,OAAA;AAAA,UACL,OAAA,EAAS,UAAA;AAAA,UACT,YAAY,CAAC,WAAA;AAAA,UACb,IAAA,sBAAO,iBAAA,EAAA,EAAkB,CAAA;AAAA,UACzB,YAAA,EAAW,iBAAA;AAAA,UACX,kBAAA,EAAkB,WAAW,OAAA,GAAU;AAAA;AAAA;AACzC,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,51 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import clsx from 'clsx';
3
+ import { forwardRef } from 'react';
4
+ import { ToggleButton as ToggleButton$1 } from 'react-aria-components';
5
+ import { useStyles } from '../../hooks/useStyles.esm.js';
6
+ import { ToggleButtonDefinition } from './definition.esm.js';
7
+ import styles from './ToggleButton.module.css.esm.js';
8
+ import { useSurface } from '../../hooks/useSurface.esm.js';
9
+
10
+ const ToggleButton = forwardRef(
11
+ (props, ref) => {
12
+ const { classNames, dataAttributes, cleanedProps } = useStyles(
13
+ ToggleButtonDefinition,
14
+ {
15
+ size: "small",
16
+ ...props
17
+ }
18
+ );
19
+ const { children, className, iconStart, iconEnd, onSurface, ...rest } = cleanedProps;
20
+ const { surface } = useSurface({ onSurface });
21
+ return /* @__PURE__ */ jsx(
22
+ ToggleButton$1,
23
+ {
24
+ className: clsx(classNames.root, styles[classNames.root], className),
25
+ ref,
26
+ ...dataAttributes,
27
+ ...typeof surface === "string" ? { "data-on-surface": surface } : {},
28
+ ...rest,
29
+ children: (renderProps) => {
30
+ const renderedChildren = typeof children === "function" ? children(renderProps) : children;
31
+ return /* @__PURE__ */ jsxs(
32
+ "span",
33
+ {
34
+ className: clsx(classNames.content, styles[classNames.content]),
35
+ "data-slot": "content",
36
+ children: [
37
+ iconStart,
38
+ renderedChildren,
39
+ iconEnd
40
+ ]
41
+ }
42
+ );
43
+ }
44
+ }
45
+ );
46
+ }
47
+ );
48
+ ToggleButton.displayName = "ToggleButton";
49
+
50
+ export { ToggleButton };
51
+ //# sourceMappingURL=ToggleButton.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleButton.esm.js","sources":["../../../src/components/ToggleButton/ToggleButton.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 clsx from 'clsx';\nimport { forwardRef, Ref } from 'react';\nimport { ToggleButton as AriaToggleButton } from 'react-aria-components';\nimport type { ToggleButtonProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\nimport { ToggleButtonDefinition } from './definition';\nimport styles from './ToggleButton.module.css';\nimport { useSurface } from '../../hooks/useSurface';\n\n/** @public */\nexport const ToggleButton = forwardRef(\n (props: ToggleButtonProps, ref: Ref<HTMLButtonElement>) => {\n const { classNames, dataAttributes, cleanedProps } = useStyles(\n ToggleButtonDefinition,\n {\n size: 'small',\n ...props,\n },\n );\n\n const { children, className, iconStart, iconEnd, onSurface, ...rest } =\n cleanedProps;\n\n const { surface } = useSurface({ onSurface });\n\n return (\n <AriaToggleButton\n className={clsx(classNames.root, styles[classNames.root], className)}\n ref={ref}\n {...dataAttributes}\n {...(typeof surface === 'string' ? { 'data-on-surface': surface } : {})}\n {...rest}\n >\n {renderProps => {\n // If children is a function, call it with render props; otherwise use children as-is\n const renderedChildren =\n typeof children === 'function' ? children(renderProps) : children;\n\n return (\n <span\n className={clsx(classNames.content, styles[classNames.content])}\n data-slot=\"content\"\n >\n {iconStart}\n {renderedChildren}\n {iconEnd}\n </span>\n );\n }}\n </AriaToggleButton>\n );\n },\n);\n\nToggleButton.displayName = 'ToggleButton';\n"],"names":["AriaToggleButton"],"mappings":";;;;;;;;;AA0BO,MAAM,YAAA,GAAe,UAAA;AAAA,EAC1B,CAAC,OAA0B,GAAA,KAAgC;AACzD,IAAA,MAAM,EAAE,UAAA,EAAY,cAAA,EAAgB,YAAA,EAAa,GAAI,SAAA;AAAA,MACnD,sBAAA;AAAA,MACA;AAAA,QACE,IAAA,EAAM,OAAA;AAAA,QACN,GAAG;AAAA;AACL,KACF;AAEA,IAAA,MAAM,EAAE,UAAU,SAAA,EAAW,SAAA,EAAW,SAAS,SAAA,EAAW,GAAG,MAAK,GAClE,YAAA;AAEF,IAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,UAAA,CAAW,EAAE,WAAW,CAAA;AAE5C,IAAA,uBACE,GAAA;AAAA,MAACA,cAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAW,KAAK,UAAA,CAAW,IAAA,EAAM,OAAO,UAAA,CAAW,IAAI,GAAG,SAAS,CAAA;AAAA,QACnE,GAAA;AAAA,QACC,GAAG,cAAA;AAAA,QACH,GAAI,OAAO,OAAA,KAAY,QAAA,GAAW,EAAE,iBAAA,EAAmB,OAAA,KAAY,EAAC;AAAA,QACpE,GAAG,IAAA;AAAA,QAEH,QAAA,EAAA,CAAA,WAAA,KAAe;AAEd,UAAA,MAAM,mBACJ,OAAO,QAAA,KAAa,UAAA,GAAa,QAAA,CAAS,WAAW,CAAA,GAAI,QAAA;AAE3D,UAAA,uBACE,IAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,WAAW,IAAA,CAAK,UAAA,CAAW,SAAS,MAAA,CAAO,UAAA,CAAW,OAAO,CAAC,CAAA;AAAA,cAC9D,WAAA,EAAU,SAAA;AAAA,cAET,QAAA,EAAA;AAAA,gBAAA,SAAA;AAAA,gBACA,gBAAA;AAAA,gBACA;AAAA;AAAA;AAAA,WACH;AAAA,QAEJ;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,YAAA,CAAa,WAAA,GAAc,cAAA;;;;"}
@@ -0,0 +1,8 @@
1
+ import styleInject from '../../node_modules_dist/style-inject/dist/style-inject.es.esm.js';
2
+
3
+ var css_248z = "/*\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\n@layer tokens, base, components, utilities;\n\n@layer components {\n .ToggleButton-module_bui-ToggleButton__1CL1A {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--bui-space-1_5);\n border: none;\n border-radius: var(--bui-radius-2);\n background: var(--bui-bg-surface-1);\n color: var(--bui-fg-primary);\n font-family: var(--bui-font-regular);\n font-weight: var(--bui-font-weight-bold);\n padding: 0 var(--bui-space-2);\n cursor: pointer;\n transition: background-color 150ms ease, box-shadow 150ms ease,\n color 150ms ease, transform 100ms ease;\n\n &[data-selected],\n &[data-pressed] {\n background: var(--bui-bg-solid);\n color: var(--bui-fg-solid);\n }\n\n &:not([data-selected])[data-hovered] {\n background: var(--bui-bg-surface-2);\n }\n\n &[data-disabled] {\n background: var(--bui-bg-neutral-on-surface-0-disabled);\n color: var(--bui-fg-disabled);\n }\n\n &[data-disabled][data-hovered] {\n background: var(--bui-bg-neutral-on-surface-0-disabled);\n }\n\n &[data-disabled][data-selected] {\n background: var(--bui-bg-solid-disabled);\n color: var(--bui-fg-disabled);\n }\n }\n\n .ToggleButton-module_bui-ToggleButton__1CL1A[data-focus-visible] {\n outline: none;\n box-shadow: inset 0 0 0 2px var(--bui-ring);\n }\n\n .ToggleButton-module_bui-ToggleButton__1CL1A[data-disabled] {\n cursor: not-allowed;\n }\n\n .ToggleButton-module_bui-ToggleButton__1CL1A[data-pressed] {\n transform: scale(0.98);\n }\n\n .ToggleButton-module_bui-ToggleButton__1CL1A[data-disabled][data-pressed] {\n transform: none;\n }\n\n .ToggleButton-module_bui-ToggleButton__1CL1A[data-size='small'] {\n height: 2rem;\n font-size: var(--bui-font-size-3);\n padding: 0 var(--bui-space-2);\n\n svg {\n width: 1rem;\n height: 1rem;\n }\n }\n\n .ToggleButton-module_bui-ToggleButton__1CL1A[data-size='medium'] {\n height: 2.5rem;\n font-size: var(--bui-font-size-4);\n padding: 0 var(--bui-space-3);\n\n svg {\n width: 1.25rem;\n height: 1.25rem;\n }\n }\n\n .ToggleButton-module_bui-ToggleButtonContent__1Pq3O {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--bui-space-1_5);\n height: 100%;\n width: 100%;\n }\n}\n";
4
+ var styles = {"bui-ToggleButton":"ToggleButton-module_bui-ToggleButton__1CL1A","bui-ToggleButtonContent":"ToggleButton-module_bui-ToggleButtonContent__1Pq3O"};
5
+ styleInject(css_248z);
6
+
7
+ export { styles as default };
8
+ //# sourceMappingURL=ToggleButton.module.css.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleButton.module.css.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,12 @@
1
+ const ToggleButtonDefinition = {
2
+ classNames: {
3
+ root: "bui-ToggleButton",
4
+ content: "bui-ToggleButtonContent"
5
+ },
6
+ dataAttributes: {
7
+ size: ["small", "medium"]
8
+ }
9
+ };
10
+
11
+ export { ToggleButtonDefinition };
12
+ //# sourceMappingURL=definition.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.esm.js","sources":["../../../src/components/ToggleButton/definition.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 */\n\nimport type { ComponentDefinition } from '../../types';\n\n/**\n * Component definition for ToggleButton\n * @public\n */\nexport const ToggleButtonDefinition = {\n classNames: {\n root: 'bui-ToggleButton',\n content: 'bui-ToggleButtonContent',\n },\n dataAttributes: {\n size: ['small', 'medium'] as const,\n },\n} as const satisfies ComponentDefinition;\n"],"names":[],"mappings":"AAsBO,MAAM,sBAAA,GAAyB;AAAA,EACpC,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,kBAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,IAAA,EAAM,CAAC,OAAA,EAAS,QAAQ;AAAA;AAE5B;;;;"}
@@ -0,0 +1,33 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import clsx from 'clsx';
3
+ import { forwardRef } from 'react';
4
+ import { ToggleButtonGroup as ToggleButtonGroup$1 } from 'react-aria-components';
5
+ import { useStyles } from '../../hooks/useStyles.esm.js';
6
+ import { ToggleButtonGroupDefinition } from './definition.esm.js';
7
+ import styles from './ToggleButtonGroup.module.css.esm.js';
8
+
9
+ const ToggleButtonGroup = forwardRef(
10
+ (props, ref) => {
11
+ const { classNames, dataAttributes, cleanedProps } = useStyles(
12
+ ToggleButtonGroupDefinition,
13
+ {
14
+ ...props
15
+ }
16
+ );
17
+ const { className, children, ...rest } = cleanedProps;
18
+ return /* @__PURE__ */ jsx(
19
+ ToggleButtonGroup$1,
20
+ {
21
+ className: clsx(classNames.root, styles[classNames.root], className),
22
+ ref,
23
+ ...dataAttributes,
24
+ ...rest,
25
+ children
26
+ }
27
+ );
28
+ }
29
+ );
30
+ ToggleButtonGroup.displayName = "ToggleButtonGroup";
31
+
32
+ export { ToggleButtonGroup };
33
+ //# sourceMappingURL=ToggleButtonGroup.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleButtonGroup.esm.js","sources":["../../../src/components/ToggleButtonGroup/ToggleButtonGroup.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 clsx from 'clsx';\nimport { forwardRef, Ref } from 'react';\nimport { ToggleButtonGroup as AriaToggleButtonGroup } from 'react-aria-components';\nimport type { ToggleButtonGroupProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\nimport { ToggleButtonGroupDefinition } from './definition';\nimport styles from './ToggleButtonGroup.module.css';\n\n/** @public */\nexport const ToggleButtonGroup = forwardRef(\n (props: ToggleButtonGroupProps, ref: Ref<HTMLDivElement>) => {\n const { classNames, dataAttributes, cleanedProps } = useStyles(\n ToggleButtonGroupDefinition,\n {\n ...props,\n },\n );\n\n const { className, children, ...rest } = cleanedProps;\n\n return (\n <AriaToggleButtonGroup\n className={clsx(classNames.root, styles[classNames.root], className)}\n ref={ref}\n {...dataAttributes}\n {...rest}\n >\n {children}\n </AriaToggleButtonGroup>\n );\n },\n);\n\nToggleButtonGroup.displayName = 'ToggleButtonGroup';\n"],"names":["AriaToggleButtonGroup"],"mappings":";;;;;;;;AAyBO,MAAM,iBAAA,GAAoB,UAAA;AAAA,EAC/B,CAAC,OAA+B,GAAA,KAA6B;AAC3D,IAAA,MAAM,EAAE,UAAA,EAAY,cAAA,EAAgB,YAAA,EAAa,GAAI,SAAA;AAAA,MACnD,2BAAA;AAAA,MACA;AAAA,QACE,GAAG;AAAA;AACL,KACF;AAEA,IAAA,MAAM,EAAE,SAAA,EAAW,QAAA,EAAU,GAAG,MAAK,GAAI,YAAA;AAEzC,IAAA,uBACE,GAAA;AAAA,MAACA,mBAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAW,KAAK,UAAA,CAAW,IAAA,EAAM,OAAO,UAAA,CAAW,IAAI,GAAG,SAAS,CAAA;AAAA,QACnE,GAAA;AAAA,QACC,GAAG,cAAA;AAAA,QACH,GAAG,IAAA;AAAA,QAEH;AAAA;AAAA,KACH;AAAA,EAEJ;AACF;AAEA,iBAAA,CAAkB,WAAA,GAAc,mBAAA;;;;"}
@@ -0,0 +1,8 @@
1
+ import styleInject from '../../node_modules_dist/style-inject/dist/style-inject.es.esm.js';
2
+
3
+ var css_248z = "/*\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\n@layer tokens, base, components, utilities;\n\n@layer components {\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx {\n display: inline-flex;\n align-items: center;\n flex-wrap: nowrap;\n border-radius: var(--bui-radius-2);\n overflow: hidden;\n box-shadow: inset 0 0 0 1px var(--bui-border);\n width: fit-content;\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx[data-orientation='vertical'] {\n flex-direction: column;\n align-items: stretch;\n width: fit-content;\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx > .bui-ToggleButton {\n border-radius: 0;\n margin: 0;\n box-shadow: none;\n border: 0;\n }\n\n /* Horizontal radius rules (default orientation) */\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx:not([data-orientation='vertical'])\n > .bui-ToggleButton {\n border-radius: 0;\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx:not([data-orientation='vertical'])\n > .bui-ToggleButton:first-child {\n border-radius: var(--bui-radius-2) 0 0 var(--bui-radius-2);\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx:not([data-orientation='vertical'])\n > .bui-ToggleButton:last-child {\n border-radius: 0 var(--bui-radius-2) var(--bui-radius-2) 0;\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx:not([data-orientation='vertical'])\n > .bui-ToggleButton:only-child {\n border-radius: var(--bui-radius-2);\n }\n\n /* Horizontal dividers */\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx:not([data-orientation='vertical'])\n .bui-ToggleButton\n + .bui-ToggleButton {\n border-left: 1px solid var(--bui-border);\n }\n\n /* Vertical dividers */\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx[data-orientation='vertical']\n .bui-ToggleButton {\n width: 100%;\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx[data-orientation='vertical']\n .bui-ToggleButton\n + .bui-ToggleButton {\n border-top: 1px solid var(--bui-border);\n }\n\n /* Vertical radius rules */\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx[data-orientation='vertical']\n > .bui-ToggleButton {\n border-radius: 0;\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx[data-orientation='vertical']\n > .bui-ToggleButton:first-child {\n border-radius: var(--bui-radius-2) var(--bui-radius-2) 0 0;\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx[data-orientation='vertical']\n > .bui-ToggleButton:last-child {\n border-radius: 0 0 var(--bui-radius-2) var(--bui-radius-2);\n }\n\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx[data-orientation='vertical']\n > .bui-ToggleButton:only-child {\n border-radius: var(--bui-radius-2);\n }\n\n /* Focus ring on group surface */\n .ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx:focus-visible {\n outline: 2px solid var(--bui-ring);\n outline-offset: 2px;\n }\n}\n";
4
+ var styles = {"bui-ToggleButtonGroup":"ToggleButtonGroup-module_bui-ToggleButtonGroup__2tWrx"};
5
+ styleInject(css_248z);
6
+
7
+ export { styles as default };
8
+ //# sourceMappingURL=ToggleButtonGroup.module.css.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleButtonGroup.module.css.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,11 @@
1
+ const ToggleButtonGroupDefinition = {
2
+ classNames: {
3
+ root: "bui-ToggleButtonGroup"
4
+ },
5
+ dataAttributes: {
6
+ orientation: ["horizontal", "vertical"]
7
+ }
8
+ };
9
+
10
+ export { ToggleButtonGroupDefinition };
11
+ //# sourceMappingURL=definition.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.esm.js","sources":["../../../src/components/ToggleButtonGroup/definition.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 */\n\nimport type { ComponentDefinition } from '../../types';\n\n/**\n * Component definition for ToggleButtonGroup\n * @public\n */\nexport const ToggleButtonGroupDefinition = {\n classNames: {\n root: 'bui-ToggleButtonGroup',\n },\n dataAttributes: {\n orientation: ['horizontal', 'vertical'] as const,\n },\n} as const satisfies ComponentDefinition;\n"],"names":[],"mappings":"AAsBO,MAAM,2BAAA,GAA8B;AAAA,EACzC,UAAA,EAAY;AAAA,IACV,IAAA,EAAM;AAAA,GACR;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,WAAA,EAAa,CAAC,YAAA,EAAc,UAAU;AAAA;AAE1C;;;;"}
@@ -0,0 +1,74 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useContext } from 'react';
3
+ import { createVersionedContext, createVersionedValueMap } from '@backstage/version-bridge';
4
+
5
+ const SurfaceContext = createVersionedContext("surface-context");
6
+ function incrementSurface(surface) {
7
+ if (!surface) return "0";
8
+ if (surface === "0") return "1";
9
+ if (surface === "1") return "2";
10
+ if (surface === "2" || surface === "3") return "3";
11
+ if (surface === "danger") return "danger";
12
+ if (surface === "warning") return "warning";
13
+ if (surface === "success") return "success";
14
+ if (surface === "auto") return "1";
15
+ return surface;
16
+ }
17
+ function resolveSurfaceForProvider(contextSurface, requestedSurface) {
18
+ if (!requestedSurface) {
19
+ return contextSurface;
20
+ }
21
+ if (typeof requestedSurface === "object") {
22
+ return requestedSurface;
23
+ }
24
+ if (typeof contextSurface === "object") {
25
+ if (requestedSurface === "auto") {
26
+ return "0";
27
+ }
28
+ return requestedSurface;
29
+ }
30
+ if (requestedSurface === "auto") {
31
+ return incrementSurface(contextSurface);
32
+ }
33
+ return requestedSurface;
34
+ }
35
+ function resolveSurfaceForConsumer(contextSurface, requestedSurface) {
36
+ if (!requestedSurface) {
37
+ return contextSurface;
38
+ }
39
+ if (typeof requestedSurface === "object") {
40
+ return requestedSurface;
41
+ }
42
+ if (requestedSurface === "auto") {
43
+ if (typeof contextSurface === "object") {
44
+ return "0";
45
+ }
46
+ return contextSurface;
47
+ }
48
+ return requestedSurface;
49
+ }
50
+ const SurfaceProvider = ({
51
+ surface,
52
+ children
53
+ }) => {
54
+ return /* @__PURE__ */ jsx(
55
+ SurfaceContext.Provider,
56
+ {
57
+ value: createVersionedValueMap({ 1: { surface } }),
58
+ children
59
+ }
60
+ );
61
+ };
62
+ const useSurface = (options) => {
63
+ const value = useContext(SurfaceContext)?.atVersion(1);
64
+ const context = value ?? { surface: void 0 };
65
+ const isProvider = options?.surface !== void 0;
66
+ const requestedSurface = options?.surface ?? options?.onSurface;
67
+ const resolvedSurface = isProvider ? resolveSurfaceForProvider(context.surface, requestedSurface) : resolveSurfaceForConsumer(context.surface, requestedSurface);
68
+ return {
69
+ surface: resolvedSurface
70
+ };
71
+ };
72
+
73
+ export { SurfaceProvider, resolveSurfaceForProvider, useSurface };
74
+ //# sourceMappingURL=useSurface.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSurface.esm.js","sources":["../../src/hooks/useSurface.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 { useContext, ReactNode } from 'react';\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport { Surface, Responsive } from '../types';\n\n/** @public */\nexport interface SurfaceContextValue {\n surface: Responsive<Surface> | undefined;\n}\n\n/** @public */\nexport interface SurfaceProviderProps {\n surface: Responsive<Surface>;\n children: ReactNode;\n}\n\n/** @public */\nexport interface UseSurfaceOptions {\n /**\n * The surface value this component CREATES for its children (container behavior).\n * When 'auto', increments from parent surface.\n *\n * Use this for components like Box, Flex, Grid that establish surface context.\n */\n surface?: Responsive<Surface>;\n /**\n * The surface value this component is ON for styling (leaf behavior).\n * When 'auto', inherits from current surface.\n *\n * Use this for leaf components like Button that consume surface for styling.\n */\n onSurface?: Responsive<Surface>;\n}\n\nconst SurfaceContext = createVersionedContext<{\n 1: SurfaceContextValue;\n}>('surface-context');\n\n/**\n * Increments a surface level by one, capping at '3'.\n * Intent surfaces (danger, warning, success) remain unchanged.\n *\n * @internal\n */\nfunction incrementSurface(surface: Surface | undefined): Surface {\n if (!surface) return '0'; // no context = root level\n if (surface === '0') return '1';\n if (surface === '1') return '2';\n if (surface === '2' || surface === '3') return '3'; // cap at max\n // Intent surfaces remain unchanged\n if (surface === 'danger') return 'danger';\n if (surface === 'warning') return 'warning';\n if (surface === 'success') return 'success';\n // 'auto' should not appear here, but handle it defensively\n if (surface === 'auto') return '1';\n return surface;\n}\n\n/**\n * Resolves a surface value for containers (SurfaceProvider).\n * When 'auto' is used, increments from the parent surface.\n * For responsive surfaces (objects), returns them as-is without resolution.\n *\n * @param contextSurface - The surface from context\n * @param requestedSurface - The requested surface value (may be 'auto')\n * @returns The resolved surface value\n * @internal\n */\nexport function resolveSurfaceForProvider(\n contextSurface: Responsive<Surface> | undefined,\n requestedSurface: Responsive<Surface> | undefined,\n): Responsive<Surface> | undefined {\n if (!requestedSurface) {\n return contextSurface;\n }\n\n // If requestedSurface is a responsive object (breakpoint-based), return as-is\n if (typeof requestedSurface === 'object') {\n return requestedSurface;\n }\n\n // If contextSurface is a responsive object, we can't auto-increment from it\n // Return the requested surface as-is or default to '0' for auto\n if (typeof contextSurface === 'object') {\n if (requestedSurface === 'auto') {\n return '0'; // fallback to root when context is responsive\n }\n return requestedSurface;\n }\n\n // For containers, 'auto' means increment to create a new elevated context\n if (requestedSurface === 'auto') {\n return incrementSurface(contextSurface);\n }\n\n return requestedSurface;\n}\n\n/**\n * Resolves a surface value for leaf components (useSurface hook).\n * When 'auto' is used, inherits the current surface (doesn't increment).\n * For responsive surfaces (objects), returns them as-is without resolution.\n *\n * @param contextSurface - The surface from context\n * @param requestedSurface - The requested surface value (may be 'auto')\n * @returns The resolved surface value\n * @internal\n */\nfunction resolveSurfaceForConsumer(\n contextSurface: Responsive<Surface> | undefined,\n requestedSurface: Responsive<Surface> | undefined,\n): Responsive<Surface> | undefined {\n if (!requestedSurface) {\n return contextSurface;\n }\n\n // If requestedSurface is a responsive object (breakpoint-based), return as-is\n if (typeof requestedSurface === 'object') {\n return requestedSurface;\n }\n\n // For leaf components, 'auto' means inherit the current surface\n if (requestedSurface === 'auto') {\n // If context is responsive, fallback to '0'\n if (typeof contextSurface === 'object') {\n return '0';\n }\n return contextSurface;\n }\n\n return requestedSurface;\n}\n\n/**\n * Provider component that establishes the surface context for child components.\n * This allows components to adapt their styling based on their background surface.\n *\n * Note: The surface value should already be resolved before passing to this provider.\n * Container components should use useSurface with the surface parameter.\n *\n * @internal\n */\nexport const SurfaceProvider = ({\n surface,\n children,\n}: SurfaceProviderProps) => {\n return (\n <SurfaceContext.Provider\n value={createVersionedValueMap({ 1: { surface } })}\n >\n {children}\n </SurfaceContext.Provider>\n );\n};\n\n/**\n * Hook to access the current surface context.\n * Returns the current surface level, or undefined if no provider is present.\n *\n * The parameter name determines the behavior:\n * - `surface`: Container behavior - 'auto' increments from parent\n * - `onSurface`: Leaf behavior - 'auto' inherits from parent\n *\n * @param options - Optional configuration for surface resolution\n * @internal\n */\nexport const useSurface = (\n options?: UseSurfaceOptions,\n): SurfaceContextValue => {\n const value = useContext(SurfaceContext)?.atVersion(1);\n const context = value ?? { surface: undefined };\n\n // Infer behavior from which parameter is provided\n // 'surface' = provider behavior (increment)\n // 'onSurface' = consumer behavior (inherit)\n const isProvider = options?.surface !== undefined;\n const requestedSurface = options?.surface ?? options?.onSurface;\n\n const resolvedSurface = isProvider\n ? resolveSurfaceForProvider(context.surface, requestedSurface)\n : res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