@backstage/ui 0.10.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.
- package/CHANGELOG.md +77 -0
- package/css/styles.css +43 -17
- package/dist/components/Box/Box.esm.js +13 -6
- package/dist/components/Box/Box.esm.js.map +1 -1
- package/dist/components/Box/Box.module.css.esm.js +1 -1
- package/dist/components/Box/definition.esm.js +4 -1
- package/dist/components/Box/definition.esm.js.map +1 -1
- package/dist/components/Button/Button.esm.js +12 -1
- package/dist/components/Button/Button.esm.js.map +1 -1
- package/dist/components/Button/Button.module.css.esm.js +1 -1
- package/dist/components/Flex/Flex.esm.js +14 -6
- package/dist/components/Flex/Flex.esm.js.map +1 -1
- package/dist/components/Flex/Flex.module.css.esm.js +1 -1
- package/dist/components/Flex/definition.esm.js +4 -1
- package/dist/components/Flex/definition.esm.js.map +1 -1
- package/dist/components/Grid/Grid.esm.js +27 -12
- package/dist/components/Grid/Grid.esm.js.map +1 -1
- package/dist/components/Grid/Grid.module.css.esm.js +2 -2
- package/dist/components/Grid/definition.esm.js +8 -2
- package/dist/components/Grid/definition.esm.js.map +1 -1
- package/dist/components/Header/Header.module.css.esm.js +1 -1
- package/dist/components/Link/Link.esm.js +9 -6
- package/dist/components/Link/Link.esm.js.map +1 -1
- package/dist/components/SearchField/SearchField.esm.js +14 -21
- package/dist/components/SearchField/SearchField.esm.js.map +1 -1
- package/dist/components/SearchField/SearchField.module.css.esm.js +1 -1
- package/dist/components/Table/Table.module.css.esm.js +1 -1
- package/dist/components/Table/components/Table.esm.js +154 -15
- package/dist/components/Table/components/Table.esm.js.map +1 -1
- package/dist/components/Table/components/TableRoot.esm.js +26 -0
- package/dist/components/Table/components/TableRoot.esm.js.map +1 -0
- package/dist/components/Table/definition.esm.js +3 -0
- package/dist/components/Table/definition.esm.js.map +1 -1
- package/dist/components/Table/hooks/useCompletePagination.esm.js +106 -0
- package/dist/components/Table/hooks/useCompletePagination.esm.js.map +1 -0
- package/dist/components/Table/hooks/useCursorPagination.esm.js +58 -0
- package/dist/components/Table/hooks/useCursorPagination.esm.js.map +1 -0
- package/dist/components/Table/hooks/useDebouncedReload.esm.js +17 -0
- package/dist/components/Table/hooks/useDebouncedReload.esm.js.map +1 -0
- package/dist/components/Table/hooks/useOffsetPagination.esm.js +64 -0
- package/dist/components/Table/hooks/useOffsetPagination.esm.js.map +1 -0
- package/dist/components/Table/hooks/usePageCache.esm.js +168 -0
- package/dist/components/Table/hooks/usePageCache.esm.js.map +1 -0
- package/dist/components/Table/hooks/useQueryState.esm.js +42 -0
- package/dist/components/Table/hooks/useQueryState.esm.js.map +1 -0
- package/dist/components/Table/hooks/useStableCallback.esm.js +10 -0
- package/dist/components/Table/hooks/useStableCallback.esm.js.map +1 -0
- package/dist/components/Table/hooks/useTable.esm.js +80 -99
- package/dist/components/Table/hooks/useTable.esm.js.map +1 -1
- package/dist/components/TablePagination/TablePagination.esm.js +76 -101
- package/dist/components/TablePagination/TablePagination.esm.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.esm.js +51 -0
- package/dist/components/ToggleButton/ToggleButton.esm.js.map +1 -0
- package/dist/components/ToggleButton/ToggleButton.module.css.esm.js +8 -0
- package/dist/components/ToggleButton/ToggleButton.module.css.esm.js.map +1 -0
- package/dist/components/ToggleButton/definition.esm.js +12 -0
- package/dist/components/ToggleButton/definition.esm.js.map +1 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.esm.js +33 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.esm.js.map +1 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.module.css.esm.js +8 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.module.css.esm.js.map +1 -0
- package/dist/components/ToggleButtonGroup/definition.esm.js +11 -0
- package/dist/components/ToggleButtonGroup/definition.esm.js.map +1 -0
- package/dist/hooks/useSurface.esm.js +74 -0
- package/dist/hooks/useSurface.esm.js.map +1 -0
- package/dist/index.d.ts +306 -92
- package/dist/index.esm.js +5 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styleInject from '../../node_modules_dist/style-inject/dist/style-inject.es.esm.js';
|
|
2
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 .Header-module_bui-HeaderToolbar__1HcPN {\n margin-bottom: var(--bui-space-6);\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0px;\n right: 0px;\n height: 16px;\n background-color: var(--bui-bg);\n z-index: 0;\n }\n\n &[data-has-tabs='true'] {\n margin-bottom: 0;\n }\n }\n\n .Header-module_bui-HeaderToolbarWrapper__1WJwf {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n background-color: var(--bui-bg-surface-1);\n padding-inline: var(--bui-space-5);\n border-bottom: 1px solid var(--bui-border);\n color: var(--bui-fg-primary);\n height: 52px;\n }\n\n .Header-module_bui-HeaderToolbarContent__8b9nS {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n }\n\n .Header-module_bui-HeaderToolbarName__2E-_b {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n font-size: var(--bui-font-size-3);\n font-weight: var(--bui-font-weight-regular);\n flex-shrink: 0;\n }\n\n .Header-module_bui-HeaderToolbarIcon__1JjN5 {\n width: 16px;\n height: 16px;\n color: var(--bui-fg-primary);\n\n & svg {\n width: 100%;\n height: 100%;\n }\n }\n\n .Header-module_bui-HeaderToolbarControls__1EtQC {\n position: absolute;\n right: var(--bui-space-5);\n top: 50%;\n transform: translateY(-50%);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n }\n\n .Header-module_bui-HeaderTabsWrapper__19BXF {\n margin-bottom: var(--bui-space-4);\n padding-inline: var(--bui-space-3);\n border-bottom: 1px solid var(--bui-border);\n background-color: var(--bui-bg-surface-1);\n }\n}\n";
|
|
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 .Header-module_bui-HeaderToolbar__1HcPN {\n margin-bottom: var(--bui-space-6);\n\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0px;\n right: 0px;\n height: 16px;\n background-color: var(--bui-bg-surface-0);\n z-index: 0;\n }\n\n &[data-has-tabs='true'] {\n margin-bottom: 0;\n }\n }\n\n .Header-module_bui-HeaderToolbarWrapper__1WJwf {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n background-color: var(--bui-bg-surface-1);\n padding-inline: var(--bui-space-5);\n border-bottom: 1px solid var(--bui-border);\n color: var(--bui-fg-primary);\n height: 52px;\n }\n\n .Header-module_bui-HeaderToolbarContent__8b9nS {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n }\n\n .Header-module_bui-HeaderToolbarName__2E-_b {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n font-size: var(--bui-font-size-3);\n font-weight: var(--bui-font-weight-regular);\n flex-shrink: 0;\n }\n\n .Header-module_bui-HeaderToolbarIcon__1JjN5 {\n width: 16px;\n height: 16px;\n color: var(--bui-fg-primary);\n\n & svg {\n width: 100%;\n height: 100%;\n }\n }\n\n .Header-module_bui-HeaderToolbarControls__1EtQC {\n position: absolute;\n right: var(--bui-space-5);\n top: 50%;\n transform: translateY(-50%);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n }\n\n .Header-module_bui-HeaderTabsWrapper__19BXF {\n margin-bottom: var(--bui-space-4);\n padding-inline: var(--bui-space-3);\n border-bottom: 1px solid var(--bui-border);\n background-color: var(--bui-bg-surface-1);\n }\n}\n";
|
|
4
4
|
var styles = {"bui-HeaderToolbar":"Header-module_bui-HeaderToolbar__1HcPN","bui-HeaderToolbarWrapper":"Header-module_bui-HeaderToolbarWrapper__1WJwf","bui-HeaderToolbarContent":"Header-module_bui-HeaderToolbarContent__8b9nS","bui-HeaderToolbarName":"Header-module_bui-HeaderToolbarName__2E-_b","bui-HeaderToolbarIcon":"Header-module_bui-HeaderToolbarIcon__1JjN5","bui-HeaderToolbarControls":"Header-module_bui-HeaderToolbarControls__1EtQC","bui-HeaderTabsWrapper":"Header-module_bui-HeaderTabsWrapper__19BXF"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
@@ -9,8 +9,7 @@ import { useNavigate, useHref } from 'react-router-dom';
|
|
|
9
9
|
import { isExternalLink } from '../../utils/isExternalLink.esm.js';
|
|
10
10
|
import styles from './Link.module.css.esm.js';
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const navigate = useNavigate();
|
|
12
|
+
const LinkInternal = forwardRef((props, ref) => {
|
|
14
13
|
const { classNames, dataAttributes, cleanedProps } = useStyles(
|
|
15
14
|
LinkDefinition,
|
|
16
15
|
{
|
|
@@ -33,7 +32,6 @@ const Link = forwardRef((props, ref) => {
|
|
|
33
32
|
slot,
|
|
34
33
|
...restProps
|
|
35
34
|
} = cleanedProps;
|
|
36
|
-
const isExternal = isExternalLink(href);
|
|
37
35
|
const internalRef = useRef(null);
|
|
38
36
|
const linkRef = ref || internalRef;
|
|
39
37
|
const { linkProps } = useLink(
|
|
@@ -44,7 +42,7 @@ const Link = forwardRef((props, ref) => {
|
|
|
44
42
|
},
|
|
45
43
|
linkRef
|
|
46
44
|
);
|
|
47
|
-
|
|
45
|
+
return /* @__PURE__ */ jsx(
|
|
48
46
|
"a",
|
|
49
47
|
{
|
|
50
48
|
...linkProps,
|
|
@@ -57,10 +55,15 @@ const Link = forwardRef((props, ref) => {
|
|
|
57
55
|
children
|
|
58
56
|
}
|
|
59
57
|
);
|
|
58
|
+
});
|
|
59
|
+
LinkInternal.displayName = "LinkInternal";
|
|
60
|
+
const Link = forwardRef((props, ref) => {
|
|
61
|
+
const navigate = useNavigate();
|
|
62
|
+
const isExternal = isExternalLink(props.href);
|
|
60
63
|
if (isExternal) {
|
|
61
|
-
return
|
|
64
|
+
return /* @__PURE__ */ jsx(LinkInternal, { ...props, ref });
|
|
62
65
|
}
|
|
63
|
-
return /* @__PURE__ */ jsx(RouterProvider, { navigate, useHref, children:
|
|
66
|
+
return /* @__PURE__ */ jsx(RouterProvider, { navigate, useHref, children: /* @__PURE__ */ jsx(LinkInternal, { ...props, ref }) });
|
|
64
67
|
});
|
|
65
68
|
Link.displayName = "Link";
|
|
66
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.esm.js","sources":["../../../src/components/Link/Link.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, useRef } from 'react';\nimport { useLink } from 'react-aria';\nimport { RouterProvider } from 'react-aria-components';\nimport clsx from 'clsx';\nimport { useStyles } from '../../hooks/useStyles';\nimport { LinkDefinition } from './definition';\nimport type { LinkProps } from './types';\nimport { useNavigate, useHref } from 'react-router-dom';\nimport { isExternalLink } from '../../utils/isExternalLink';\nimport styles from './Link.module.css';\n\
|
|
1
|
+
{"version":3,"file":"Link.esm.js","sources":["../../../src/components/Link/Link.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, useRef } from 'react';\nimport { useLink } from 'react-aria';\nimport { RouterProvider } from 'react-aria-components';\nimport clsx from 'clsx';\nimport { useStyles } from '../../hooks/useStyles';\nimport { LinkDefinition } from './definition';\nimport type { LinkProps } from './types';\nimport { useNavigate, useHref } from 'react-router-dom';\nimport { isExternalLink } from '../../utils/isExternalLink';\nimport styles from './Link.module.css';\n\nconst LinkInternal = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {\n const { classNames, dataAttributes, cleanedProps } = useStyles(\n LinkDefinition,\n {\n variant: 'body',\n weight: 'regular',\n color: 'primary',\n ...props,\n },\n );\n\n const {\n className,\n href,\n title,\n children,\n onPress,\n variant,\n weight,\n color,\n truncate,\n slot,\n ...restProps\n } = cleanedProps;\n\n const internalRef = useRef<HTMLAnchorElement>(null);\n const linkRef = (ref || internalRef) as React.RefObject<HTMLAnchorElement>;\n\n // Use useLink hook to get link props\n // For internal links, this will use the RouterProvider's navigate function\n const { linkProps } = useLink(\n {\n href,\n onPress,\n ...restProps,\n },\n linkRef,\n );\n\n return (\n <a\n {...linkProps}\n {...dataAttributes}\n {...(restProps as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={linkRef}\n href={href}\n title={title}\n className={clsx(classNames.root, styles[classNames.root], className)}\n >\n {children}\n </a>\n );\n});\n\nLinkInternal.displayName = 'LinkInternal';\n\n/** @public */\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {\n const navigate = useNavigate();\n const isExternal = isExternalLink(props.href);\n\n // If it's an external link, render without RouterProvider\n if (isExternal) {\n return <LinkInternal {...props} ref={ref} />;\n }\n\n // For internal links, wrap in RouterProvider so useLink can access the router\n return (\n <RouterProvider navigate={navigate} useHref={useHref}>\n <LinkInternal {...props} ref={ref} />\n </RouterProvider>\n );\n});\n\nLink.displayName = 'Link';\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA,MAAM,YAAA,GAAe,UAAA,CAAyC,CAAC,KAAA,EAAO,GAAA,KAAQ;AAC5E,EAAA,MAAM,EAAE,UAAA,EAAY,cAAA,EAAgB,YAAA,EAAa,GAAI,SAAA;AAAA,IACnD,cAAA;AAAA,IACA;AAAA,MACE,OAAA,EAAS,MAAA;AAAA,MACT,MAAA,EAAQ,SAAA;AAAA,MACR,KAAA,EAAO,SAAA;AAAA,MACP,GAAG;AAAA;AACL,GACF;AAEA,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,YAAA;AAEJ,EAAA,MAAM,WAAA,GAAc,OAA0B,IAAI,CAAA;AAClD,EAAA,MAAM,UAAW,GAAA,IAAO,WAAA;AAIxB,EAAA,MAAM,EAAE,WAAU,GAAI,OAAA;AAAA,IACpB;AAAA,MACE,IAAA;AAAA,MACA,OAAA;AAAA,MACA,GAAG;AAAA,KACL;AAAA,IACA;AAAA,GACF;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACE,GAAG,SAAA;AAAA,MACH,GAAG,cAAA;AAAA,MACH,GAAI,SAAA;AAAA,MACL,GAAA,EAAK,OAAA;AAAA,MACL,IAAA;AAAA,MACA,KAAA;AAAA,MACA,SAAA,EAAW,KAAK,UAAA,CAAW,IAAA,EAAM,OAAO,UAAA,CAAW,IAAI,GAAG,SAAS,CAAA;AAAA,MAElE;AAAA;AAAA,GACH;AAEJ,CAAC,CAAA;AAED,YAAA,CAAa,WAAA,GAAc,cAAA;AAGpB,MAAM,IAAA,GAAO,UAAA,CAAyC,CAAC,KAAA,EAAO,GAAA,KAAQ;AAC3E,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,UAAA,GAAa,cAAA,CAAe,KAAA,CAAM,IAAI,CAAA;AAG5C,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,uBAAO,GAAA,CAAC,YAAA,EAAA,EAAc,GAAG,KAAA,EAAO,GAAA,EAAU,CAAA;AAAA,EAC5C;AAGA,EAAA,uBACE,GAAA,CAAC,kBAAe,QAAA,EAAoB,OAAA,EAClC,8BAAC,YAAA,EAAA,EAAc,GAAG,KAAA,EAAO,GAAA,EAAU,CAAA,EACrC,CAAA;AAEJ,CAAC;AAED,IAAA,CAAK,WAAA,GAAc,MAAA;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useState,
|
|
2
|
+
import { forwardRef, useEffect, useState, useRef } from 'react';
|
|
3
3
|
import { SearchField as SearchField$1, Input, Button } from 'react-aria-components';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { FieldLabel } from '../FieldLabel/FieldLabel.esm.js';
|
|
@@ -16,8 +16,6 @@ const SearchField = forwardRef(
|
|
|
16
16
|
"aria-label": ariaLabel,
|
|
17
17
|
"aria-labelledby": ariaLabelledBy
|
|
18
18
|
} = props;
|
|
19
|
-
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
20
|
-
const [shouldCollapse, setShouldCollapse] = useState(true);
|
|
21
19
|
useEffect(() => {
|
|
22
20
|
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
23
21
|
console.warn(
|
|
@@ -44,25 +42,19 @@ const SearchField = forwardRef(
|
|
|
44
42
|
startCollapsed,
|
|
45
43
|
...rest
|
|
46
44
|
} = cleanedProps;
|
|
45
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
46
|
+
const inputRef = useRef(null);
|
|
47
47
|
const secondaryLabelText = secondaryLabel || (isRequired ? "Required" : null);
|
|
48
|
-
const
|
|
49
|
-
props.onFocusChange?.(
|
|
50
|
-
|
|
51
|
-
if (isFocused) {
|
|
52
|
-
setIsCollapsed(true);
|
|
53
|
-
} else {
|
|
54
|
-
setIsCollapsed(false);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
48
|
+
const handleFocusChange = (isFocused2) => {
|
|
49
|
+
props.onFocusChange?.(isFocused2);
|
|
50
|
+
setIsFocused(isFocused2);
|
|
57
51
|
};
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
if (value.length > 0) {
|
|
61
|
-
setShouldCollapse(false);
|
|
62
|
-
} else {
|
|
63
|
-
setShouldCollapse(true);
|
|
64
|
-
}
|
|
52
|
+
const handleContainerClick = () => {
|
|
53
|
+
inputRef.current?.focus();
|
|
65
54
|
};
|
|
55
|
+
const hasInputRef = !!inputRef.current;
|
|
56
|
+
const hasValue = !!inputRef.current?.value;
|
|
57
|
+
const isCollapsed = hasInputRef ? startCollapsed && !hasValue && !isFocused : startCollapsed && !rest.value && !rest.defaultValue && !isFocused;
|
|
66
58
|
return /* @__PURE__ */ jsxs(
|
|
67
59
|
SearchField$1,
|
|
68
60
|
{
|
|
@@ -71,10 +63,9 @@ const SearchField = forwardRef(
|
|
|
71
63
|
"aria-label": ariaLabel,
|
|
72
64
|
"aria-labelledby": ariaLabelledBy,
|
|
73
65
|
"data-collapsed": isCollapsed,
|
|
74
|
-
onFocusChange: handleClick,
|
|
75
|
-
onChange: handleChange,
|
|
76
66
|
style,
|
|
77
67
|
...rest,
|
|
68
|
+
onFocusChange: handleFocusChange,
|
|
78
69
|
ref,
|
|
79
70
|
children: [
|
|
80
71
|
/* @__PURE__ */ jsx(
|
|
@@ -93,6 +84,7 @@ const SearchField = forwardRef(
|
|
|
93
84
|
styles[classNames.inputWrapper]
|
|
94
85
|
),
|
|
95
86
|
"data-size": dataAttributes["data-size"],
|
|
87
|
+
onClick: handleContainerClick,
|
|
96
88
|
children: [
|
|
97
89
|
icon !== false && /* @__PURE__ */ jsx(
|
|
98
90
|
"div",
|
|
@@ -109,6 +101,7 @@ const SearchField = forwardRef(
|
|
|
109
101
|
/* @__PURE__ */ jsx(
|
|
110
102
|
Input,
|
|
111
103
|
{
|
|
104
|
+
ref: inputRef,
|
|
112
105
|
className: clsx(classNames.input, styles[classNames.input]),
|
|
113
106
|
...icon !== false && { "data-icon": true },
|
|
114
107
|
placeholder
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchField.esm.js","sources":["../../../src/components/SearchField/SearchField.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, useState } from 'react';\nimport {\n Input,\n SearchField as AriaSearchField,\n Button,\n} from 'react-aria-components';\nimport clsx from 'clsx';\nimport { FieldLabel } from '../FieldLabel';\nimport { FieldError } from '../FieldError';\nimport { RiSearch2Line, RiCloseCircleLine } from '@remixicon/react';\nimport { useStyles } from '../../hooks/useStyles';\nimport { SearchFieldDefinition } from './definition';\nimport styles from './SearchField.module.css';\n\nimport type { SearchFieldProps } from './types';\n\n/** @public */\nexport const SearchField = forwardRef<HTMLDivElement, SearchFieldProps>(\n (props, ref) => {\n const {\n label,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n } = props;\n\n
|
|
1
|
+
{"version":3,"file":"SearchField.esm.js","sources":["../../../src/components/SearchField/SearchField.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, useState, useRef } from 'react';\nimport {\n Input,\n SearchField as AriaSearchField,\n Button,\n} from 'react-aria-components';\nimport clsx from 'clsx';\nimport { FieldLabel } from '../FieldLabel';\nimport { FieldError } from '../FieldError';\nimport { RiSearch2Line, RiCloseCircleLine } from '@remixicon/react';\nimport { useStyles } from '../../hooks/useStyles';\nimport { SearchFieldDefinition } from './definition';\nimport styles from './SearchField.module.css';\n\nimport type { SearchFieldProps } from './types';\n\n/** @public */\nexport const SearchField = forwardRef<HTMLDivElement, SearchFieldProps>(\n (props, ref) => {\n const {\n label,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n } = props;\n\n useEffect(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n 'SearchField requires either a visible label, aria-label, or aria-labelledby for accessibility',\n );\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n const { classNames, dataAttributes, style, cleanedProps } = useStyles(\n SearchFieldDefinition,\n {\n size: 'small',\n placeholder: 'Search',\n startCollapsed: false,\n ...props,\n },\n );\n\n const {\n className,\n description,\n icon,\n isRequired,\n secondaryLabel,\n placeholder,\n startCollapsed,\n ...rest\n } = cleanedProps;\n\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\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 const handleFocusChange = (isFocused: boolean) => {\n props.onFocusChange?.(isFocused);\n setIsFocused(isFocused);\n };\n\n const handleContainerClick = () => {\n inputRef.current?.focus();\n };\n\n const hasInputRef = !!inputRef.current;\n const hasValue = !!inputRef.current?.value;\n\n const isCollapsed = hasInputRef\n ? startCollapsed && !hasValue && !isFocused\n : startCollapsed && !rest.value && !rest.defaultValue && !isFocused;\n\n return (\n <AriaSearchField\n className={clsx(classNames.root, styles[classNames.root], className)}\n {...dataAttributes}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n data-collapsed={isCollapsed}\n style={style}\n {...rest}\n onFocusChange={handleFocusChange}\n ref={ref}\n >\n <FieldLabel\n label={label}\n secondaryLabel={secondaryLabelText}\n description={description}\n />\n <div\n className={clsx(\n classNames.inputWrapper,\n styles[classNames.inputWrapper],\n )}\n data-size={dataAttributes['data-size']}\n onClick={handleContainerClick}\n >\n {icon !== false && (\n <div\n className={clsx(\n classNames.inputIcon,\n styles[classNames.inputIcon],\n )}\n data-size={dataAttributes['data-size']}\n aria-hidden=\"true\"\n >\n {icon || <RiSearch2Line />}\n </div>\n )}\n <Input\n ref={inputRef}\n className={clsx(classNames.input, styles[classNames.input])}\n {...(icon !== false && { 'data-icon': true })}\n placeholder={placeholder}\n />\n <Button\n className={clsx(classNames.clear, styles[classNames.clear])}\n data-size={dataAttributes['data-size']}\n >\n <RiCloseCircleLine />\n </Button>\n </div>\n <FieldError />\n </Ari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BACR,GAAA;AAAA,kBAAC,KAAA;AAAA,kBAAA;AAAA,oBACC,SAAA,EAAW,IAAA;AAAA,sBACT,UAAA,CAAW,SAAA;AAAA,sBACX,MAAA,CAAO,WAAW,SAAS;AAAA,qBAC7B;AAAA,oBACA,WAAA,EAAW,eAAe,WAAW,CAAA;AAAA,oBACrC,aAAA,EAAY,MAAA;AAAA,oBAEX,QAAA,EAAA,IAAA,wBAAS,aAAA,EAAA,EAAc;AAAA;AAAA,iBAC1B;AAAA,gCAEF,GAAA;AAAA,kBAAC,KAAA;AAAA,kBAAA;AAAA,oBACC,GAAA,EAAK,QAAA;AAAA,oBACL,WAAW,IAAA,CAAK,UAAA,CAAW,OAAO,MAAA,CAAO,UAAA,CAAW,KAAK,CAAC,CAAA;AAAA,oBACzD,GAAI,IAAA,KAAS,KAAA,IAAS,EAAE,aAAa,IAAA,EAAK;AAAA,oBAC3C;AAAA;AAAA,iBACF;AAAA,gCACA,GAAA;AAAA,kBAAC,MAAA;AAAA,kBAAA;AAAA,oBACC,WAAW,IAAA,CAAK,UAAA,CAAW,OAAO,MAAA,CAAO,UAAA,CAAW,KAAK,CAAC,CAAA;AAAA,oBAC1D,WAAA,EAAW,eAAe,WAAW,CAAA;AAAA,oBAErC,8BAAC,iBAAA,EAAA,EAAkB;AAAA;AAAA;AACrB;AAAA;AAAA,WACF;AAAA,8BACC,UAAA,EAAA,EAAW;AAAA;AAAA;AAAA,KACd;AAAA,EAEJ;AACF;AAEA,WAAA,CAAY,WAAA,GAAc,aAAA;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styleInject from '../../node_modules_dist/style-inject/dist/style-inject.es.esm.js';
|
|
2
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 .SearchField-module_bui-SearchField__2TyT_ {\n display: flex;\n flex-direction: column;\n font-family: var(--bui-font-regular);\n width: 100%;\n flex: 1;\n flex-shrink: 0;\n\n &[data-size='small'] {\n --search-field-item-height: 2rem;\n }\n\n &[data-size='medium'] {\n --search-field-item-height: 2.5rem;\n }\n\n &[data-empty] {\n .SearchField-module_bui-SearchFieldClear__1gJQc {\n display: none;\n }\n }\n\n &[data-startCollapsed='true'] {\n transition: flex-basis 0.3s ease-in-out;\n padding: 0;\n flex: 0 1 auto;\n\n &[data-collapsed='true'] {\n
|
|
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 .SearchField-module_bui-SearchField__2TyT_ {\n display: flex;\n flex-direction: column;\n font-family: var(--bui-font-regular);\n width: 100%;\n flex: 1;\n flex-shrink: 0;\n\n &[data-size='small'] {\n --search-field-item-height: 2rem;\n }\n\n &[data-size='medium'] {\n --search-field-item-height: 2.5rem;\n }\n\n &[data-empty] {\n .SearchField-module_bui-SearchFieldClear__1gJQc {\n display: none;\n }\n }\n\n &[data-startCollapsed='true'] {\n transition: flex-basis 0.3s ease-in-out, width 0.3s ease-in-out,\n max-width 0.3s ease-in-out;\n padding: 0;\n flex: 0 1 auto;\n\n &[data-collapsed='true'] {\n cursor: pointer;\n\n &[data-size='medium'] {\n flex-basis: 2.5rem;\n width: 2.5rem;\n max-width: 2.5rem;\n height: 2.5rem;\n }\n\n &[data-size='small'] {\n flex-basis: 2rem;\n width: 2rem;\n max-width: 2rem;\n height: 2rem;\n }\n\n &[data-size='medium'] .SearchField-module_bui-SearchFieldInput__3Opoj {\n &::placeholder {\n opacity: 0;\n }\n }\n\n &[data-size='small'] .SearchField-module_bui-SearchFieldInput__3Opoj {\n &::placeholder {\n opacity: 0;\n }\n }\n\n .SearchField-module_bui-SearchFieldInputWrapper__1JEG8 {\n .SearchField-module_bui-SearchFieldInput__3Opoj[data-icon] {\n padding-right: 0px;\n }\n }\n }\n\n &[data-collapsed='false'] {\n flex-basis: 200px;\n width: 200px;\n max-width: 200px;\n }\n }\n }\n\n .SearchField-module_bui-SearchFieldInputWrapper__1JEG8 {\n display: flex;\n align-items: center;\n border-radius: var(--bui-radius-2);\n border: 1px solid var(--bui-border);\n background-color: var(--bui-bg-surface-1);\n transition: border-color 0.2s ease-in-out, outline-color 0.2s ease-in-out;\n\n &[data-size='small'] {\n height: 2rem;\n }\n\n &[data-size='medium'] {\n height: 2.5rem;\n }\n\n &:focus-within {\n border-color: var(--bui-border-pressed);\n outline-width: 0px;\n }\n\n &:hover {\n border-color: var(--bui-border-hover);\n }\n\n &[data-invalid] {\n border-color: var(--bui-fg-danger);\n }\n\n &[data-disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n border: 1px solid var(--bui-border-disabled);\n }\n }\n\n .SearchField-module_bui-SearchFieldInputIcon__EA0t9 {\n flex: 0 0 auto;\n display: grid;\n place-content: center;\n color: var(--bui-fg-primary);\n pointer-events: none;\n width: var(--search-field-item-height);\n height: var(--search-field-item-height);\n /* To animate the icon when the input is collapsed */\n transition: opacity 0.2s ease-in-out;\n\n & svg {\n .SearchField-module_bui-SearchField__2TyT_[data-size='small'] & {\n width: 1rem;\n height: 1rem;\n }\n\n .SearchField-module_bui-SearchField__2TyT_[data-size='medium'] & {\n width: 1.25rem;\n height: 1.25rem;\n }\n }\n }\n\n .SearchField-module_bui-SearchFieldInput__3Opoj {\n flex: 1;\n display: flex;\n align-items: center;\n padding: 0;\n border: none;\n background-color: transparent;\n font-size: var(--bui-font-size-3);\n font-family: var(--bui-font-regular);\n font-weight: var(--bui-font-weight-regular);\n color: var(--bui-fg-primary);\n transition: padding 0.3s ease-in-out;\n width: 100%;\n height: 100%;\n outline: none;\n cursor: inherit;\n\n &::-webkit-search-cancel-button,\n &::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n &::placeholder {\n color: var(--bui-fg-secondary);\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n }\n\n &:first-child {\n .SearchField-module_bui-SearchField__2TyT_[data-size='small'] & {\n padding-inline: var(--bui-space-3) 0;\n }\n\n .SearchField-module_bui-SearchField__2TyT_[data-size='medium'] & {\n padding-inline: var(--bui-space-3) 0;\n }\n }\n }\n\n .SearchField-module_bui-SearchFieldClear__1gJQc {\n flex: 0 0 auto;\n display: grid;\n place-content: center;\n background-color: transparent;\n border: none;\n padding: 0;\n margin: 0;\n cursor: pointer;\n color: var(--bui-fg-secondary);\n transition: color 0.2s ease-in-out;\n width: var(--search-field-item-height);\n height: var(--search-field-item-height);\n\n &:hover {\n color: var(--bui-fg-primary);\n }\n\n & svg {\n width: 1rem;\n height: 1rem;\n }\n }\n}\n";
|
|
4
4
|
var styles = {"bui-SearchField":"SearchField-module_bui-SearchField__2TyT_","bui-SearchFieldClear":"SearchField-module_bui-SearchFieldClear__1gJQc","bui-SearchFieldInput":"SearchField-module_bui-SearchFieldInput__3Opoj","bui-SearchFieldInputWrapper":"SearchField-module_bui-SearchFieldInputWrapper__1JEG8","bui-SearchFieldInputIcon":"SearchField-module_bui-SearchFieldInputIcon__EA0t9"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styleInject from '../../node_modules_dist/style-inject/dist/style-inject.es.esm.js';
|
|
2
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 .Table-module_bui-Table__BkcBL {\n width: 100%;\n caption-side: bottom;\n border-collapse: collapse;\n table-layout: fixed;\n }\n\n .Table-module_bui-TableHeader__3Lh_9 {\n border-bottom: 1px solid var(--bui-border);\n transition: color 0.2s ease-in-out;\n }\n\n .Table-module_bui-TableHead__y-Yzm {\n text-align: left;\n padding: var(--bui-space-3);\n font-size: var(--bui-font-size-3);\n color: var(--bui-fg-primary);\n\n &:hover {\n .Table-module_bui-TableHeadSortButton__Slxp- {\n opacity: 1;\n }\n }\n }\n\n .Table-module_bui-TableHeadSelection__2H6Yp {\n width: 40px;\n }\n\n .Table-module_bui-TableHeadContent__1Buiu {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-1);\n }\n\n .Table-module_bui-TableHeadSortButton__Slxp- {\n cursor: pointer;\n user-select: none;\n display: inline-flex;\n align-items: center;\n gap: var(--bui-space-1);\n opacity: 0;\n transition: opacity 0.1s ease-in-out;\n color: var(--bui-fg-secondary);\n\n & svg {\n transition: transform 0.1s ease-in-out;\n }\n\n &[data-sort-order='asc'] svg {\n opacity: 1;\n transform: rotate(0);\n }\n\n &[data-sort-order='desc'] svg {\n opacity: 1;\n transform: rotate(180deg);\n }\n }\n\n .Table-module_bui-TableBody__2hcz_ {\n color: var(--bui-fg-primary);\n }\n\n .Table-module_bui-TableRow__3S2EQ {\n border-bottom: 1px solid var(--bui-border);\n transition: color 0.2s ease-in-out;\n\n &:hover {\n background-color: var(--bui-bg-tint-hover);\n }\n\n &[data-selected] {\n background-color: var(--bui-bg-tint-pressed);\n }\n\n &[data-pressed] {\n background-color: var(--bui-bg-tint-pressed);\n }\n\n &[data-disabled] {\n background-color: var(--bui-bg-tint-disabled);\n }\n\n &[data-react-aria-pressable='true'] {\n cursor: pointer;\n }\n }\n\n .Table-module_bui-TableCell__1C-Gr {\n padding: var(--bui-space-3);\n font-size: var(--bui-font-size-3);\n font-family: var(--bui-font-regular);\n font-weight: var(--bui-font-weight-regular);\n min-width: 0;\n overflow: hidden;\n }\n\n .Table-module_bui-TableCellSelection__3g6Iz {\n width: 40px;\n }\n\n .Table-module_bui-TableCellContentWrapper__2zDK3 {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n min-width: 0;\n width: 100%;\n max-width: 100%;\n }\n\n .Table-module_bui-TableCellIcon__118Vd,\n .Table-module_bui-TableCellIcon__118Vd svg {\n display: inline-flex;\n align-items: center;\n color: var(--bui-fg-primary);\n }\n\n .Table-module_bui-TableCellContent__35knW {\n display: flex;\n flex-direction: column;\n gap: var(--bui-space-0_5);\n min-width: 0;\n flex: 1;\n overflow: hidden;\n max-width: 100%;\n }\n\n .Table-module_bui-TableCellContent__35knW > * {\n min-width: 0;\n max-width: 100%;\n }\n\n .Table-module_bui-TableCellProfile__34xxd {\n display: flex;\n flex-direction: row;\n gap: var(--bui-space-2);\n align-items: center;\n }\n}\n";
|
|
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 .Table-module_bui-Table__BkcBL {\n width: 100%;\n caption-side: bottom;\n border-collapse: collapse;\n table-layout: fixed;\n transition: opacity 0.2s ease-in-out;\n\n &[data-stale='true'] {\n opacity: 0.6;\n }\n }\n\n .Table-module_bui-TableHeader__3Lh_9 {\n border-bottom: 1px solid var(--bui-border);\n transition: color 0.2s ease-in-out;\n }\n\n .Table-module_bui-TableHead__y-Yzm {\n text-align: left;\n padding: var(--bui-space-3);\n font-size: var(--bui-font-size-3);\n color: var(--bui-fg-primary);\n\n &:hover {\n .Table-module_bui-TableHeadSortButton__Slxp- {\n opacity: 1;\n }\n }\n }\n\n .Table-module_bui-TableHeadSelection__2H6Yp {\n width: 40px;\n }\n\n .Table-module_bui-TableHeadContent__1Buiu {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-1);\n }\n\n .Table-module_bui-TableHeadSortButton__Slxp- {\n cursor: pointer;\n user-select: none;\n display: inline-flex;\n align-items: center;\n gap: var(--bui-space-1);\n opacity: 0;\n transition: opacity 0.1s ease-in-out;\n color: var(--bui-fg-secondary);\n\n & svg {\n transition: transform 0.1s ease-in-out;\n }\n\n &[data-sort-order='asc'] svg {\n opacity: 1;\n transform: rotate(0);\n }\n\n &[data-sort-order='desc'] svg {\n opacity: 1;\n transform: rotate(180deg);\n }\n }\n\n .Table-module_bui-TableBody__2hcz_ {\n color: var(--bui-fg-primary);\n }\n\n .Table-module_bui-TableRow__3S2EQ {\n border-bottom: 1px solid var(--bui-border);\n transition: color 0.2s ease-in-out;\n\n &:hover {\n background-color: var(--bui-bg-tint-hover);\n }\n\n &[data-selected] {\n background-color: var(--bui-bg-tint-pressed);\n }\n\n &[data-pressed] {\n background-color: var(--bui-bg-tint-pressed);\n }\n\n &[data-disabled] {\n background-color: var(--bui-bg-tint-disabled);\n }\n\n &[data-react-aria-pressable='true'] {\n cursor: pointer;\n }\n }\n\n .Table-module_bui-TableCell__1C-Gr {\n padding: var(--bui-space-3);\n font-size: var(--bui-font-size-3);\n font-family: var(--bui-font-regular);\n font-weight: var(--bui-font-weight-regular);\n min-width: 0;\n overflow: hidden;\n }\n\n .Table-module_bui-TableCellSelection__3g6Iz {\n width: 40px;\n }\n\n .Table-module_bui-TableCellContentWrapper__2zDK3 {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: var(--bui-space-2);\n min-width: 0;\n width: 100%;\n max-width: 100%;\n }\n\n .Table-module_bui-TableCellIcon__118Vd,\n .Table-module_bui-TableCellIcon__118Vd svg {\n display: inline-flex;\n align-items: center;\n color: var(--bui-fg-primary);\n }\n\n .Table-module_bui-TableCellContent__35knW {\n display: flex;\n flex-direction: column;\n gap: var(--bui-space-0_5);\n min-width: 0;\n flex: 1;\n overflow: hidden;\n max-width: 100%;\n }\n\n .Table-module_bui-TableCellContent__35knW > * {\n min-width: 0;\n max-width: 100%;\n }\n\n .Table-module_bui-TableCellProfile__34xxd {\n display: flex;\n flex-direction: row;\n gap: var(--bui-space-2);\n align-items: center;\n }\n}\n";
|
|
4
4
|
var styles = {"bui-Table":"Table-module_bui-Table__BkcBL","bui-TableHeader":"Table-module_bui-TableHeader__3Lh_9","bui-TableHead":"Table-module_bui-TableHead__y-Yzm","bui-TableHeadSortButton":"Table-module_bui-TableHeadSortButton__Slxp-","bui-TableHeadSelection":"Table-module_bui-TableHeadSelection__2H6Yp","bui-TableHeadContent":"Table-module_bui-TableHeadContent__1Buiu","bui-TableBody":"Table-module_bui-TableBody__2hcz_","bui-TableRow":"Table-module_bui-TableRow__3S2EQ","bui-TableCell":"Table-module_bui-TableCell__1C-Gr","bui-TableCellSelection":"Table-module_bui-TableCellSelection__3g6Iz","bui-TableCellContentWrapper":"Table-module_bui-TableCellContentWrapper__2zDK3","bui-TableCellIcon":"Table-module_bui-TableCellIcon__118Vd","bui-TableCellContent":"Table-module_bui-TableCellContent__35knW","bui-TableCellProfile":"Table-module_bui-TableCellProfile__34xxd"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
@@ -1,21 +1,160 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { TableRoot } from './TableRoot.esm.js';
|
|
3
|
+
import { TableHeader } from './TableHeader.esm.js';
|
|
4
|
+
import { TableBody } from './TableBody.esm.js';
|
|
5
|
+
import { Row } from './Row.esm.js';
|
|
6
|
+
import { Column } from './Column.esm.js';
|
|
7
|
+
import { TablePagination } from '../../TablePagination/TablePagination.esm.js';
|
|
8
|
+
import { useId, useMemo, Fragment as Fragment$1 } from 'react';
|
|
9
|
+
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden.esm.js';
|
|
10
|
+
import { Flex } from '../../Flex/Flex.esm.js';
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
function isRowRenderFn(rowConfig) {
|
|
13
|
+
return typeof rowConfig === "function";
|
|
14
|
+
}
|
|
15
|
+
function useDisabledRows({
|
|
16
|
+
data,
|
|
17
|
+
rowConfig
|
|
18
|
+
}) {
|
|
19
|
+
return useMemo(() => {
|
|
20
|
+
if (!data || typeof rowConfig === "function" || !rowConfig?.getIsDisabled) {
|
|
21
|
+
return;
|
|
16
22
|
}
|
|
23
|
+
return data.reduce((set, item) => {
|
|
24
|
+
const isDisabled = rowConfig.getIsDisabled?.(item);
|
|
25
|
+
if (isDisabled) {
|
|
26
|
+
set.add(String(item.id));
|
|
27
|
+
}
|
|
28
|
+
return set;
|
|
29
|
+
}, /* @__PURE__ */ new Set());
|
|
30
|
+
}, [data, rowConfig]);
|
|
31
|
+
}
|
|
32
|
+
function useLiveRegionLabel(pagination, isStale, hasData) {
|
|
33
|
+
if (!hasData || pagination.type === "none") {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
const { pageSize, offset, totalCount, getLabel } = pagination;
|
|
37
|
+
if (isStale) {
|
|
38
|
+
return "Loading table data.";
|
|
39
|
+
}
|
|
40
|
+
let liveRegionLabel = "Table page loaded. ";
|
|
41
|
+
if (getLabel) {
|
|
42
|
+
liveRegionLabel += getLabel({ pageSize, offset, totalCount });
|
|
43
|
+
} else if (offset !== void 0) {
|
|
44
|
+
const fromCount = offset + 1;
|
|
45
|
+
const toCount = Math.min(offset + pageSize, totalCount ?? 0);
|
|
46
|
+
liveRegionLabel += `Showing ${fromCount} to ${toCount} of ${totalCount}`;
|
|
47
|
+
}
|
|
48
|
+
return liveRegionLabel;
|
|
49
|
+
}
|
|
50
|
+
function Table({
|
|
51
|
+
columnConfig,
|
|
52
|
+
data,
|
|
53
|
+
loading = false,
|
|
54
|
+
isStale = false,
|
|
55
|
+
error,
|
|
56
|
+
pagination,
|
|
57
|
+
sort,
|
|
58
|
+
rowConfig,
|
|
59
|
+
selection,
|
|
60
|
+
emptyState
|
|
61
|
+
}) {
|
|
62
|
+
const liveRegionId = useId();
|
|
63
|
+
const visibleColumns = useMemo(
|
|
64
|
+
() => columnConfig.filter((col) => !col.isHidden),
|
|
65
|
+
[columnConfig]
|
|
17
66
|
);
|
|
18
|
-
};
|
|
67
|
+
const disabledRows = useDisabledRows({ data, rowConfig });
|
|
68
|
+
const {
|
|
69
|
+
mode: selectionMode,
|
|
70
|
+
selected: selectedKeys,
|
|
71
|
+
behavior: selectionBehavior,
|
|
72
|
+
onSelectionChange
|
|
73
|
+
} = selection || {};
|
|
74
|
+
if (loading && !data) {
|
|
75
|
+
return /* @__PURE__ */ jsx("div", { children: "Loading..." });
|
|
76
|
+
}
|
|
77
|
+
if (error) {
|
|
78
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
79
|
+
"Error: ",
|
|
80
|
+
error.message
|
|
81
|
+
] });
|
|
82
|
+
}
|
|
83
|
+
const liveRegionLabel = useLiveRegionLabel(
|
|
84
|
+
pagination,
|
|
85
|
+
isStale,
|
|
86
|
+
data !== void 0
|
|
87
|
+
);
|
|
88
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
89
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "polite", id: liveRegionId, children: liveRegionLabel }),
|
|
90
|
+
/* @__PURE__ */ jsxs(
|
|
91
|
+
TableRoot,
|
|
92
|
+
{
|
|
93
|
+
selectionMode,
|
|
94
|
+
selectionBehavior,
|
|
95
|
+
selectedKeys,
|
|
96
|
+
onSelectionChange,
|
|
97
|
+
sortDescriptor: sort?.descriptor ?? void 0,
|
|
98
|
+
onSortChange: sort?.onSortChange,
|
|
99
|
+
disabledKeys: disabledRows,
|
|
100
|
+
stale: isStale,
|
|
101
|
+
"aria-describedby": liveRegionId,
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ jsx(TableHeader, { columns: visibleColumns, children: (column) => column.header ? /* @__PURE__ */ jsx(Fragment, { children: column.header() }) : /* @__PURE__ */ jsx(
|
|
104
|
+
Column,
|
|
105
|
+
{
|
|
106
|
+
id: column.id,
|
|
107
|
+
isRowHeader: column.isRowHeader,
|
|
108
|
+
allowsSorting: column.isSortable,
|
|
109
|
+
children: column.label
|
|
110
|
+
}
|
|
111
|
+
) }),
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
TableBody,
|
|
114
|
+
{
|
|
115
|
+
items: data,
|
|
116
|
+
renderEmptyState: emptyState ? () => /* @__PURE__ */ jsx(Flex, { p: "3", children: emptyState }) : void 0,
|
|
117
|
+
children: (item) => {
|
|
118
|
+
const itemIndex = data?.indexOf(item) ?? -1;
|
|
119
|
+
if (isRowRenderFn(rowConfig)) {
|
|
120
|
+
return rowConfig({
|
|
121
|
+
item,
|
|
122
|
+
index: itemIndex
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
Row,
|
|
127
|
+
{
|
|
128
|
+
id: String(item.id),
|
|
129
|
+
columns: visibleColumns,
|
|
130
|
+
href: rowConfig?.getHref?.(item),
|
|
131
|
+
onAction: rowConfig?.onClick ? () => rowConfig?.onClick?.(item) : void 0,
|
|
132
|
+
children: (column) => /* @__PURE__ */ jsx(Fragment$1, { children: column.cell(item) }, column.id)
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
pagination.type === "page" && /* @__PURE__ */ jsx(
|
|
142
|
+
TablePagination,
|
|
143
|
+
{
|
|
144
|
+
pageSize: pagination.pageSize,
|
|
145
|
+
offset: pagination.offset,
|
|
146
|
+
totalCount: pagination.totalCount,
|
|
147
|
+
hasNextPage: pagination.hasNextPage,
|
|
148
|
+
hasPreviousPage: pagination.hasPreviousPage,
|
|
149
|
+
onNextPage: pagination.onNextPage,
|
|
150
|
+
onPreviousPage: pagination.onPreviousPage,
|
|
151
|
+
onPageSizeChange: pagination.onPageSizeChange,
|
|
152
|
+
showPageSizeOptions: pagination.showPageSizeOptions,
|
|
153
|
+
getLabel: pagination.getLabel
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
19
158
|
|
|
20
159
|
export { Table };
|
|
21
160
|
//# sourceMappingURL=Table.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.esm.js","sources":["../../../../src/components/Table/components/Table.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 { useStyles } from '../../../hooks/useStyles';\nimport { TableDefinition } from '../definition';\nimport {\n Table as ReactAriaTable,\n type TableProps,\n} from 'react-aria-components';\nimport styles from '../Table.module.css';\nimport clsx from 'clsx';\n\n/** @public */\nexport const Table = (props: TableProps) => {\n const { classNames, cleanedProps } = useStyles(TableDefinition, props);\n\n return (\n <ReactAriaTable\n className={clsx(classNames.table, styles[classNames.table])}\n aria-label=\"Data table\"\n {...cleanedProps}\n />\n );\n};\n"],"names":["ReactAriaTable"],"mappings":";;;;;;;AA0BO,MAAM,KAAA,GAAQ,CAAC,KAAA,KAAsB;AAC1C,EAAA,MAAM,EAAE,UAAA,EAAY,YAAA,EAAa,GAAI,SAAA,CAAU,iBAAiB,KAAK,CAAA;AAErE,EAAA,uBACE,GAAA;AAAA,IAACA,OAAA;AAAA,IAAA;AAAA,MACC,WAAW,IAAA,CAAK,UAAA,CAAW,OAAO,MAAA,CAAO,UAAA,CAAW,KAAK,CAAC,CAAA;AAAA,MAC1D,YAAA,EAAW,YAAA;AAAA,MACV,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"Table.esm.js","sources":["../../../../src/components/Table/components/Table.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 type { Key } from 'react-aria-components';\nimport { TableRoot } from './TableRoot';\nimport { TableHeader } from './TableHeader';\nimport { TableBody } from './TableBody';\nimport { Row } from './Row';\nimport { Column } from './Column';\nimport { TablePagination } from '../../TablePagination';\nimport type {\n TableProps,\n TableItem,\n RowConfig,\n RowRenderFn,\n TablePaginationType,\n} from '../types';\nimport { Fragment, useId, useMemo } from 'react';\nimport { VisuallyHidden } from '../../VisuallyHidden';\nimport { Flex } from '../../Flex';\n\nfunction isRowRenderFn<T extends TableItem>(\n rowConfig: RowConfig<T> | RowRenderFn<T> | undefined,\n): rowConfig is RowRenderFn<T> {\n return typeof rowConfig === 'function';\n}\n\nfunction useDisabledRows<T extends TableItem>({\n data,\n rowConfig,\n}: Pick<TableProps<T>, 'data' | 'rowConfig'>): Set<Key> | undefined {\n return useMemo(() => {\n if (!data || typeof rowConfig === 'function' || !rowConfig?.getIsDisabled) {\n return;\n }\n\n return data.reduce<Set<Key>>((set, item) => {\n const isDisabled = rowConfig.getIsDisabled?.(item);\n if (isDisabled) {\n set.add(String(item.id));\n }\n return set;\n }, new Set<Key>());\n }, [data, rowConfig]);\n}\n\nfunction useLiveRegionLabel(\n pagination: TablePaginationType,\n isStale: boolean,\n hasData: boolean,\n): string {\n if (!hasData || pagination.type === 'none') {\n return '';\n }\n\n const { pageSize, offset, totalCount, getLabel } = pagination;\n\n if (isStale) {\n return 'Loading table data.';\n }\n\n let liveRegionLabel = 'Table page loaded. ';\n\n if (getLabel) {\n liveRegionLabel += getLabel({ pageSize, offset, totalCount });\n } else if (offset !== undefined) {\n const fromCount = offset + 1;\n const toCount = Math.min(offset + pageSize, totalCount ?? 0);\n liveRegionLabel += `Showing ${fromCount} to ${toCount} of ${totalCount}`;\n }\n return liveRegionLabel;\n}\n\n/** @public */\nexport function Table<T extends TableItem>({\n columnConfig,\n data,\n loading = false,\n isStale = false,\n error,\n pagination,\n sort,\n rowConfig,\n selection,\n emptyState,\n}: TableProps<T>) {\n const liveRegionId = useId();\n\n const visibleColumns = useMemo(\n () => columnConfig.filter(col => !col.isHidden),\n [columnConfig],\n );\n const disabledRows = useDisabledRows({ data, rowConfig });\n\n const {\n mode: selectionMode,\n selected: selectedKeys,\n behavior: selectionBehavior,\n onSelectionChange,\n } = selection || {};\n\n if (loading && !data) {\n return <div>Loading...</div>;\n }\n\n if (error) {\n return <div>Error: {error.message}</div>;\n }\n\n const liveRegionLabel = useLiveRegionLabel(\n pagination,\n isStale,\n data !== undefined,\n );\n\n return (\n <div>\n <VisuallyHidden aria-live=\"polite\" id={liveRegionId}>\n {liveRegionLabel}\n </VisuallyHidden>\n\n <TableRoot\n selectionMode={selectionMode}\n selectionBehavior={selectionBehavior}\n selectedKeys={selectedKeys}\n onSelectionChange={onSelectionChange}\n sortDescriptor={sort?.descriptor ?? undefined}\n onSortChange={sort?.onSortChange}\n disabledKeys={disabledRows}\n stale={isStale}\n aria-describedby={liveRegionId}\n >\n <TableHeader columns={visibleColumns}>\n {column =>\n column.header ? (\n <>{column.header()}</>\n ) : (\n <Column\n id={column.id}\n isRowHeader={column.isRowHeader}\n allowsSorting={column.isSortable}\n >\n {column.label}\n </Column>\n )\n }\n </TableHeader>\n <TableBody\n items={data}\n renderEmptyState={\n emptyState ? () => <Flex p=\"3\">{emptyState}</Flex> : undefined\n }\n >\n {item => {\n const itemIndex = data?.indexOf(item) ?? -1;\n\n if (isRowRenderFn(rowConfig)) {\n return rowConfig({\n item,\n index: itemIndex,\n });\n }\n\n return (\n <Row\n id={String(item.id)}\n columns={visibleColumns}\n href={rowConfig?.getHref?.(item)}\n onAction={\n rowConfig?.onClick\n ? () => rowConfig?.onClick?.(item)\n : undefined\n }\n >\n {column => (\n <Fragment key={column.id}>{column.cell(item)}</Fragment>\n )}\n </Row>\n );\n }}\n </TableBody>\n </TableRoot>\n {pagination.type === 'page' && (\n <TablePagination\n pageSize={pagination.pageSize}\n offset={pagination.offset}\n totalCount={pagination.totalCount}\n hasNextPage={pagination.hasNextPage}\n hasPreviousPage={pagination.hasPreviousPage}\n onNextPage={pagination.onNextPage}\n onPreviousPage={pagination.onPreviousPage}\n onPageSizeChange={pagination.onPageSizeChange}\n showPageSizeOptions={pagination.showPageSizeOptions}\n getLabel={pagination.getLabel}\n />\n )}\n </div>\n );\n}\n"],"names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1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useStyles } from '../../../hooks/useStyles.esm.js';
|
|
3
|
+
import { TableDefinition } from '../definition.esm.js';
|
|
4
|
+
import { Table } from 'react-aria-components';
|
|
5
|
+
import styles from '../Table.module.css.esm.js';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
|
|
8
|
+
const TableRoot = (props) => {
|
|
9
|
+
const { classNames, dataAttributes, cleanedProps } = useStyles(
|
|
10
|
+
TableDefinition,
|
|
11
|
+
props
|
|
12
|
+
);
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
Table,
|
|
15
|
+
{
|
|
16
|
+
className: clsx(classNames.table, styles[classNames.table]),
|
|
17
|
+
"aria-label": "Data table",
|
|
18
|
+
"aria-busy": props.stale,
|
|
19
|
+
...dataAttributes,
|
|
20
|
+
...cleanedProps
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { TableRoot };
|
|
26
|
+
//# sourceMappingURL=TableRoot.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRoot.esm.js","sources":["../../../../src/components/Table/components/TableRoot.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 { useStyles } from '../../../hooks/useStyles';\nimport { TableDefinition } from '../definition';\nimport { Table as ReactAriaTable } from 'react-aria-components';\nimport styles from '../Table.module.css';\nimport clsx from 'clsx';\nimport { TableRootProps } from '../types';\n\n/** @public */\nexport const TableRoot = (props: TableRootProps) => {\n const { classNames, dataAttributes, cleanedProps } = useStyles(\n TableDefinition,\n props,\n );\n\n return (\n <ReactAriaTable\n className={clsx(classNames.table, styles[classNames.table])}\n aria-label=\"Data table\"\n aria-busy={props.stale}\n {...dataAttributes}\n {...cleanedProps}\n />\n );\n};\n"],"names":["ReactAriaTable"],"mappings":";;;;;;;AAwBO,MAAM,SAAA,GAAY,CAAC,KAAA,KAA0B;AAClD,EAAA,MAAM,EAAE,UAAA,EAAY,cAAA,EAAgB,YAAA,EAAa,GAAI,SAAA;AAAA,IACnD,eAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,uBACE,GAAA;AAAA,IAACA,KAAA;AAAA,IAAA;AAAA,MACC,WAAW,IAAA,CAAK,UAAA,CAAW,OAAO,MAAA,CAAO,UAAA,CAAW,KAAK,CAAC,CAAA;AAAA,MAC1D,YAAA,EAAW,YAAA;AAAA,MACX,aAAW,KAAA,CAAM,KAAA;AAAA,MAChB,GAAG,cAAA;AAAA,MACH,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Table/definition.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 */\n\nimport type { ComponentDefinition } from '../../types';\n\n/**\n * Component definition for Table\n * @public\n */\nexport const TableDefinition = {\n classNames: {\n table: 'bui-Table',\n header: 'bui-TableHeader',\n body: 'bui-TableBody',\n row: 'bui-TableRow',\n head: 'bui-TableHead',\n headContent: 'bui-TableHeadContent',\n headSortButton: 'bui-TableHeadSortButton',\n caption: 'bui-TableCaption',\n cell: 'bui-TableCell',\n cellContentWrapper: 'bui-TableCellContentWrapper',\n cellContent: 'bui-TableCellContent',\n cellIcon: 'bui-TableCellIcon',\n cellProfileAvatar: 'bui-TableCellProfileAvatar',\n cellProfileAvatarImage: 'bui-TableCellProfileAvatarImage',\n cellProfileAvatarFallback: 'bui-TableCellProfileAvatarFallback',\n cellProfileName: 'bui-TableCellProfileName',\n cellProfileLink: 'bui-TableCellProfileLink',\n headSelection: 'bui-TableHeadSelection',\n cellSelection: 'bui-TableCellSelection',\n },\n} as const satisfies ComponentDefinition;\n"],"names":[],"mappings":"AAsBO,MAAM,eAAA,GAAkB;AAAA,EAC7B,UAAA,EAAY;AAAA,IACV,KAAA,EAAO,WAAA;AAAA,IACP,MAAA,EAAQ,iBAAA;AAAA,IACR,IAAA,EAAM,eAAA;AAAA,IACN,GAAA,EAAK,cAAA;AAAA,IACL,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EAAa,sBAAA;AAAA,IACb,cAAA,EAAgB,yBAAA;AAAA,IAChB,OAAA,EAAS,kBAAA;AAAA,IACT,IAAA,EAAM,eAAA;AAAA,IACN,kBAAA,EAAoB,6BAAA;AAAA,IACpB,WAAA,EAAa,sBAAA;AAAA,IACb,QAAA,EAAU,mBAAA;AAAA,IACV,iBAAA,EAAmB,4BAAA;AAAA,IACnB,sBAAA,EAAwB,iCAAA;AAAA,IACxB,yBAAA,EAA2B,oCAAA;AAAA,IAC3B,eAAA,EAAiB,0BAAA;AAAA,IACjB,eAAA,EAAiB,0BAAA;AAAA,IACjB,aAAA,EAAe,wBAAA;AAAA,IACf,aAAA,EAAe;AAAA;
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Table/definition.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 */\n\nimport type { ComponentDefinition } from '../../types';\n\n/**\n * Component definition for Table\n * @public\n */\nexport const TableDefinition = {\n classNames: {\n table: 'bui-Table',\n header: 'bui-TableHeader',\n body: 'bui-TableBody',\n row: 'bui-TableRow',\n head: 'bui-TableHead',\n headContent: 'bui-TableHeadContent',\n headSortButton: 'bui-TableHeadSortButton',\n caption: 'bui-TableCaption',\n cell: 'bui-TableCell',\n cellContentWrapper: 'bui-TableCellContentWrapper',\n cellContent: 'bui-TableCellContent',\n cellIcon: 'bui-TableCellIcon',\n cellProfileAvatar: 'bui-TableCellProfileAvatar',\n cellProfileAvatarImage: 'bui-TableCellProfileAvatarImage',\n cellProfileAvatarFallback: 'bui-TableCellProfileAvatarFallback',\n cellProfileName: 'bui-TableCellProfileName',\n cellProfileLink: 'bui-TableCellProfileLink',\n headSelection: 'bui-TableHeadSelection',\n cellSelection: 'bui-TableCellSelection',\n },\n dataAttributes: {\n stale: [true, false] as const,\n },\n} as const satisfies ComponentDefinition;\n"],"names":[],"mappings":"AAsBO,MAAM,eAAA,GAAkB;AAAA,EAC7B,UAAA,EAAY;AAAA,IACV,KAAA,EAAO,WAAA;AAAA,IACP,MAAA,EAAQ,iBAAA;AAAA,IACR,IAAA,EAAM,eAAA;AAAA,IACN,GAAA,EAAK,cAAA;AAAA,IACL,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EAAa,sBAAA;AAAA,IACb,cAAA,EAAgB,yBAAA;AAAA,IAChB,OAAA,EAAS,kBAAA;AAAA,IACT,IAAA,EAAM,eAAA;AAAA,IACN,kBAAA,EAAoB,6BAAA;AAAA,IACpB,WAAA,EAAa,sBAAA;AAAA,IACb,QAAA,EAAU,mBAAA;AAAA,IACV,iBAAA,EAAmB,4BAAA;AAAA,IACnB,sBAAA,EAAwB,iCAAA;AAAA,IACxB,yBAAA,EAA2B,oCAAA;AAAA,IAC3B,eAAA,EAAiB,0BAAA;AAAA,IACjB,eAAA,EAAiB,0BAAA;AAAA,IACjB,aAAA,EAAe,wBAAA;AAAA,IACf,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAO,CAAC,IAAA,EAAM,KAAK;AAAA;AAEvB;;;;"}
|