@backstage/ui 0.9.0 → 0.9.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 +18 -0
- package/dist/components/ButtonIcon/ButtonIcon.esm.js +2 -4
- package/dist/components/ButtonIcon/ButtonIcon.esm.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.module.css.esm.js +1 -1
- package/dist/components/Table/components/Row.esm.js +1 -1
- package/dist/components/Table/components/Row.esm.js.map +1 -1
- package/dist/components/Table/hooks/useTable.esm.js +1 -1
- package/dist/components/Table/hooks/useTable.esm.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @backstage/ui
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4514097: Fixed Checkbox indicator showing checkmark color when unchecked.
|
|
8
|
+
|
|
9
|
+
Affected components: Checkbox
|
|
10
|
+
|
|
11
|
+
- 3fc4aeb: Fixed `ButtonIcon` incorrectly applying `className` to inner elements instead of only the root element.
|
|
12
|
+
|
|
13
|
+
Affected components: ButtonIcon
|
|
14
|
+
|
|
15
|
+
- d43f3ce: Fixed Table Row component to correctly handle cases where no `href` is provided, preventing unnecessary router provider wrapping and fixing the cursor incorrectly showing as a pointer despite the element not being a link.
|
|
16
|
+
|
|
17
|
+
Affected components: Row
|
|
18
|
+
|
|
19
|
+
- 2e92b5a: Fixed `useTable` hook to prioritize `providedRowCount` over data length for accurate row count in server-side pagination scenarios.
|
|
20
|
+
|
|
3
21
|
## 0.9.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -43,8 +43,7 @@ const ButtonIcon = forwardRef(
|
|
|
43
43
|
classNames.content,
|
|
44
44
|
classNamesButtonIcon.content,
|
|
45
45
|
stylesButton[classNames.content],
|
|
46
|
-
stylesButtonIcon[classNamesButtonIcon.content]
|
|
47
|
-
className
|
|
46
|
+
stylesButtonIcon[classNamesButtonIcon.content]
|
|
48
47
|
),
|
|
49
48
|
children: icon
|
|
50
49
|
}
|
|
@@ -58,8 +57,7 @@ const ButtonIcon = forwardRef(
|
|
|
58
57
|
classNames.spinner,
|
|
59
58
|
classNamesButtonIcon.spinner,
|
|
60
59
|
stylesButton[classNames.spinner],
|
|
61
|
-
stylesButtonIcon[classNamesButtonIcon.spinner]
|
|
62
|
-
className
|
|
60
|
+
stylesButtonIcon[classNamesButtonIcon.spinner]
|
|
63
61
|
),
|
|
64
62
|
children: /* @__PURE__ */ jsx(RiLoader4Line, { "aria-hidden": "true" })
|
|
65
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.esm.js","sources":["../../../src/components/ButtonIcon/ButtonIcon.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 clsx from 'clsx';\nimport { forwardRef, Ref } from 'react';\nimport { Button as RAButton, ProgressBar } from 'react-aria-components';\nimport { RiLoader4Line } from '@remixicon/react';\nimport type { ButtonIconProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\nimport { ButtonDefinition } from '../Button/definition';\nimport { ButtonIconDefinition } from './definition';\nimport stylesButtonIcon from './ButtonIcon.module.css';\nimport stylesButton from '../Button/Button.module.css';\n\n/** @public */\nexport const ButtonIcon = forwardRef(\n (props: ButtonIconProps, ref: Ref<HTMLButtonElement>) => {\n const { classNames, dataAttributes, cleanedProps } = useStyles(\n ButtonDefinition,\n {\n size: 'small',\n variant: 'primary',\n ...props,\n },\n );\n\n const { classNames: classNamesButtonIcon } =\n useStyles(ButtonIconDefinition);\n\n const { className, icon, loading, ...rest } = cleanedProps;\n\n return (\n <RAButton\n className={clsx(\n classNames.root,\n classNamesButtonIcon.root,\n stylesButton[classNames.root],\n stylesButtonIcon[classNamesButtonIcon.root],\n className,\n )}\n ref={ref}\n isPending={loading}\n {...dataAttributes}\n {...rest}\n >\n {({ isPending }) => (\n <>\n <span\n className={clsx(\n classNames.content,\n classNamesButtonIcon.content,\n stylesButton[classNames.content],\n stylesButtonIcon[classNamesButtonIcon.content],\n
|
|
1
|
+
{"version":3,"file":"ButtonIcon.esm.js","sources":["../../../src/components/ButtonIcon/ButtonIcon.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 clsx from 'clsx';\nimport { forwardRef, Ref } from 'react';\nimport { Button as RAButton, ProgressBar } from 'react-aria-components';\nimport { RiLoader4Line } from '@remixicon/react';\nimport type { ButtonIconProps } from './types';\nimport { useStyles } from '../../hooks/useStyles';\nimport { ButtonDefinition } from '../Button/definition';\nimport { ButtonIconDefinition } from './definition';\nimport stylesButtonIcon from './ButtonIcon.module.css';\nimport stylesButton from '../Button/Button.module.css';\n\n/** @public */\nexport const ButtonIcon = forwardRef(\n (props: ButtonIconProps, ref: Ref<HTMLButtonElement>) => {\n const { classNames, dataAttributes, cleanedProps } = useStyles(\n ButtonDefinition,\n {\n size: 'small',\n variant: 'primary',\n ...props,\n },\n );\n\n const { classNames: classNamesButtonIcon } =\n useStyles(ButtonIconDefinition);\n\n const { className, icon, loading, ...rest } = cleanedProps;\n\n return (\n <RAButton\n className={clsx(\n classNames.root,\n classNamesButtonIcon.root,\n stylesButton[classNames.root],\n stylesButtonIcon[classNamesButtonIcon.root],\n className,\n )}\n ref={ref}\n isPending={loading}\n {...dataAttributes}\n {...rest}\n >\n {({ isPending }) => (\n <>\n <span\n className={clsx(\n classNames.content,\n classNamesButtonIcon.content,\n stylesButton[classNames.content],\n stylesButtonIcon[classNamesButtonIcon.content],\n )}\n >\n {icon}\n </span>\n\n {isPending && (\n <ProgressBar\n aria-label=\"Loading\"\n isIndeterminate\n className={clsx(\n classNames.spinner,\n classNamesButtonIcon.spinner,\n stylesButton[classNames.spinner],\n stylesButtonIcon[classNamesButtonIcon.spinner],\n )}\n >\n <RiLoader4Line aria-hidden=\"true\" />\n </ProgressBar>\n )}\n </>\n )}\n </RAButton>\n );\n },\n);\n\nButtonIcon.displayName = 'ButtonIcon';\n"],"names":["RAButton"],"mappings":";;;;;;;;;;;AA4BO,MAAM,UAAA,GAAa,UAAA;AAAA,EACxB,CAAC,OAAwB,GAAA,KAAgC;AACvD,IAAA,MAAM,EAAE,UAAA,EAAY,cAAA,EAAgB,YAAA,EAAa,GAAI,SAAA;AAAA,MACnD,gBAAA;AAAA,MACA;AAAA,QACE,IAAA,EAAM,OAAA;AAAA,QACN,OAAA,EAAS,SAAA;AAAA,QACT,GAAG;AAAA;AACL,KACF;AAEA,IAAA,MAAM,EAAE,UAAA,EAAY,oBAAA,EAAqB,GACvC,UAAU,oBAAoB,CAAA;AAEhC,IAAA,MAAM,EAAE,SAAA,EAAW,IAAA,EAAM,OAAA,EAAS,GAAG,MAAK,GAAI,YAAA;AAE9C,IAAA,uBACE,GAAA;AAAA,MAACA,MAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAW,IAAA;AAAA,UACT,UAAA,CAAW,IAAA;AAAA,UACX,oBAAA,CAAqB,IAAA;AAAA,UACrB,YAAA,CAAa,WAAW,IAAI,CAAA;AAAA,UAC5B,gBAAA,CAAiB,qBAAqB,IAAI,CAAA;AAAA,UAC1C;AAAA,SACF;AAAA,QACA,GAAA;AAAA,QACA,SAAA,EAAW,OAAA;AAAA,QACV,GAAG,cAAA;AAAA,QACH,GAAG,IAAA;AAAA,QAEH,QAAA,EAAA,CAAC,EAAE,SAAA,EAAU,qBACZ,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAW,IAAA;AAAA,gBACT,UAAA,CAAW,OAAA;AAAA,gBACX,oBAAA,CAAqB,OAAA;AAAA,gBACrB,YAAA,CAAa,WAAW,OAAO,CAAA;AAAA,gBAC/B,gBAAA,CAAiB,qBAAqB,OAAO;AAAA,eAC/C;AAAA,cAEC,QAAA,EAAA;AAAA;AAAA,WACH;AAAA,UAEC,SAAA,oBACC,GAAA;AAAA,YAAC,WAAA;AAAA,YAAA;AAAA,cACC,YAAA,EAAW,SAAA;AAAA,cACX,eAAA,EAAe,IAAA;AAAA,cACf,SAAA,EAAW,IAAA;AAAA,gBACT,UAAA,CAAW,OAAA;AAAA,gBACX,oBAAA,CAAqB,OAAA;AAAA,gBACrB,YAAA,CAAa,WAAW,OAAO,CAAA;AAAA,gBAC/B,gBAAA,CAAiB,qBAAqB,OAAO;AAAA,eAC/C;AAAA,cAEA,QAAA,kBAAA,GAAA,CAAC,aAAA,EAAA,EAAc,aAAA,EAAY,MAAA,EAAO;AAAA;AAAA;AACpC,SAAA,EAEJ;AAAA;AAAA,KAEJ;AAAA,EAEJ;AACF;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA;;;;"}
|
|
@@ -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 .Checkbox-module_bui-Checkbox__1Oiwl {\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-family: var(--bui-font-regular);\n font-weight: var(--bui-font-weight-regular);\n color: var(--bui-fg-primary);\n user-select: none;\n cursor: pointer;\n }\n\n .Checkbox-module_bui-Checkbox__1Oiwl[data-disabled] {\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .Checkbox-module_bui-CheckboxIndicator__2ZJtl {\n border: none;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 1rem;\n height: 1rem;\n box-shadow: inset 0 0 0 1px var(--bui-border);\n border-radius: 2px;\n transition: background-color 0.2s ease-in-out;\n background-color: var(--bui-bg-surface-1);\n padding: 0;\n flex-shrink: 0;\n color:
|
|
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 .Checkbox-module_bui-Checkbox__1Oiwl {\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-family: var(--bui-font-regular);\n font-weight: var(--bui-font-weight-regular);\n color: var(--bui-fg-primary);\n user-select: none;\n cursor: pointer;\n }\n\n .Checkbox-module_bui-Checkbox__1Oiwl[data-disabled] {\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .Checkbox-module_bui-CheckboxIndicator__2ZJtl {\n border: none;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 1rem;\n height: 1rem;\n box-shadow: inset 0 0 0 1px var(--bui-border);\n border-radius: 2px;\n transition: background-color 0.2s ease-in-out;\n background-color: var(--bui-bg-surface-1);\n padding: 0;\n flex-shrink: 0;\n color: transparent;\n\n .Checkbox-module_bui-Checkbox__1Oiwl[data-focus-visible] & {\n transition: none;\n outline: 2px solid var(--bui-ring);\n outline-offset: 2px;\n }\n\n .Checkbox-module_bui-Checkbox__1Oiwl[data-selected] & {\n background-color: var(--bui-bg-solid);\n box-shadow: none;\n color: var(--bui-fg-solid);\n }\n\n .Checkbox-module_bui-Checkbox__1Oiwl[data-hovered]:not([data-selected]) & {\n box-shadow: inset 0 0 0 1px var(--bui-border-hover);\n }\n\n @media (prefers-reduced-motion: reduce) {\n & {\n transition: none;\n }\n }\n }\n}\n";
|
|
4
4
|
var styles = {"bui-Checkbox":"Checkbox-module_bui-Checkbox__1Oiwl","bui-CheckboxIndicator":"Checkbox-module_bui-CheckboxIndicator__2ZJtl"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ function Row(props) {
|
|
|
17
17
|
selectionBehavior === "toggle" && /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Checkbox, { slot: "selection" }) }),
|
|
18
18
|
/* @__PURE__ */ jsx(Collection, { items: columns, children })
|
|
19
19
|
] });
|
|
20
|
-
if (isExternal) {
|
|
20
|
+
if (!href || isExternal) {
|
|
21
21
|
return /* @__PURE__ */ jsx(
|
|
22
22
|
Row$1,
|
|
23
23
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.esm.js","sources":["../../../../src/components/Table/components/Row.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 {\n Row as ReactAriaRow,\n RowProps,\n useTableOptions,\n Cell,\n Collection,\n Checkbox,\n RouterProvider,\n} from 'react-aria-components';\nimport { useStyles } from '../../../hooks/useStyles';\nimport { TableDefinition } from '../definition';\nimport { useNavigate } from 'react-router-dom';\nimport { useHref } from 'react-router-dom';\nimport { isExternalLink } from '../../../utils/isExternalLink';\nimport styles from '../Table.module.css';\nimport clsx from 'clsx';\n\n/** @public */\nexport function Row<T extends object>(props: RowProps<T>) {\n const { classNames, cleanedProps } = useStyles(TableDefinition, props);\n const { id, columns, children, href, ...rest } = cleanedProps;\n const navigate = useNavigate();\n const isExternal = isExternalLink(href);\n\n let { selectionBehavior } = useTableOptions();\n\n const content = (\n <>\n {selectionBehavior === 'toggle' && (\n <Cell>\n <Checkbox slot=\"selection\" />\n </Cell>\n )}\n <Collection items={columns}>{children}</Collection>\n </>\n );\n\n if (isExternal) {\n return (\n <ReactAriaRow\n id={id}\n href={href}\n className={clsx(classNames.row, styles[classNames.row])}\n {...rest}\n >\n {content}\n </ReactAriaRow>\n );\n }\n\n return (\n <RouterProvider navigate={navigate} useHref={useHref}>\n <ReactAriaRow\n id={id}\n href={href}\n className={clsx(classNames.row, styles[classNames.row])}\n data-react-aria-pressable=\"true\"\n {...rest}\n >\n {content}\n </ReactAriaRow>\n </RouterProvider>\n );\n}\n"],"names":["ReactAriaRow"],"mappings":";;;;;;;;;AAkCO,SAAS,IAAsB,KAAA,EAAoB;AACxD,EAAA,MAAM,EAAE,UAAA,EAAY,YAAA,EAAa,GAAI,SAAA,CAAU,iBAAiB,KAAK,CAAA;AACrE,EAAA,MAAM,EAAE,EAAA,EAAI,OAAA,EAAS,UAAU,IAAA,EAAM,GAAG,MAAK,GAAI,YAAA;AACjD,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,UAAA,GAAa,eAAe,IAAI,CAAA;AAEtC,EAAA,IAAI,EAAE,iBAAA,EAAkB,GAAI,eAAA,EAAgB;AAE5C,EAAA,MAAM,0BACJ,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,iBAAA,KAAsB,4BACrB,GAAA,CAAC,IAAA,EAAA,EACC,8BAAC,QAAA,EAAA,EAAS,IAAA,EAAK,aAAY,CAAA,EAC7B,CAAA;AAAA,oBAEF,GAAA,CAAC,UAAA,EAAA,EAAW,KAAA,EAAO,OAAA,EAAU,QAAA,EAAS;AAAA,GAAA,EACxC,CAAA;AAGF,EAAA,IAAI,UAAA,EAAY;
|
|
1
|
+
{"version":3,"file":"Row.esm.js","sources":["../../../../src/components/Table/components/Row.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 {\n Row as ReactAriaRow,\n RowProps,\n useTableOptions,\n Cell,\n Collection,\n Checkbox,\n RouterProvider,\n} from 'react-aria-components';\nimport { useStyles } from '../../../hooks/useStyles';\nimport { TableDefinition } from '../definition';\nimport { useNavigate } from 'react-router-dom';\nimport { useHref } from 'react-router-dom';\nimport { isExternalLink } from '../../../utils/isExternalLink';\nimport styles from '../Table.module.css';\nimport clsx from 'clsx';\n\n/** @public */\nexport function Row<T extends object>(props: RowProps<T>) {\n const { classNames, cleanedProps } = useStyles(TableDefinition, props);\n const { id, columns, children, href, ...rest } = cleanedProps;\n const navigate = useNavigate();\n const isExternal = isExternalLink(href);\n\n let { selectionBehavior } = useTableOptions();\n\n const content = (\n <>\n {selectionBehavior === 'toggle' && (\n <Cell>\n <Checkbox slot=\"selection\" />\n </Cell>\n )}\n <Collection items={columns}>{children}</Collection>\n </>\n );\n\n if (!href || isExternal) {\n return (\n <ReactAriaRow\n id={id}\n href={href}\n className={clsx(classNames.row, styles[classNames.row])}\n {...rest}\n >\n {content}\n </ReactAriaRow>\n );\n }\n\n return (\n <RouterProvider navigate={navigate} useHref={useHref}>\n <ReactAriaRow\n id={id}\n href={href}\n className={clsx(classNames.row, styles[classNames.row])}\n data-react-aria-pressable=\"true\"\n {...rest}\n >\n {content}\n </ReactAriaRow>\n </RouterProvider>\n );\n}\n"],"names":["ReactAriaRow"],"mappings":";;;;;;;;;AAkCO,SAAS,IAAsB,KAAA,EAAoB;AACxD,EAAA,MAAM,EAAE,UAAA,EAAY,YAAA,EAAa,GAAI,SAAA,CAAU,iBAAiB,KAAK,CAAA;AACrE,EAAA,MAAM,EAAE,EAAA,EAAI,OAAA,EAAS,UAAU,IAAA,EAAM,GAAG,MAAK,GAAI,YAAA;AACjD,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,UAAA,GAAa,eAAe,IAAI,CAAA;AAEtC,EAAA,IAAI,EAAE,iBAAA,EAAkB,GAAI,eAAA,EAAgB;AAE5C,EAAA,MAAM,0BACJ,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,iBAAA,KAAsB,4BACrB,GAAA,CAAC,IAAA,EAAA,EACC,8BAAC,QAAA,EAAA,EAAS,IAAA,EAAK,aAAY,CAAA,EAC7B,CAAA;AAAA,oBAEF,GAAA,CAAC,UAAA,EAAA,EAAW,KAAA,EAAO,OAAA,EAAU,QAAA,EAAS;AAAA,GAAA,EACxC,CAAA;AAGF,EAAA,IAAI,CAAC,QAAQ,UAAA,EAAY;AACvB,IAAA,uBACE,GAAA;AAAA,MAACA,KAAA;AAAA,MAAA;AAAA,QACC,EAAA;AAAA,QACA,IAAA;AAAA,QACA,WAAW,IAAA,CAAK,UAAA,CAAW,KAAK,MAAA,CAAO,UAAA,CAAW,GAAG,CAAC,CAAA;AAAA,QACrD,GAAG,IAAA;AAAA,QAEH,QAAA,EAAA;AAAA;AAAA,KACH;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA,CAAC,cAAA,EAAA,EAAe,QAAA,EAAoB,OAAA,EAClC,QAAA,kBAAA,GAAA;AAAA,IAACA,KAAA;AAAA,IAAA;AAAA,MACC,EAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAW,IAAA,CAAK,UAAA,CAAW,KAAK,MAAA,CAAO,UAAA,CAAW,GAAG,CAAC,CAAA;AAAA,MACtD,2BAAA,EAA0B,MAAA;AAAA,MACzB,GAAG,IAAA;AAAA,MAEH,QAAA,EAAA;AAAA;AAAA,GACH,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -15,7 +15,7 @@ function useTable(config = {}) {
|
|
|
15
15
|
showPageSizeOptions = true
|
|
16
16
|
} = paginationConfig;
|
|
17
17
|
const isControlled = controlledOffset !== void 0 || controlledPageSize !== void 0;
|
|
18
|
-
const rowCount = data?.length ??
|
|
18
|
+
const rowCount = providedRowCount ?? data?.length ?? 0;
|
|
19
19
|
const [internalOffset, setInternalOffset] = useState(defaultOffset);
|
|
20
20
|
const [internalPageSize, setInternalPageSize] = useState(defaultPageSize);
|
|
21
21
|
const currentOffset = controlledOffset ?? internalOffset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.esm.js","sources":["../../../../src/components/Table/hooks/useTable.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 { useState, useMemo, useCallback } from 'react';\nimport type { TablePaginationProps } from '../../TablePagination/types';\nimport type {\n UseTableConfig,\n UseTableResult,\n UseTablePagination,\n} from './types';\n\n/**\n * Hook for managing table state including pagination and future features like sorting.\n * Supports both controlled and uncontrolled modes using offset/pageSize pattern (Backstage style).\n *\n * @public\n */\nexport function useTable<T = any>(\n config: UseTableConfig<T> = {},\n): UseTableResult<T> {\n const { data, pagination: paginationConfig = {} } = config;\n\n const {\n rowCount: providedRowCount,\n offset: controlledOffset,\n pageSize: controlledPageSize,\n onOffsetChange,\n onPageSizeChange,\n defaultPageSize = 10,\n defaultOffset = 0,\n onNextPage,\n onPreviousPage,\n showPageSizeOptions = true,\n } = paginationConfig;\n\n // Determine if we're in controlled mode\n const isControlled =\n controlledOffset !== undefined || controlledPageSize !== undefined;\n\n //
|
|
1
|
+
{"version":3,"file":"useTable.esm.js","sources":["../../../../src/components/Table/hooks/useTable.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 { useState, useMemo, useCallback } from 'react';\nimport type { TablePaginationProps } from '../../TablePagination/types';\nimport type {\n UseTableConfig,\n UseTableResult,\n UseTablePagination,\n} from './types';\n\n/**\n * Hook for managing table state including pagination and future features like sorting.\n * Supports both controlled and uncontrolled modes using offset/pageSize pattern (Backstage style).\n *\n * @public\n */\nexport function useTable<T = any>(\n config: UseTableConfig<T> = {},\n): UseTableResult<T> {\n const { data, pagination: paginationConfig = {} } = config;\n\n const {\n rowCount: providedRowCount,\n offset: controlledOffset,\n pageSize: controlledPageSize,\n onOffsetChange,\n onPageSizeChange,\n defaultPageSize = 10,\n defaultOffset = 0,\n onNextPage,\n onPreviousPage,\n showPageSizeOptions = true,\n } = paginationConfig;\n\n // Determine if we're in controlled mode\n const isControlled =\n controlledOffset !== undefined || controlledPageSize !== undefined;\n\n // Use providedRowCount if passed, otherwise fallback to data length\n const rowCount = providedRowCount ?? data?.length ?? 0;\n\n // Internal state for uncontrolled mode\n const [internalOffset, setInternalOffset] = useState(defaultOffset);\n const [internalPageSize, setInternalPageSize] = useState(defaultPageSize);\n\n // Calculate current values\n const currentOffset = controlledOffset ?? internalOffset;\n const currentPageSize = controlledPageSize ?? internalPageSize;\n\n // Calculate sliced data if data array is provided\n const currentData = useMemo(() => {\n if (!data) return undefined;\n return data.slice(currentOffset, currentOffset + currentPageSize);\n }, [data, currentOffset, currentPageSize]);\n\n // Update functions\n const setOffset = useCallback(\n (newOffset: number) => {\n if (isControlled) {\n onOffsetChange?.(newOffset);\n } else {\n setInternalOffset(newOffset);\n }\n },\n [isControlled, onOffsetChange],\n );\n\n const setPageSize = useCallback(\n (newPageSize: number) => {\n // When changing page size, reset to first page to avoid showing empty results\n const newOffset = 0;\n\n if (isControlled) {\n onPageSizeChange?.(newPageSize);\n onOffsetChange?.(newOffset);\n } else {\n setInternalPageSize(newPageSize);\n setInternalOffset(newOffset);\n }\n },\n [isControlled, onPageSizeChange, onOffsetChange],\n );\n\n const nextPage = useCallback(() => {\n const nextOffset = currentOffset + currentPageSize;\n if (nextOffset < rowCount) {\n onNextPage?.();\n setOffset(nextOffset);\n }\n }, [currentOffset, currentPageSize, rowCount, onNextPage, setOffset]);\n\n const previousPage = useCallback(() => {\n if (currentOffset > 0) {\n onPreviousPage?.();\n const prevOffset = Math.max(0, currentOffset - currentPageSize);\n setOffset(prevOffset);\n }\n }, [currentOffset, currentPageSize, onPreviousPage, setOffset]);\n\n // Pagination props for TablePagination component\n const paginationProps: TablePaginationProps = useMemo(\n () => ({\n offset: currentOffset,\n pageSize: currentPageSize,\n rowCount,\n setOffset,\n setPageSize,\n onNextPage,\n onPreviousPage,\n showPageSizeOptions,\n }),\n [\n currentOffset,\n currentPageSize,\n rowCount,\n setOffset,\n setPageSize,\n onNextPage,\n onPreviousPage,\n showPageSizeOptions,\n ],\n );\n\n const pagination: UseTablePagination<T> = useMemo(\n () => ({\n paginationProps,\n offset: currentOffset,\n pageSize: currentPageSize,\n data: currentData,\n nextPage,\n previousPage,\n setOffset,\n setPageSize,\n }),\n [\n paginationProps,\n currentOffset,\n currentPageSize,\n currentData,\n nextPage,\n previousPage,\n setOffset,\n setPageSize,\n ],\n );\n\n return {\n data: currentData,\n paginationProps,\n pagination,\n };\n}\n"],"names":[],"mappings":";;AA8BO,SAAS,QAAA,CACd,MAAA,GAA4B,EAAC,EACV;AACnB,EAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAY,gBAAA,GAAmB,IAAG,GAAI,MAAA;AAEpD,EAAA,MAAM;AAAA,IACJ,QAAA,EAAU,gBAAA;AAAA,IACV,MAAA,EAAQ,gBAAA;AAAA,IACR,QAAA,EAAU,kBAAA;AAAA,IACV,cAAA;AAAA,IACA,gBAAA;AAAA,IACA,eAAA,GAAkB,EAAA;AAAA,IAClB,aAAA,GAAgB,CAAA;AAAA,IAChB,UAAA;AAAA,IACA,cAAA;AAAA,IACA,mBAAA,GAAsB;AAAA,GACxB,GAAI,gBAAA;AAGJ,EAAA,MAAM,YAAA,GACJ,gBAAA,KAAqB,MAAA,IAAa,kBAAA,KAAuB,MAAA;AAG3D,EAAA,MAAM,QAAA,GAAW,gBAAA,IAAoB,IAAA,EAAM,MAAA,IAAU,CAAA;AAGrD,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,C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