@bitrise/bitkit-v2 0.3.414 → 0.3.416
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/dist/components/BitkitControlButton/BitkitControlButton.js +1 -0
- package/dist/components/BitkitControlButton/BitkitControlButton.js.map +1 -1
- package/dist/components/BitkitGroupHeading/BitkitGroupHeading.d.ts +2 -0
- package/dist/components/BitkitGroupHeading/BitkitGroupHeading.js +15 -11
- package/dist/components/BitkitGroupHeading/BitkitGroupHeading.js.map +1 -1
- package/dist/components/BitkitPageHeader/BitkitPageHeader.d.ts +120 -0
- package/dist/components/BitkitPageHeader/BitkitPageHeader.js +105 -0
- package/dist/components/BitkitPageHeader/BitkitPageHeader.js.map +1 -0
- package/dist/components/BitkitPageSidebar/BitkitPageSidebar.d.ts +74 -0
- package/dist/components/BitkitPageSidebar/BitkitPageSidebar.js +263 -0
- package/dist/components/BitkitPageSidebar/BitkitPageSidebar.js.map +1 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/main.js +3 -2
- package/dist/theme/slot-recipes/GroupHeading.recipe.js +4 -1
- package/dist/theme/slot-recipes/GroupHeading.recipe.js.map +1 -1
- package/dist/theme/slot-recipes/PageHeader.recipe.d.ts +202 -0
- package/dist/theme/slot-recipes/PageHeader.recipe.js +354 -0
- package/dist/theme/slot-recipes/PageHeader.recipe.js.map +1 -0
- package/dist/theme/slot-recipes/PageSidebar.recipe.d.ts +85 -0
- package/dist/theme/slot-recipes/PageSidebar.recipe.js +276 -0
- package/dist/theme/slot-recipes/PageSidebar.recipe.js.map +1 -0
- package/dist/theme/slot-recipes/Tour.recipe.d.ts +1 -1
- package/dist/theme/slot-recipes/index.d.ts +286 -22
- package/dist/theme/slot-recipes/index.js +4 -2
- package/dist/theme/slot-recipes/index.js.map +1 -1
- package/dist/utilities/useIsTruncated.d.ts +27 -0
- package/dist/utilities/useIsTruncated.js +54 -0
- package/dist/utilities/useIsTruncated.js.map +1 -0
- package/docs/v1-to-v2-migration-guide.md +9 -6
- package/package.json +1 -1
- package/dist/components/BitkitSidebar/BitkitSidebar.d.ts +0 -45
- package/dist/components/BitkitSidebar/BitkitSidebar.js +0 -147
- package/dist/components/BitkitSidebar/BitkitSidebar.js.map +0 -1
- package/dist/theme/slot-recipes/Sidebar.recipe.d.ts +0 -22
- package/dist/theme/slot-recipes/Sidebar.recipe.js +0 -143
- package/dist/theme/slot-recipes/Sidebar.recipe.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitControlButton.js","names":[],"sources":["../../../lib/components/BitkitControlButton/BitkitControlButton.tsx"],"sourcesContent":["import { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, type HTMLChakraProps, useRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type KeyboardEvent, type MouseEvent, type Ref } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport opensPopup from '../../utilities/opensPopup';\nimport BitkitLabelTooltip, { type BitkitLabelTooltipProps } from '../BitkitLabelTooltip/BitkitLabelTooltip';\n\ntype ControlButtonSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg';\n\ninterface BitkitControlButtonCommonProps {\n icon: BitkitIconComponent;\n isDanger?: boolean;\n label: string;\n size?: ControlButtonSize;\n state?: 'disabled' | 'skeleton';\n /**\n * Overrides for the label tooltip. It is off by default when this control opens a popup — a menu,\n * select or popover trigger — where the panel is the affordance and a tooltip would hover over it.\n * Pass `{ disabled: false }` to bring it back. The accessible name comes from `label` either way.\n */\n tooltipProps?: Partial<Omit<BitkitLabelTooltipProps, 'children' | 'text'>>;\n}\n\n// Exported so dependent declarations can name it: `BitkitTabs.AddButton`'s props derive from\n// `Extract<BitkitControlButtonProps, { href?: undefined }>` (this type), and the .d.ts emit\n// fails with TS4023 (\"cannot be named\") if it isn't exported.\nexport interface BitkitControlButtonAsButtonProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'button'>, 'children' | 'disabled' | 'size'> {\n href?: undefined;\n isExternal?: undefined;\n}\n\nexport interface BitkitControlButtonAsAnchorProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'a'>, 'children' | 'size'> {\n href: string;\n isExternal?: boolean;\n}\n\nexport type BitkitControlButtonProps = BitkitControlButtonAsButtonProps | BitkitControlButtonAsAnchorProps;\n\nconst BitkitControlButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, BitkitControlButtonProps>(\n (props, ref) => {\n const Icon = props.icon;\n const size = props.size ?? 'sm';\n const recipe = useRecipe({ key: 'controlButton' });\n const iconSize = size === 'xxs' || size === 'xs' ? '16' : '24';\n const isDisabled = props.state === 'disabled';\n const isSkeleton = props.state === 'skeleton';\n const isPopupTrigger = opensPopup(props);\n const inertOnClick = isDisabled || isSkeleton;\n\n // --- Anchor mode (href) ---\n if (props.href !== undefined) {\n const {\n href,\n icon: _icon,\n isDanger,\n isExternal,\n label,\n onClick,\n onKeyDown,\n rel,\n size: _size,\n state: _state,\n target,\n tooltipProps,\n ...anchorRest\n } = props;\n const effectiveTarget = isExternal ? '_blank' : target;\n const effectiveRel = isExternal ? (rel ? `${rel} noreferrer noopener` : 'noreferrer noopener') : rel;\n const handleClick = inertOnClick\n ? (e: MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault();\n e.stopPropagation();\n }\n : onClick;\n const handleKeyDown = inertOnClick\n ? (e: KeyboardEvent<HTMLAnchorElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n : onKeyDown;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.a\n ref={ref as Ref<HTMLAnchorElement>}\n aria-disabled={inertOnClick || undefined}\n aria-label={label}\n {...anchorRest}\n css={recipe({ isDanger, size })}\n href={inertOnClick ? undefined : href}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n rel={effectiveRel}\n target={effectiveTarget}\n >\n <Skeleton loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.a>\n </BitkitLabelTooltip>\n );\n }\n\n // --- Button mode (default) ---\n const { icon: _icon, isDanger, label, size: _size, state, tooltipProps, ...buttonRest } = props;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.button\n ref={ref as Ref<HTMLButtonElement>}\n aria-label={label}\n disabled={state === 'disabled' || state === 'skeleton'}\n {...buttonRest}\n css={recipe({ isDanger, size })}\n >\n <Skeleton loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.button>\n </BitkitLabelTooltip>\n );\n },\n);\n\nBitkitControlButton.displayName = 'BitkitControlButton';\n\nexport default BitkitControlButton;\n"],"mappings":";;;;;;;AAyCA,IAAM,sBAAsB,YACzB,OAAO,QAAQ;CACd,MAAM,OAAO,MAAM;CACnB,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,SAAS,UAAU,EAAE,KAAK,gBAAgB,CAAC;CACjD,MAAM,WAAW,SAAS,SAAS,SAAS,OAAO,OAAO;CAC1D,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,iBAAiB,WAAW,KAAK;CACvC,MAAM,eAAe,cAAc;CAGnC,IAAI,MAAM,SAAS,KAAA,GAAW;EAC5B,MAAM,EACJ,MACA,MAAM,OACN,UACA,YACA,OACA,SACA,WACA,KACA,MAAM,OACN,OAAO,QACP,QACA,cACA,GAAG,eACD;EACJ,MAAM,kBAAkB,aAAa,WAAW;EAChD,MAAM,eAAe,aAAc,MAAM,GAAG,IAAI,wBAAwB,wBAAyB;EACjG,MAAM,cAAc,gBACf,MAAqC;GACpC,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB,IACA;EACJ,MAAM,gBAAgB,gBACjB,MAAwC;GACvC,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;IACtC,EAAE,eAAe;IACjB,EAAE,gBAAgB;GACpB;EACF,IACA;EACJ,OACE,oBAAC,oBAAD;GAAoB,MAAM;GAAO,UAAU;GAAgB,GAAI;GAC7D,UAAA,oBAAC,OAAO,GAAR;IACO;IACL,iBAAe,gBAAgB,KAAA;IAC/B,cAAY;IACZ,GAAI;IACJ,KAAK,OAAO;KAAE;KAAU;IAAK,CAAC;IAC9B,MAAM,eAAe,KAAA,IAAY;IACjC,SAAS;IACT,WAAW;IACX,KAAK;IACL,QAAQ;IAER,UAAA,oBAAC,UAAD;KAAU,SAAS;KACjB,UAAA,oBAAC,MAAD,EAAM,MAAM,SAAW,CAAA;IACf,CAAA;GACF,CAAA;EACQ,CAAA;CAExB;CAGA,MAAM,EAAE,MAAM,OAAO,UAAU,OAAO,MAAM,OAAO,OAAO,cAAc,GAAG,eAAe;CAC1F,OACE,oBAAC,oBAAD;EAAoB,MAAM;EAAO,UAAU;EAAgB,GAAI;EAC7D,UAAA,oBAAC,OAAO,QAAR;GACO;GACL,cAAY;GACZ,UAAU,UAAU,cAAc,UAAU;
|
|
1
|
+
{"version":3,"file":"BitkitControlButton.js","names":[],"sources":["../../../lib/components/BitkitControlButton/BitkitControlButton.tsx"],"sourcesContent":["import { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, type HTMLChakraProps, useRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type KeyboardEvent, type MouseEvent, type Ref } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport opensPopup from '../../utilities/opensPopup';\nimport BitkitLabelTooltip, { type BitkitLabelTooltipProps } from '../BitkitLabelTooltip/BitkitLabelTooltip';\n\ntype ControlButtonSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg';\n\ninterface BitkitControlButtonCommonProps {\n icon: BitkitIconComponent;\n isDanger?: boolean;\n label: string;\n size?: ControlButtonSize;\n state?: 'disabled' | 'skeleton';\n /**\n * Overrides for the label tooltip. It is off by default when this control opens a popup — a menu,\n * select or popover trigger — where the panel is the affordance and a tooltip would hover over it.\n * Pass `{ disabled: false }` to bring it back. The accessible name comes from `label` either way.\n */\n tooltipProps?: Partial<Omit<BitkitLabelTooltipProps, 'children' | 'text'>>;\n}\n\n// Exported so dependent declarations can name it: `BitkitTabs.AddButton`'s props derive from\n// `Extract<BitkitControlButtonProps, { href?: undefined }>` (this type), and the .d.ts emit\n// fails with TS4023 (\"cannot be named\") if it isn't exported.\nexport interface BitkitControlButtonAsButtonProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'button'>, 'children' | 'disabled' | 'size'> {\n href?: undefined;\n isExternal?: undefined;\n}\n\nexport interface BitkitControlButtonAsAnchorProps\n extends BitkitControlButtonCommonProps, Omit<HTMLChakraProps<'a'>, 'children' | 'size'> {\n href: string;\n isExternal?: boolean;\n}\n\nexport type BitkitControlButtonProps = BitkitControlButtonAsButtonProps | BitkitControlButtonAsAnchorProps;\n\nconst BitkitControlButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, BitkitControlButtonProps>(\n (props, ref) => {\n const Icon = props.icon;\n const size = props.size ?? 'sm';\n const recipe = useRecipe({ key: 'controlButton' });\n const iconSize = size === 'xxs' || size === 'xs' ? '16' : '24';\n const isDisabled = props.state === 'disabled';\n const isSkeleton = props.state === 'skeleton';\n const isPopupTrigger = opensPopup(props);\n const inertOnClick = isDisabled || isSkeleton;\n\n // --- Anchor mode (href) ---\n if (props.href !== undefined) {\n const {\n href,\n icon: _icon,\n isDanger,\n isExternal,\n label,\n onClick,\n onKeyDown,\n rel,\n size: _size,\n state: _state,\n target,\n tooltipProps,\n ...anchorRest\n } = props;\n const effectiveTarget = isExternal ? '_blank' : target;\n const effectiveRel = isExternal ? (rel ? `${rel} noreferrer noopener` : 'noreferrer noopener') : rel;\n const handleClick = inertOnClick\n ? (e: MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault();\n e.stopPropagation();\n }\n : onClick;\n const handleKeyDown = inertOnClick\n ? (e: KeyboardEvent<HTMLAnchorElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n : onKeyDown;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.a\n ref={ref as Ref<HTMLAnchorElement>}\n aria-disabled={inertOnClick || undefined}\n aria-label={label}\n {...anchorRest}\n css={recipe({ isDanger, size })}\n href={inertOnClick ? undefined : href}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n rel={effectiveRel}\n target={effectiveTarget}\n >\n <Skeleton loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.a>\n </BitkitLabelTooltip>\n );\n }\n\n // --- Button mode (default) ---\n const { icon: _icon, isDanger, label, size: _size, state, tooltipProps, ...buttonRest } = props;\n return (\n <BitkitLabelTooltip text={label} disabled={isPopupTrigger} {...tooltipProps}>\n <chakra.button\n ref={ref as Ref<HTMLButtonElement>}\n aria-label={label}\n disabled={state === 'disabled' || state === 'skeleton'}\n // A control button is an action, not a form submit — without this it would submit any\n // form it happens to sit inside. Before the spread, so a consumer can still opt into\n // `type=\"submit\"`.\n type=\"button\"\n {...buttonRest}\n css={recipe({ isDanger, size })}\n >\n <Skeleton loading={isSkeleton}>\n <Icon size={iconSize} />\n </Skeleton>\n </chakra.button>\n </BitkitLabelTooltip>\n );\n },\n);\n\nBitkitControlButton.displayName = 'BitkitControlButton';\n\nexport default BitkitControlButton;\n"],"mappings":";;;;;;;AAyCA,IAAM,sBAAsB,YACzB,OAAO,QAAQ;CACd,MAAM,OAAO,MAAM;CACnB,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,SAAS,UAAU,EAAE,KAAK,gBAAgB,CAAC;CACjD,MAAM,WAAW,SAAS,SAAS,SAAS,OAAO,OAAO;CAC1D,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,aAAa,MAAM,UAAU;CACnC,MAAM,iBAAiB,WAAW,KAAK;CACvC,MAAM,eAAe,cAAc;CAGnC,IAAI,MAAM,SAAS,KAAA,GAAW;EAC5B,MAAM,EACJ,MACA,MAAM,OACN,UACA,YACA,OACA,SACA,WACA,KACA,MAAM,OACN,OAAO,QACP,QACA,cACA,GAAG,eACD;EACJ,MAAM,kBAAkB,aAAa,WAAW;EAChD,MAAM,eAAe,aAAc,MAAM,GAAG,IAAI,wBAAwB,wBAAyB;EACjG,MAAM,cAAc,gBACf,MAAqC;GACpC,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB,IACA;EACJ,MAAM,gBAAgB,gBACjB,MAAwC;GACvC,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;IACtC,EAAE,eAAe;IACjB,EAAE,gBAAgB;GACpB;EACF,IACA;EACJ,OACE,oBAAC,oBAAD;GAAoB,MAAM;GAAO,UAAU;GAAgB,GAAI;GAC7D,UAAA,oBAAC,OAAO,GAAR;IACO;IACL,iBAAe,gBAAgB,KAAA;IAC/B,cAAY;IACZ,GAAI;IACJ,KAAK,OAAO;KAAE;KAAU;IAAK,CAAC;IAC9B,MAAM,eAAe,KAAA,IAAY;IACjC,SAAS;IACT,WAAW;IACX,KAAK;IACL,QAAQ;IAER,UAAA,oBAAC,UAAD;KAAU,SAAS;KACjB,UAAA,oBAAC,MAAD,EAAM,MAAM,SAAW,CAAA;IACf,CAAA;GACF,CAAA;EACQ,CAAA;CAExB;CAGA,MAAM,EAAE,MAAM,OAAO,UAAU,OAAO,MAAM,OAAO,OAAO,cAAc,GAAG,eAAe;CAC1F,OACE,oBAAC,oBAAD;EAAoB,MAAM;EAAO,UAAU;EAAgB,GAAI;EAC7D,UAAA,oBAAC,OAAO,QAAR;GACO;GACL,cAAY;GACZ,UAAU,UAAU,cAAc,UAAU;GAI5C,MAAK;GACL,GAAI;GACJ,KAAK,OAAO;IAAE;IAAU;GAAK,CAAC;GAE9B,UAAA,oBAAC,UAAD;IAAU,SAAS;IACjB,UAAA,oBAAC,MAAD,EAAM,MAAM,SAAW,CAAA;GACf,CAAA;EACG,CAAA;CACG,CAAA;AAExB,CACF;AAEA,oBAAoB,cAAc"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BoxProps } from '@chakra-ui/react/box';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { BitkitIconComponent } from '../../icons';
|
|
3
4
|
export interface BitkitGroupHeadingProps extends Omit<BoxProps, 'icon'> {
|
|
5
|
+
badge?: ReactNode;
|
|
4
6
|
icon?: BitkitIconComponent;
|
|
5
7
|
label: string;
|
|
6
8
|
}
|
|
@@ -5,22 +5,26 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { Separator } from "@chakra-ui/react/separator";
|
|
6
6
|
//#region lib/components/BitkitGroupHeading/BitkitGroupHeading.tsx
|
|
7
7
|
var BitkitGroupHeading = forwardRef((props, ref) => {
|
|
8
|
-
const { icon: Icon, label, ...rest } = props;
|
|
8
|
+
const { badge, icon: Icon, label, ...rest } = props;
|
|
9
9
|
const styles = useSlotRecipe({ key: "groupHeading" })();
|
|
10
10
|
return /* @__PURE__ */ jsxs(Box, {
|
|
11
11
|
css: styles.root,
|
|
12
12
|
ref,
|
|
13
13
|
...rest,
|
|
14
|
-
children: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsxs(chakra.div, {
|
|
16
|
+
css: styles.titleBlock,
|
|
17
|
+
children: [Icon && /* @__PURE__ */ jsx(Icon, {
|
|
18
|
+
css: styles.icon,
|
|
19
|
+
size: "16"
|
|
20
|
+
}), /* @__PURE__ */ jsx(chakra.span, {
|
|
21
|
+
css: styles.label,
|
|
22
|
+
children: label
|
|
23
|
+
})]
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ jsx(Separator, { css: styles.separator }),
|
|
26
|
+
badge
|
|
27
|
+
]
|
|
24
28
|
});
|
|
25
29
|
});
|
|
26
30
|
BitkitGroupHeading.displayName = "BitkitGroupHeading";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitGroupHeading.js","names":[],"sources":["../../../lib/components/BitkitGroupHeading/BitkitGroupHeading.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\nimport { Separator } from '@chakra-ui/react/separator';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\n\nexport interface BitkitGroupHeadingProps extends Omit<BoxProps, 'icon'> {\n icon?: BitkitIconComponent;\n label: string;\n}\n\nconst BitkitGroupHeading = forwardRef<HTMLDivElement, BitkitGroupHeadingProps>((props, ref) => {\n const { icon: Icon, label, ...rest } = props;\n\n const recipe = useSlotRecipe({ key: 'groupHeading' });\n const styles = recipe();\n\n return (\n <Box css={styles.root} ref={ref} {...rest}>\n <chakra.div css={styles.titleBlock}>\n {Icon && <Icon css={styles.icon} size=\"16\" />}\n <chakra.span css={styles.label}>{label}</chakra.span>\n </chakra.div>\n <Separator css={styles.separator} />\n </Box>\n );\n});\n\nBitkitGroupHeading.displayName = 'BitkitGroupHeading';\n\nexport default BitkitGroupHeading;\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"BitkitGroupHeading.js","names":[],"sources":["../../../lib/components/BitkitGroupHeading/BitkitGroupHeading.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\nimport { Separator } from '@chakra-ui/react/separator';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type ReactNode } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\n\nexport interface BitkitGroupHeadingProps extends Omit<BoxProps, 'icon'> {\n badge?: ReactNode;\n icon?: BitkitIconComponent;\n label: string;\n}\n\nconst BitkitGroupHeading = forwardRef<HTMLDivElement, BitkitGroupHeadingProps>((props, ref) => {\n const { badge, icon: Icon, label, ...rest } = props;\n\n const recipe = useSlotRecipe({ key: 'groupHeading' });\n const styles = recipe();\n\n return (\n <Box css={styles.root} ref={ref} {...rest}>\n <chakra.div css={styles.titleBlock}>\n {Icon && <Icon css={styles.icon} size=\"16\" />}\n <chakra.span css={styles.label}>{label}</chakra.span>\n </chakra.div>\n <Separator css={styles.separator} />\n {badge}\n </Box>\n );\n});\n\nBitkitGroupHeading.displayName = 'BitkitGroupHeading';\n\nexport default BitkitGroupHeading;\n"],"mappings":";;;;;;AAaA,IAAM,qBAAqB,YAAqD,OAAO,QAAQ;CAC7F,MAAM,EAAE,OAAO,MAAM,MAAM,OAAO,GAAG,SAAS;CAG9C,MAAM,SADS,cAAc,EAAE,KAAK,eAAe,CACpC,CAAA,CAAO;CAEtB,OACE,qBAAC,KAAD;EAAK,KAAK,OAAO;EAAW;EAAK,GAAI;EAArC,UAAA;GACE,qBAAC,OAAO,KAAR;IAAY,KAAK,OAAO;IAAxB,UAAA,CACG,QAAQ,oBAAC,MAAD;KAAM,KAAK,OAAO;KAAM,MAAK;IAAM,CAAA,GAC5C,oBAAC,OAAO,MAAR;KAAa,KAAK,OAAO;KAAQ,UAAA;IAAmB,CAAA,CAC1C;;GACZ,oBAAC,WAAD,EAAW,KAAK,OAAO,UAAY,CAAA;GAClC;EACE;;AAET,CAAC;AAED,mBAAmB,cAAc"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { BoxProps } from '@chakra-ui/react/box';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface BitkitPageHeaderProps extends Omit<BoxProps, 'title'> {
|
|
4
|
+
/**
|
|
5
|
+
* Avatar, app icon or thumbnail rendered before the title. Hidden in the collapsed layout.
|
|
6
|
+
*
|
|
7
|
+
* Belongs to the sub-page layouts: the design's main-page header is a title and its subtitle with
|
|
8
|
+
* no avatar, so pass this alongside a `breadcrumb`.
|
|
9
|
+
*
|
|
10
|
+
* Size it to match the design's two sub-page cards, since the node is yours to build: `size="40"`
|
|
11
|
+
* (8px radius) against a bare title, and `size="48"` (10px radius) once `secondaryText` is
|
|
12
|
+
* present — the same avatar the `app` and `user` content shapes use.
|
|
13
|
+
*/
|
|
14
|
+
avatar?: ReactNode;
|
|
15
|
+
/** Badge rendered next to the title. Hidden in the collapsed layout. */
|
|
16
|
+
badge?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Breadcrumb trail above the title — pass a `BitkitBreadcrumb`. Its presence is what switches the
|
|
19
|
+
* header from the design's main-page layout to a sub-page one, so there is no separate page-type
|
|
20
|
+
* prop: the recipe's own `hasBreadcrumb` variant is derived from it.
|
|
21
|
+
*
|
|
22
|
+
* The two layouts carry more than the trail. A main-page header is a title and its subtitle —
|
|
23
|
+
* top-level pages and product overviews — with no avatar and no `app`/`user` content shape. Those
|
|
24
|
+
* belong to sub-pages, so pass them together with a trail.
|
|
25
|
+
*/
|
|
26
|
+
breadcrumb?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Trailing action buttons. Stacked full-width below the title on mobile, primary action on top.
|
|
29
|
+
*
|
|
30
|
+
* The collapsed row is built for `size="sm"` buttons and the expanded header for `size="md"`.
|
|
31
|
+
* Actions arrive as children, so the component cannot set that for you — pass a flat `size="sm"`
|
|
32
|
+
* whenever `minimal` or `isSticky` is in play.
|
|
33
|
+
*
|
|
34
|
+
* Flat, not responsive: Bitkit icons render a different SVG asset per size, so `BitkitButton`
|
|
35
|
+
* resolves `size` in JS and a `{ base, tablet }` object matches no key, falling through to a 24px
|
|
36
|
+
* icon in a 32px button. Since the header collapses in CSS from `tablet` up, a `sm` action is a
|
|
37
|
+
* little small in the expanded mobile layout — but the design draws no mobile frame for the
|
|
38
|
+
* collapsed variants, so `sm` is the closer of the two.
|
|
39
|
+
*/
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Shape of the title block, mirroring the design's `content` property. `title` is a page title
|
|
43
|
+
* with an optional subtitle; `app` and `user` are the tighter entity layouts — a larger avatar
|
|
44
|
+
* centred against a smaller title and 14px secondary text. They differ only in the gap between
|
|
45
|
+
* the avatar and the text, 16 and 12 respectively.
|
|
46
|
+
*/
|
|
47
|
+
contentVariant?: 'title' | 'app' | 'user';
|
|
48
|
+
/**
|
|
49
|
+
* Inline controls between the trail and the actions — a view switcher, filters, a settings menu.
|
|
50
|
+
* Their presence spreads the row into three groups instead of the usual trail-and-actions pair,
|
|
51
|
+
* which is the shape the design file calls `PageHeader-WFE`.
|
|
52
|
+
*
|
|
53
|
+
* Belongs to the collapsed row, so it is honoured by `variant="minimal"` *and* by `isSticky` —
|
|
54
|
+
* the two produce the same row — and ignored in the expanded layouts, which the design draws no
|
|
55
|
+
* controls in.
|
|
56
|
+
*/
|
|
57
|
+
controls?: ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Renders the compact single-row layout used while the header is stuck to the top of the viewport.
|
|
60
|
+
* Appearance only — the consumer owns scroll detection and any portalling, since the sticky offset
|
|
61
|
+
* and header container are application concerns.
|
|
62
|
+
*
|
|
63
|
+
* Ignored below the `tablet` breakpoint, where the header always stays expanded.
|
|
64
|
+
*
|
|
65
|
+
* Pair it with `size="sm"` actions — see `children`.
|
|
66
|
+
*/
|
|
67
|
+
isSticky?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Descriptive text below the title. Hidden in the collapsed layout.
|
|
70
|
+
*
|
|
71
|
+
* A string, like `title`, so it can be truncated to one line and carried in full by the tooltip
|
|
72
|
+
* that appears when it does not fit.
|
|
73
|
+
*/
|
|
74
|
+
secondaryText?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Tab bar along the bottom edge — pass a `BitkitTabs.List`. Hidden in the collapsed layout.
|
|
77
|
+
*
|
|
78
|
+
* The node is rendered inside the header, so tab panels cannot be siblings of the row. To drive
|
|
79
|
+
* page content from it, put `BitkitTabs.Root` around the header *and* the content, and pass only
|
|
80
|
+
* the list here — `BitkitTabs.List` reads its Root from context and throws without an ancestor:
|
|
81
|
+
*
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <BitkitTabs.Root defaultValue="overview">
|
|
84
|
+
* <BitkitPageHeader tabs={<BitkitTabs.List>…</BitkitTabs.List>} title="Build Hub" />
|
|
85
|
+
* <BitkitTabs.ContentGroup>
|
|
86
|
+
* <BitkitTabs.Content padding="32" value="overview">…</BitkitTabs.Content>
|
|
87
|
+
* </BitkitTabs.ContentGroup>
|
|
88
|
+
* </BitkitTabs.Root>
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* Only the row is hidden when the header collapses — the panels live outside it and keep
|
|
92
|
+
* rendering, so the page never blanks.
|
|
93
|
+
*/
|
|
94
|
+
tabs?: ReactNode;
|
|
95
|
+
/**
|
|
96
|
+
* The page title, as a string. Everything passed here lands inside the `h1`, so it is the
|
|
97
|
+
* heading's accessible name and nothing else belongs in it — the avatar, badge and secondary
|
|
98
|
+
* text each have their own slot. Required: it is what gives the header a page heading at every
|
|
99
|
+
* breakpoint.
|
|
100
|
+
*
|
|
101
|
+
* Truncated to a single line with an ellipsis. When it does not fit, hovering or focusing it
|
|
102
|
+
* shows the full string in a tooltip — so a long title never grows the header.
|
|
103
|
+
*
|
|
104
|
+
* In the collapsed layout (`minimal` or `isSticky`) *with* a `breadcrumb`, the design shows the
|
|
105
|
+
* title in the trail rather than as a heading, so end the breadcrumb with a
|
|
106
|
+
* `BitkitBreadcrumb.CurrentItem` carrying it — the title is then rendered as a visually hidden
|
|
107
|
+
* `h1`, since `Breadcrumb.CurrentLink` is a link and not a heading. Below `tablet` the header
|
|
108
|
+
* never collapses and the visible heading is used instead (`BitkitBreadcrumb` drops its
|
|
109
|
+
* `CurrentItem` on mobile).
|
|
110
|
+
*/
|
|
111
|
+
title: string;
|
|
112
|
+
/**
|
|
113
|
+
* `minimal` collapses the header to the single breadcrumb row used by sub-pages that don't repeat
|
|
114
|
+
* their title as a heading. Like `isSticky`, it only collapses from `tablet` up, and expects
|
|
115
|
+
* `size="sm"` actions — see `children`.
|
|
116
|
+
*/
|
|
117
|
+
variant?: 'default' | 'minimal';
|
|
118
|
+
}
|
|
119
|
+
declare const BitkitPageHeader: import('react').ForwardRefExoticComponent<BitkitPageHeaderProps & import('react').RefAttributes<HTMLElement>>;
|
|
120
|
+
export default BitkitPageHeader;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { isEmptyNode } from "../../utilities/isEmptyNode.js";
|
|
2
|
+
import BitkitOverflowTooltip from "../BitkitOverflowTooltip/BitkitOverflowTooltip.js";
|
|
3
|
+
import useIsTruncated from "../../utilities/useIsTruncated.js";
|
|
4
|
+
import { Box } from "@chakra-ui/react/box";
|
|
5
|
+
import { useSlotRecipe } from "@chakra-ui/react/styled-system";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Text } from "@chakra-ui/react/text";
|
|
9
|
+
//#region lib/components/BitkitPageHeader/BitkitPageHeader.tsx
|
|
10
|
+
var BitkitPageHeader = forwardRef((props, ref) => {
|
|
11
|
+
const { avatar, badge, breadcrumb, children, contentVariant, controls, isSticky, secondaryText, tabs, title, variant, ...rest } = props;
|
|
12
|
+
const hasAvatar = !isEmptyNode(avatar);
|
|
13
|
+
const hasBadge = !isEmptyNode(badge);
|
|
14
|
+
const hasBreadcrumb = !isEmptyNode(breadcrumb);
|
|
15
|
+
const hasActions = !isEmptyNode(children);
|
|
16
|
+
const hasSecondaryText = !isEmptyNode(secondaryText);
|
|
17
|
+
const hasTabs = !isEmptyNode(tabs);
|
|
18
|
+
const { isTruncated: isTitleTruncated, ref: titleRef } = useIsTruncated(title);
|
|
19
|
+
const { isTruncated: isSecondaryTruncated, ref: secondaryRef } = useIsTruncated(secondaryText);
|
|
20
|
+
const isCollapsed = variant === "minimal" || Boolean(isSticky);
|
|
21
|
+
const showControls = !isEmptyNode(controls) && isCollapsed;
|
|
22
|
+
const canShowTitleTooltip = isTitleTruncated && !(isCollapsed && hasBreadcrumb);
|
|
23
|
+
const styles = useSlotRecipe({ key: "pageHeader" })({
|
|
24
|
+
contentVariant,
|
|
25
|
+
hasBreadcrumb,
|
|
26
|
+
hasControls: showControls,
|
|
27
|
+
isSticky,
|
|
28
|
+
variant
|
|
29
|
+
});
|
|
30
|
+
const controlsNode = showControls ? /* @__PURE__ */ jsx(Box, {
|
|
31
|
+
css: styles.controls,
|
|
32
|
+
children: controls
|
|
33
|
+
}) : null;
|
|
34
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
35
|
+
as: "header",
|
|
36
|
+
css: styles.root,
|
|
37
|
+
ref,
|
|
38
|
+
...rest,
|
|
39
|
+
children: [/* @__PURE__ */ jsxs(Box, {
|
|
40
|
+
css: styles.headerBlock,
|
|
41
|
+
children: [
|
|
42
|
+
hasBreadcrumb && /* @__PURE__ */ jsx(Box, {
|
|
43
|
+
css: styles.breadcrumb,
|
|
44
|
+
children: breadcrumb
|
|
45
|
+
}),
|
|
46
|
+
hasBreadcrumb && controlsNode,
|
|
47
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
48
|
+
css: styles.contentBlock,
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
51
|
+
css: styles.titleBlock,
|
|
52
|
+
children: [hasAvatar && /* @__PURE__ */ jsx(Box, {
|
|
53
|
+
css: styles.avatar,
|
|
54
|
+
children: avatar
|
|
55
|
+
}), /* @__PURE__ */ jsxs(Box, {
|
|
56
|
+
css: styles.textBlock,
|
|
57
|
+
children: [/* @__PURE__ */ jsxs(Box, {
|
|
58
|
+
css: styles.titleRow,
|
|
59
|
+
children: [/* @__PURE__ */ jsx(BitkitOverflowTooltip, {
|
|
60
|
+
disabled: !canShowTitleTooltip,
|
|
61
|
+
placement: "bottom-start",
|
|
62
|
+
text: title,
|
|
63
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
64
|
+
as: "h1",
|
|
65
|
+
css: styles.title,
|
|
66
|
+
ref: titleRef,
|
|
67
|
+
tabIndex: canShowTitleTooltip ? 0 : void 0,
|
|
68
|
+
children: title
|
|
69
|
+
})
|
|
70
|
+
}), hasBadge && /* @__PURE__ */ jsx(Box, {
|
|
71
|
+
css: styles.badge,
|
|
72
|
+
children: badge
|
|
73
|
+
})]
|
|
74
|
+
}), hasSecondaryText && secondaryText !== void 0 && /* @__PURE__ */ jsx(BitkitOverflowTooltip, {
|
|
75
|
+
disabled: !isSecondaryTruncated,
|
|
76
|
+
placement: "bottom-start",
|
|
77
|
+
text: secondaryText,
|
|
78
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
79
|
+
css: styles.secondaryText,
|
|
80
|
+
ref: secondaryRef,
|
|
81
|
+
tabIndex: isSecondaryTruncated ? 0 : void 0,
|
|
82
|
+
children: secondaryText
|
|
83
|
+
})
|
|
84
|
+
})]
|
|
85
|
+
})]
|
|
86
|
+
}),
|
|
87
|
+
!hasBreadcrumb && controlsNode,
|
|
88
|
+
hasActions && /* @__PURE__ */ jsx(Box, {
|
|
89
|
+
css: styles.actionBlock,
|
|
90
|
+
children
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
}), hasTabs && /* @__PURE__ */ jsx(Box, {
|
|
96
|
+
css: styles.tabs,
|
|
97
|
+
children: tabs
|
|
98
|
+
})]
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
BitkitPageHeader.displayName = "BitkitPageHeader";
|
|
102
|
+
//#endregion
|
|
103
|
+
export { BitkitPageHeader as default };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=BitkitPageHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitkitPageHeader.js","names":[],"sources":["../../../lib/components/BitkitPageHeader/BitkitPageHeader.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\nimport { useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { Text } from '@chakra-ui/react/text';\nimport { forwardRef, type ReactNode } from 'react';\n\nimport { isEmptyNode } from '../../utilities/isEmptyNode';\nimport useIsTruncated from '../../utilities/useIsTruncated';\nimport BitkitOverflowTooltip from '../BitkitOverflowTooltip/BitkitOverflowTooltip';\n\nexport interface BitkitPageHeaderProps extends Omit<BoxProps, 'title'> {\n /**\n * Avatar, app icon or thumbnail rendered before the title. Hidden in the collapsed layout.\n *\n * Belongs to the sub-page layouts: the design's main-page header is a title and its subtitle with\n * no avatar, so pass this alongside a `breadcrumb`.\n *\n * Size it to match the design's two sub-page cards, since the node is yours to build: `size=\"40\"`\n * (8px radius) against a bare title, and `size=\"48\"` (10px radius) once `secondaryText` is\n * present — the same avatar the `app` and `user` content shapes use.\n */\n avatar?: ReactNode;\n /** Badge rendered next to the title. Hidden in the collapsed layout. */\n badge?: ReactNode;\n /**\n * Breadcrumb trail above the title — pass a `BitkitBreadcrumb`. Its presence is what switches the\n * header from the design's main-page layout to a sub-page one, so there is no separate page-type\n * prop: the recipe's own `hasBreadcrumb` variant is derived from it.\n *\n * The two layouts carry more than the trail. A main-page header is a title and its subtitle —\n * top-level pages and product overviews — with no avatar and no `app`/`user` content shape. Those\n * belong to sub-pages, so pass them together with a trail.\n */\n breadcrumb?: ReactNode;\n /**\n * Trailing action buttons. Stacked full-width below the title on mobile, primary action on top.\n *\n * The collapsed row is built for `size=\"sm\"` buttons and the expanded header for `size=\"md\"`.\n * Actions arrive as children, so the component cannot set that for you — pass a flat `size=\"sm\"`\n * whenever `minimal` or `isSticky` is in play.\n *\n * Flat, not responsive: Bitkit icons render a different SVG asset per size, so `BitkitButton`\n * resolves `size` in JS and a `{ base, tablet }` object matches no key, falling through to a 24px\n * icon in a 32px button. Since the header collapses in CSS from `tablet` up, a `sm` action is a\n * little small in the expanded mobile layout — but the design draws no mobile frame for the\n * collapsed variants, so `sm` is the closer of the two.\n */\n children?: ReactNode;\n /**\n * Shape of the title block, mirroring the design's `content` property. `title` is a page title\n * with an optional subtitle; `app` and `user` are the tighter entity layouts — a larger avatar\n * centred against a smaller title and 14px secondary text. They differ only in the gap between\n * the avatar and the text, 16 and 12 respectively.\n */\n contentVariant?: 'title' | 'app' | 'user';\n /**\n * Inline controls between the trail and the actions — a view switcher, filters, a settings menu.\n * Their presence spreads the row into three groups instead of the usual trail-and-actions pair,\n * which is the shape the design file calls `PageHeader-WFE`.\n *\n * Belongs to the collapsed row, so it is honoured by `variant=\"minimal\"` *and* by `isSticky` —\n * the two produce the same row — and ignored in the expanded layouts, which the design draws no\n * controls in.\n */\n controls?: ReactNode;\n /**\n * Renders the compact single-row layout used while the header is stuck to the top of the viewport.\n * Appearance only — the consumer owns scroll detection and any portalling, since the sticky offset\n * and header container are application concerns.\n *\n * Ignored below the `tablet` breakpoint, where the header always stays expanded.\n *\n * Pair it with `size=\"sm\"` actions — see `children`.\n */\n isSticky?: boolean;\n /**\n * Descriptive text below the title. Hidden in the collapsed layout.\n *\n * A string, like `title`, so it can be truncated to one line and carried in full by the tooltip\n * that appears when it does not fit.\n */\n secondaryText?: string;\n /**\n * Tab bar along the bottom edge — pass a `BitkitTabs.List`. Hidden in the collapsed layout.\n *\n * The node is rendered inside the header, so tab panels cannot be siblings of the row. To drive\n * page content from it, put `BitkitTabs.Root` around the header *and* the content, and pass only\n * the list here — `BitkitTabs.List` reads its Root from context and throws without an ancestor:\n *\n * ```tsx\n * <BitkitTabs.Root defaultValue=\"overview\">\n * <BitkitPageHeader tabs={<BitkitTabs.List>…</BitkitTabs.List>} title=\"Build Hub\" />\n * <BitkitTabs.ContentGroup>\n * <BitkitTabs.Content padding=\"32\" value=\"overview\">…</BitkitTabs.Content>\n * </BitkitTabs.ContentGroup>\n * </BitkitTabs.Root>\n * ```\n *\n * Only the row is hidden when the header collapses — the panels live outside it and keep\n * rendering, so the page never blanks.\n */\n tabs?: ReactNode;\n /**\n * The page title, as a string. Everything passed here lands inside the `h1`, so it is the\n * heading's accessible name and nothing else belongs in it — the avatar, badge and secondary\n * text each have their own slot. Required: it is what gives the header a page heading at every\n * breakpoint.\n *\n * Truncated to a single line with an ellipsis. When it does not fit, hovering or focusing it\n * shows the full string in a tooltip — so a long title never grows the header.\n *\n * In the collapsed layout (`minimal` or `isSticky`) *with* a `breadcrumb`, the design shows the\n * title in the trail rather than as a heading, so end the breadcrumb with a\n * `BitkitBreadcrumb.CurrentItem` carrying it — the title is then rendered as a visually hidden\n * `h1`, since `Breadcrumb.CurrentLink` is a link and not a heading. Below `tablet` the header\n * never collapses and the visible heading is used instead (`BitkitBreadcrumb` drops its\n * `CurrentItem` on mobile).\n */\n title: string;\n /**\n * `minimal` collapses the header to the single breadcrumb row used by sub-pages that don't repeat\n * their title as a heading. Like `isSticky`, it only collapses from `tablet` up, and expects\n * `size=\"sm\"` actions — see `children`.\n */\n variant?: 'default' | 'minimal';\n}\n\nconst BitkitPageHeader = forwardRef<HTMLElement, BitkitPageHeaderProps>((props, ref) => {\n const {\n avatar,\n badge,\n breadcrumb,\n children,\n contentVariant,\n controls,\n isSticky,\n secondaryText,\n tabs,\n title,\n variant,\n ...rest\n } = props;\n\n // Which slots the collapsed row drops, and whether it collapses at all, is decided entirely by\n // the recipe's `tablet`-scoped styles. Nothing here branches on the viewport: a breakpoint hook\n // would render the wrong layout on first paint, since Chakra's `useMediaQuery` returns its\n // fallback until after mount.\n\n // A slot's presence is its own toggle, so all of them share one emptiness test rather than plain\n // truthiness: an array whose entries all render nothing — `items.map()` where every branch is\n // `null` — is still truthy, and would otherwise render a wrapper that only contributes gap. For\n // `controls` it would also spread the row into three groups around an empty middle one.\n const hasAvatar = !isEmptyNode(avatar);\n const hasBadge = !isEmptyNode(badge);\n const hasBreadcrumb = !isEmptyNode(breadcrumb);\n const hasActions = !isEmptyNode(children);\n const hasSecondaryText = !isEmptyNode(secondaryText);\n const hasTabs = !isEmptyNode(tabs);\n\n // `BitkitOverflowTooltip` does no measuring of its own — it shows the tooltip unless told not to,\n // so each truncating text reports whether it is actually clipped and suppresses its own tooltip\n // when it is not. Keyed on the text so a change re-measures without waiting for a resize.\n const { isTruncated: isTitleTruncated, ref: titleRef } = useIsTruncated<HTMLHeadingElement>(title);\n const { isTruncated: isSecondaryTruncated, ref: secondaryRef } = useIsTruncated<HTMLParagraphElement>(secondaryText);\n\n // The design only draws inline controls in the collapsed row, so they are ignored in the\n // expanded layouts rather than left to land somewhere undesigned. `minimal` and `isSticky`\n // produce that row through the same `collapsedSlots`, so both have to honour them — gating on\n // `minimal` alone left `isSticky` rendering the identical row with the middle group missing.\n const isCollapsed = variant === 'minimal' || Boolean(isSticky);\n const showControls = !isEmptyNode(controls) && isCollapsed;\n\n // The collapsed row with a trail makes the title block `srOnly`, which is a 1px box — so the\n // measurement reports \"truncated\" for a heading nobody can see. Left alone that puts a tab stop\n // on an invisible element and opens a tooltip against it. The trail already carries the title as\n // its current item in exactly that layout, so there is nothing to surface anyway.\n const canShowTitleTooltip = isTitleTruncated && !(isCollapsed && hasBreadcrumb);\n\n const recipe = useSlotRecipe({ key: 'pageHeader' });\n const styles = recipe({\n contentVariant,\n hasBreadcrumb,\n hasControls: showControls,\n isSticky,\n variant,\n });\n\n // The controls are the middle of three groups, so they follow whichever element holds the left\n // slot: the trail when there is one, otherwise the title — which lives inside `contentBlock`, so\n // they have to go in there with it rather than beside it.\n const controlsNode = showControls ? <Box css={styles.controls}>{controls}</Box> : null;\n\n return (\n <Box as=\"header\" css={styles.root} ref={ref} {...rest}>\n <Box css={styles.headerBlock}>\n {hasBreadcrumb && <Box css={styles.breadcrumb}>{breadcrumb}</Box>}\n\n {hasBreadcrumb && controlsNode}\n\n <Box css={styles.contentBlock}>\n <Box css={styles.titleBlock}>\n {hasAvatar && <Box css={styles.avatar}>{avatar}</Box>}\n\n <Box css={styles.textBlock}>\n <Box css={styles.titleRow}>\n {/*\n `bottom-start` rather than the tooltip's default `right`: these texts are\n full-width rows, so a right-hand tooltip lands over the actions. Opening below and\n aligned to the text's start keeps it clear of them and lines it up with the text\n it repeats.\n */}\n <BitkitOverflowTooltip disabled={!canShowTitleTooltip} placement=\"bottom-start\" text={title}>\n {/*\n `tabIndex` only while truncated: the tooltip trigger is rendered `asChild`, so an\n `h1` stays unfocusable and the full title would be mouse-only. Adding the tab\n stop unconditionally would put one in every header for no benefit.\n */}\n <Text as=\"h1\" css={styles.title} ref={titleRef} tabIndex={canShowTitleTooltip ? 0 : undefined}>\n {title}\n </Text>\n </BitkitOverflowTooltip>\n {hasBadge && <Box css={styles.badge}>{badge}</Box>}\n </Box>\n\n {hasSecondaryText && secondaryText !== undefined && (\n <BitkitOverflowTooltip disabled={!isSecondaryTruncated} placement=\"bottom-start\" text={secondaryText}>\n <Text css={styles.secondaryText} ref={secondaryRef} tabIndex={isSecondaryTruncated ? 0 : undefined}>\n {secondaryText}\n </Text>\n </BitkitOverflowTooltip>\n )}\n </Box>\n </Box>\n\n {!hasBreadcrumb && controlsNode}\n\n {hasActions && <Box css={styles.actionBlock}>{children}</Box>}\n </Box>\n </Box>\n\n {hasTabs && <Box css={styles.tabs}>{tabs}</Box>}\n </Box>\n );\n});\n\nBitkitPageHeader.displayName = 'BitkitPageHeader';\n\nexport default BitkitPageHeader;\n"],"mappings":";;;;;;;;;AA8HA,IAAM,mBAAmB,YAAgD,OAAO,QAAQ;CACtF,MAAM,EACJ,QACA,OACA,YACA,UACA,gBACA,UACA,UACA,eACA,MACA,OACA,SACA,GAAG,SACD;CAWJ,MAAM,YAAY,CAAC,YAAY,MAAM;CACrC,MAAM,WAAW,CAAC,YAAY,KAAK;CACnC,MAAM,gBAAgB,CAAC,YAAY,UAAU;CAC7C,MAAM,aAAa,CAAC,YAAY,QAAQ;CACxC,MAAM,mBAAmB,CAAC,YAAY,aAAa;CACnD,MAAM,UAAU,CAAC,YAAY,IAAI;CAKjC,MAAM,EAAE,aAAa,kBAAkB,KAAK,aAAa,eAAmC,KAAK;CACjG,MAAM,EAAE,aAAa,sBAAsB,KAAK,iBAAiB,eAAqC,aAAa;CAMnH,MAAM,cAAc,YAAY,aAAa,QAAQ,QAAQ;CAC7D,MAAM,eAAe,CAAC,YAAY,QAAQ,KAAK;CAM/C,MAAM,sBAAsB,oBAAoB,EAAE,eAAe;CAGjE,MAAM,SADS,cAAc,EAAE,KAAK,aAAa,CAClC,CAAA,CAAO;EACpB;EACA;EACA,aAAa;EACb;EACA;CACF,CAAC;CAKD,MAAM,eAAe,eAAe,oBAAC,KAAD;EAAK,KAAK,OAAO;EAAW,UAAA;CAAc,CAAA,IAAI;CAElF,OACE,qBAAC,KAAD;EAAK,IAAG;EAAS,KAAK,OAAO;EAAW;EAAK,GAAI;EAAjD,UAAA,CACE,qBAAC,KAAD;GAAK,KAAK,OAAO;GAAjB,UAAA;IACG,iBAAiB,oBAAC,KAAD;KAAK,KAAK,OAAO;KAAa,UAAA;IAAgB,CAAA;IAE/D,iBAAiB;IAElB,qBAAC,KAAD;KAAK,KAAK,OAAO;KAAjB,UAAA;MACE,qBAAC,KAAD;OAAK,KAAK,OAAO;OAAjB,UAAA,CACG,aAAa,oBAAC,KAAD;QAAK,KAAK,OAAO;QAAS,UAAA;OAAY,CAAA,GAEpD,qBAAC,KAAD;QAAK,KAAK,OAAO;QAAjB,UAAA,CACE,qBAAC,KAAD;SAAK,KAAK,OAAO;SAAjB,UAAA,CAOE,oBAAC,uBAAD;UAAuB,UAAU,CAAC;UAAqB,WAAU;UAAe,MAAM;UAMpF,UAAA,oBAAC,MAAD;WAAM,IAAG;WAAK,KAAK,OAAO;WAAO,KAAK;WAAU,UAAU,sBAAsB,IAAI,KAAA;WACjF,UAAA;UACG,CAAA;SACe,CAAA,GACtB,YAAY,oBAAC,KAAD;UAAK,KAAK,OAAO;UAAQ,UAAA;SAAW,CAAA,CAC9C;QAEJ,CAAA,GAAA,oBAAoB,kBAAkB,KAAA,KACrC,oBAAC,uBAAD;SAAuB,UAAU,CAAC;SAAsB,WAAU;SAAe,MAAM;SACrF,UAAA,oBAAC,MAAD;UAAM,KAAK,OAAO;UAAe,KAAK;UAAc,UAAU,uBAAuB,IAAI,KAAA;UACtF,UAAA;SACG,CAAA;QACe,CAAA,CAEtB;OACF,CAAA,CAAA;;MAEJ,CAAC,iBAAiB;MAElB,cAAc,oBAAC,KAAD;OAAK,KAAK,OAAO;OAAc;MAAc,CAAA;KACzD;;GACF;EAEJ,CAAA,GAAA,WAAW,oBAAC,KAAD;GAAK,KAAK,OAAO;GAAO,UAAA;EAAU,CAAA,CAC3C;;AAET,CAAC;AAED,iBAAiB,cAAc"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { BoxProps } from '@chakra-ui/react/box';
|
|
2
|
+
import { SeparatorProps } from '@chakra-ui/react/separator';
|
|
3
|
+
import { HTMLChakraProps } from '@chakra-ui/react/styled-system';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { BitkitIconComponent } from '../../icons';
|
|
6
|
+
import { BitkitGroupHeadingProps } from '../BitkitGroupHeading/BitkitGroupHeading';
|
|
7
|
+
export interface BitkitPageSidebarProps extends BoxProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
interface BitkitPageSidebarItemCommonProps {
|
|
11
|
+
badge?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* The item's label. Typed as a string rather than `ReactNode` because the row truncates it with
|
|
14
|
+
* an ellipsis, and the overflow tooltip needs the full text to reveal.
|
|
15
|
+
*/
|
|
16
|
+
children: string;
|
|
17
|
+
icon?: BitkitIconComponent;
|
|
18
|
+
/**
|
|
19
|
+
* Marks the item as the current page. Mutually exclusive with `state="disabled"` — you cannot be
|
|
20
|
+
* on a page whose nav item is unavailable — but the two are not type-checked against each other:
|
|
21
|
+
* the combination only ever arrives from a computed `selected`, which no union can catch, and
|
|
22
|
+
* checking it would break the ordinary `selected={item.id === currentId}` mapping. If both do
|
|
23
|
+
* turn up, disabled wins, since that is the one of the two the design actually defines.
|
|
24
|
+
*/
|
|
25
|
+
selected?: boolean;
|
|
26
|
+
state?: 'disabled';
|
|
27
|
+
suffixIcon?: BitkitIconComponent;
|
|
28
|
+
}
|
|
29
|
+
interface BitkitPageSidebarItemLinkProps extends Omit<HTMLChakraProps<'a'>, 'children'>, BitkitPageSidebarItemCommonProps {
|
|
30
|
+
href: string;
|
|
31
|
+
}
|
|
32
|
+
interface BitkitPageSidebarItemButtonProps extends Omit<HTMLChakraProps<'button'>, 'children' | 'disabled'>, BitkitPageSidebarItemCommonProps {
|
|
33
|
+
href?: never;
|
|
34
|
+
}
|
|
35
|
+
export type BitkitPageSidebarItemProps = BitkitPageSidebarItemButtonProps | BitkitPageSidebarItemLinkProps;
|
|
36
|
+
interface BitkitPageSidebarTitleCommonProps extends BoxProps {
|
|
37
|
+
backLabel?: string;
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
interface BitkitPageSidebarTitleLinkProps extends BitkitPageSidebarTitleCommonProps {
|
|
41
|
+
backHref: string;
|
|
42
|
+
onBackClick?: never;
|
|
43
|
+
}
|
|
44
|
+
interface BitkitPageSidebarTitleButtonProps extends BitkitPageSidebarTitleCommonProps {
|
|
45
|
+
backHref?: never;
|
|
46
|
+
onBackClick: () => void;
|
|
47
|
+
}
|
|
48
|
+
interface BitkitPageSidebarTitlePlainProps extends BitkitPageSidebarTitleCommonProps {
|
|
49
|
+
backHref?: never;
|
|
50
|
+
onBackClick?: never;
|
|
51
|
+
}
|
|
52
|
+
export type BitkitPageSidebarTitleProps = BitkitPageSidebarTitleButtonProps | BitkitPageSidebarTitleLinkProps | BitkitPageSidebarTitlePlainProps;
|
|
53
|
+
export interface BitkitPageSidebarBodyProps extends BoxProps {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
export interface BitkitPageSidebarFooterProps extends BoxProps {
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
}
|
|
59
|
+
export interface BitkitPageSidebarProjectProps extends BoxProps {
|
|
60
|
+
label: string;
|
|
61
|
+
value: string;
|
|
62
|
+
}
|
|
63
|
+
export type BitkitPageSidebarGroupHeadingProps = BitkitGroupHeadingProps;
|
|
64
|
+
export type BitkitPageSidebarDividerProps = SeparatorProps;
|
|
65
|
+
declare const _default: import('react').ForwardRefExoticComponent<BitkitPageSidebarProps & import('react').RefAttributes<HTMLElement>> & {
|
|
66
|
+
Body: import('react').ForwardRefExoticComponent<BitkitPageSidebarBodyProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
67
|
+
Divider: import('react').ForwardRefExoticComponent<SeparatorProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
68
|
+
Footer: import('react').ForwardRefExoticComponent<BitkitPageSidebarFooterProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
69
|
+
GroupHeading: import('react').ForwardRefExoticComponent<BitkitGroupHeadingProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
70
|
+
Item: import('react').ForwardRefExoticComponent<BitkitPageSidebarItemProps & import('react').RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
71
|
+
Project: import('react').ForwardRefExoticComponent<BitkitPageSidebarProjectProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
72
|
+
Title: import('react').ForwardRefExoticComponent<BitkitPageSidebarTitleProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
73
|
+
};
|
|
74
|
+
export default _default;
|