alicia-design-system 1.112.1 → 1.112.2
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/cjs/alicia-ui/layout/Sidebar/SidebarBrand.d.ts +12 -0
- package/dist/cjs/alicia-ui/layout/Sidebar/SidebarBrand.js +121 -0
- package/dist/cjs/alicia-ui/layout/Sidebar/SidebarBrand.js.map +1 -0
- package/dist/cjs/alicia-ui/layout/Sidebar/SidebarBrand.types.d.ts +152 -0
- package/dist/cjs/alicia-ui/layout/Sidebar/SidebarBrand.types.js +3 -0
- package/dist/cjs/alicia-ui/layout/Sidebar/SidebarBrand.types.js.map +1 -0
- package/dist/cjs/brand/index.d.ts +2 -0
- package/dist/cjs/brand/index.js +3 -1
- package/dist/cjs/brand/index.js.map +1 -1
- package/dist/esm/alicia-ui/layout/Sidebar/SidebarBrand.d.ts +12 -0
- package/dist/esm/alicia-ui/layout/Sidebar/SidebarBrand.js +117 -0
- package/dist/esm/alicia-ui/layout/Sidebar/SidebarBrand.js.map +1 -0
- package/dist/esm/alicia-ui/layout/Sidebar/SidebarBrand.types.d.ts +152 -0
- package/dist/esm/alicia-ui/layout/Sidebar/SidebarBrand.types.js +2 -0
- package/dist/esm/alicia-ui/layout/Sidebar/SidebarBrand.types.js.map +1 -0
- package/dist/esm/brand/index.d.ts +2 -0
- package/dist/esm/brand/index.js +1 -0
- package/dist/esm/brand/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import type { SidebarBrandProps } from './SidebarBrand.types';
|
|
3
|
+
export type { SidebarBrandProps, SidebarItemStyleProps, SidebarLayout, SidebarLayoutValue, SidebarMenuItem, SidebarVisibility, } from './SidebarBrand.types';
|
|
4
|
+
/**
|
|
5
|
+
* Brand sidebar for the sales-funnel account nav.
|
|
6
|
+
*
|
|
7
|
+
* Renders one pill per row and, when a parent is open, its children.
|
|
8
|
+
* Defaults match the v3 self-service nav.
|
|
9
|
+
*
|
|
10
|
+
* Import via `alicia-design-system/brand`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Sidebar: FC<SidebarBrandProps>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Sidebar = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const polished_1 = require("polished");
|
|
7
|
+
const react_2 = require("react");
|
|
8
|
+
const brand_1 = require("../../icons/brand");
|
|
9
|
+
const ITEM_HEIGHT = 46.4;
|
|
10
|
+
const HORIZONTAL_ITEM_HEIGHT = 40;
|
|
11
|
+
const HORIZONTAL_ITEM_PADDING = 15.2;
|
|
12
|
+
const HORIZONTAL_GAP = 8;
|
|
13
|
+
const HORIZONTAL_PADDING_X = 16;
|
|
14
|
+
const HORIZONTAL_PADDING_Y = 12.8;
|
|
15
|
+
const VERTICAL_PADDING = 16;
|
|
16
|
+
const ICON_SIZE = 18;
|
|
17
|
+
const BADGE_SIZE = 22.4;
|
|
18
|
+
const ROW_GAP = 11.2;
|
|
19
|
+
const SUBMENU_INDENT = 16;
|
|
20
|
+
const TooltipPositioner = react_1.Tooltip.Positioner;
|
|
21
|
+
/**
|
|
22
|
+
* Brand nav pill.
|
|
23
|
+
*
|
|
24
|
+
* Idle fill is transparent, the label is `body.md` in `fg.brand`, and the
|
|
25
|
+
* outline is `border.input`. The active pill uses `accent.solid`, `accent.fg`,
|
|
26
|
+
* and weight 600. A labeled count sits at the end of the row in `brand.solid`
|
|
27
|
+
* with `caption`. An icons-only count sits on the top-right of the circle.
|
|
28
|
+
*/
|
|
29
|
+
const SidebarItem = ({ id, label, route, icon, count, isActive = false, hasSubMenu = false, isOpen = false, onClick, itemProps, labelProps, iconProps, badgeProps, visibility = 'full', horizontal = false, showTooltip = false, linkComponent, }) => {
|
|
30
|
+
const showLabel = horizontal || visibility === 'full';
|
|
31
|
+
const isLink = !hasSubMenu && !!route;
|
|
32
|
+
const content = ((0, jsx_runtime_1.jsxs)(react_1.Flex, Object.assign({ "data-testid": `sidebar-brand-item-${id}`, "data-active": isActive ? 'true' : 'false', as: isLink ? linkComponent !== null && linkComponent !== void 0 ? linkComponent : 'a' : 'button' }, (isLink
|
|
33
|
+
? linkComponent
|
|
34
|
+
? { to: route }
|
|
35
|
+
: { href: route }
|
|
36
|
+
: { type: 'button' }), { "aria-label": label }, (hasSubMenu && { 'aria-expanded': isOpen }), (visibility === 'iconsOnly' && !showTooltip && { title: label }), { alignItems: "center", justifyContent: showLabel ? 'space-between' : 'center', gap: showLabel ? (0, polished_1.rem)(8) : 0, w: horizontal ? 'auto' : showLabel ? '100%' : (0, polished_1.rem)(ITEM_HEIGHT), h: (0, polished_1.rem)(horizontal ? HORIZONTAL_ITEM_HEIGHT : ITEM_HEIGHT), px: horizontal ? (0, polished_1.rem)(HORIZONTAL_ITEM_PADDING) : showLabel ? (0, polished_1.rem)(16) : 0, flexShrink: 0, borderRadius: "full", borderWidth: (0, polished_1.rem)(1), borderStyle: "solid", borderColor: isActive ? 'accent.solid' : 'border.input', bg: isActive ? 'accent.solid' : 'transparent', color: isActive ? 'accent.fg' : 'fg.brand', textDecoration: "none", cursor: "pointer", textAlign: "left", appearance: "none" }, (!showLabel && { position: 'relative' }), { transition: "background 0.15s ease, border-color 0.15s ease, color 0.15s ease", _hover: {
|
|
37
|
+
bg: isActive ? 'accent.solid' : 'bg.subtle',
|
|
38
|
+
color: isActive ? 'accent.fg' : 'fg.brand',
|
|
39
|
+
borderColor: isActive ? 'accent.solid' : 'border.input',
|
|
40
|
+
textDecoration: 'none',
|
|
41
|
+
}, _focusVisible: { outline: 'none', boxShadow: 'focus' }, onClick: () => {
|
|
42
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(hasSubMenu ? id : route !== null && route !== void 0 ? route : id);
|
|
43
|
+
} }, itemProps, { children: [(0, jsx_runtime_1.jsxs)(react_1.Flex, { alignItems: "center", justifyContent: showLabel ? 'flex-start' : 'center', gap: showLabel ? (0, polished_1.rem)(12) : 0, minW: 0, children: [icon && !horizontal && ((0, jsx_runtime_1.jsx)(react_1.Box, Object.assign({ as: icon, boxSize: (0, polished_1.rem)(ICON_SIZE), color: isActive ? 'fg.brand' : 'fg.muted', flexShrink: 0, "aria-hidden": true }, iconProps))), showLabel && ((0, jsx_runtime_1.jsx)(react_1.Text, Object.assign({ textStyle: "body.md" }, (isActive && { fontWeight: '600' }), { truncate: true }, labelProps, { children: label })))] }), hasSubMenu && showLabel && !horizontal && (0, jsx_runtime_1.jsx)(brand_1.ChevronIcon, { open: isOpen }), count !== undefined && ((0, jsx_runtime_1.jsx)(react_1.Text, Object.assign({ as: "span", "data-testid": `sidebar-brand-badge-${id}`, flexShrink: 0, minW: (0, polished_1.rem)(BADGE_SIZE), h: (0, polished_1.rem)(BADGE_SIZE), px: (0, polished_1.rem)(6.4), borderRadius: "full", display: "flex", alignItems: "center", justifyContent: "center", bg: "brand.solid", color: "brand.fg", textStyle: "caption", fontWeight: "normal", pointerEvents: "none" }, (!showLabel && {
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
top: 0,
|
|
46
|
+
right: 0,
|
|
47
|
+
transform: 'translate(40%, -40%)',
|
|
48
|
+
}), badgeProps, { children: count })))] })));
|
|
49
|
+
if (!showTooltip || showLabel) {
|
|
50
|
+
return content;
|
|
51
|
+
}
|
|
52
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Tooltip.Root, { positioning: { placement: 'right' }, children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { asChild: true, children: content }), (0, jsx_runtime_1.jsx)(react_1.Portal, { children: (0, jsx_runtime_1.jsx)(TooltipPositioner, { children: (0, jsx_runtime_1.jsx)(react_1.Tooltip.Content, { bg: "bg.elevated", color: "fg.default", textStyle: "body.md", py: (0, polished_1.rem)(8), px: (0, polished_1.rem)(16), ml: (0, polished_1.rem)(8), rounded: "full", borderWidth: (0, polished_1.rem)(1), borderStyle: "solid", borderColor: "border.strong", children: label }) }) })] }));
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Brand sidebar for the sales-funnel account nav.
|
|
56
|
+
*
|
|
57
|
+
* Renders one pill per row and, when a parent is open, its children.
|
|
58
|
+
* Defaults match the v3 self-service nav.
|
|
59
|
+
*
|
|
60
|
+
* Import via `alicia-design-system/brand`.
|
|
61
|
+
*/
|
|
62
|
+
const Sidebar = ({ menu, activeRoute = '', onClick, rootProps, itemProps, labelProps, iconProps, badgeProps, visibility = 'full', showTooltip = false, linkComponent, layout = 'vertical', }) => {
|
|
63
|
+
var _a;
|
|
64
|
+
const [openParentId, setOpenParentId] = (0, react_2.useState)();
|
|
65
|
+
const layoutAtBreakpoint = (0, react_1.useBreakpointValue)(typeof layout === 'string' ? { base: layout } : layout);
|
|
66
|
+
const horizontal = ((_a = layoutAtBreakpoint !== null && layoutAtBreakpoint !== void 0 ? layoutAtBreakpoint : (typeof layout === 'string' ? layout : layout.base)) !== null && _a !== void 0 ? _a : 'vertical') === 'horizontal';
|
|
67
|
+
const childIsActive = (item) => { var _a, _b; return (_b = (_a = item.subMenu) === null || _a === void 0 ? void 0 : _a.some((child) => child.route === activeRoute)) !== null && _b !== void 0 ? _b : false; };
|
|
68
|
+
const renderItem = (item, options) => ((0, jsx_runtime_1.jsx)(SidebarItem, { id: item.id, label: item.label, route: item.route, icon: item.icon, count: item.count, itemProps: Object.assign(Object.assign({}, (options.indented &&
|
|
69
|
+
!horizontal &&
|
|
70
|
+
visibility === 'full' && {
|
|
71
|
+
ml: (0, polished_1.rem)(SUBMENU_INDENT),
|
|
72
|
+
w: 'auto',
|
|
73
|
+
})), itemProps), horizontal: horizontal, labelProps: labelProps, iconProps: iconProps, badgeProps: badgeProps, visibility: visibility, showTooltip: showTooltip, linkComponent: linkComponent, isActive: options.isActive, hasSubMenu: options.hasSubMenu, isOpen: options.isOpen, onClick: (value) => {
|
|
74
|
+
if (options.hasSubMenu) {
|
|
75
|
+
setOpenParentId((current) => current === item.id ? undefined : item.id);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (options.parentId) {
|
|
79
|
+
setOpenParentId(options.parentId);
|
|
80
|
+
}
|
|
81
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(value);
|
|
82
|
+
} }, item.id));
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Stack, Object.assign({ "data-testid": "sidebar-brand", "data-layout": "vertical", flexWrap: "nowrap", w: visibility === 'full' ? '100%' : 'fit-content', gap: (0, polished_1.rem)(ROW_GAP), px: (0, polished_1.rem)(VERTICAL_PADDING), py: (0, polished_1.rem)(VERTICAL_PADDING), borderRightWidth: (0, polished_1.rem)(1), borderRightStyle: "solid", borderRightColor: "border.divider" }, (horizontal && {
|
|
84
|
+
'data-layout': 'horizontal',
|
|
85
|
+
w: '100%',
|
|
86
|
+
gap: (0, polished_1.rem)(HORIZONTAL_GAP),
|
|
87
|
+
direction: 'row',
|
|
88
|
+
align: 'center',
|
|
89
|
+
px: (0, polished_1.rem)(HORIZONTAL_PADDING_X),
|
|
90
|
+
py: (0, polished_1.rem)(HORIZONTAL_PADDING_Y),
|
|
91
|
+
overflowX: 'auto',
|
|
92
|
+
borderRightWidth: 0,
|
|
93
|
+
borderBottomWidth: (0, polished_1.rem)(1),
|
|
94
|
+
borderBottomStyle: 'solid',
|
|
95
|
+
borderBottomColor: 'border.divider',
|
|
96
|
+
css: {
|
|
97
|
+
scrollbarWidth: 'none',
|
|
98
|
+
'&::-webkit-scrollbar': { display: 'none' },
|
|
99
|
+
},
|
|
100
|
+
}), rootProps, { children: menu.flatMap((item) => {
|
|
101
|
+
var _a;
|
|
102
|
+
const hasSubMenu = !!((_a = item.subMenu) === null || _a === void 0 ? void 0 : _a.length);
|
|
103
|
+
const isOpen = openParentId === item.id || childIsActive(item);
|
|
104
|
+
return [
|
|
105
|
+
renderItem(item, {
|
|
106
|
+
isActive: item.route === activeRoute || childIsActive(item),
|
|
107
|
+
hasSubMenu,
|
|
108
|
+
isOpen,
|
|
109
|
+
}),
|
|
110
|
+
...(hasSubMenu && isOpen && item.subMenu
|
|
111
|
+
? item.subMenu.map((child) => renderItem(child, {
|
|
112
|
+
isActive: child.route === activeRoute,
|
|
113
|
+
parentId: item.id,
|
|
114
|
+
indented: true,
|
|
115
|
+
}))
|
|
116
|
+
: []),
|
|
117
|
+
];
|
|
118
|
+
}) })));
|
|
119
|
+
};
|
|
120
|
+
exports.Sidebar = Sidebar;
|
|
121
|
+
//# sourceMappingURL=SidebarBrand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarBrand.js","sourceRoot":"","sources":["../../../../../src/alicia-ui/layout/Sidebar/SidebarBrand.tsx"],"names":[],"mappings":";;;;AAAA,4CAQ0B;AAC1B,uCAA+B;AAC/B,iCAA8D;AAC9D,6CAAgD;AAmBhD,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,iBAAiB,GACrB,eAAO,CAAC,UAAmD,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,CAAC,EACnB,EAAE,EACF,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,UAAU,GAAG,KAAK,E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
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the brand Sidebar.
|
|
3
|
+
* See SidebarBrand.tsx for implementation.
|
|
4
|
+
*/
|
|
5
|
+
import type { BoxProps, FlexProps, StackProps, TextProps, Tooltip } from '@chakra-ui/react';
|
|
6
|
+
import type { ComponentProps, ElementType, ReactNode } from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* One navigation row.
|
|
9
|
+
* Parents may include a single level of `subMenu`. Nested submenus are ignored.
|
|
10
|
+
*/
|
|
11
|
+
export type SidebarMenuItem = {
|
|
12
|
+
/** Stable id. Passed to `onClick` when the row has a submenu. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Visible label. */
|
|
15
|
+
label: string;
|
|
16
|
+
/** Route passed to `onClick` when the row has no submenu. */
|
|
17
|
+
route?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Icon component. Rendered at 18px. Idle uses `fg.muted`, active uses `fg.brand`.
|
|
20
|
+
* A component that bakes in its own fill will not follow those colors.
|
|
21
|
+
*/
|
|
22
|
+
icon?: ElementType;
|
|
23
|
+
/**
|
|
24
|
+
* Count badge. Hidden when this is omitted. `0` is shown.
|
|
25
|
+
* It sits at the end of a labeled row, and on the top-right of an icons-only circle.
|
|
26
|
+
*/
|
|
27
|
+
count?: number;
|
|
28
|
+
/** Child rows. One level only. */
|
|
29
|
+
subMenu?: SidebarMenuItem[];
|
|
30
|
+
};
|
|
31
|
+
/** Options passed when the sidebar renders one row, including an open child. */
|
|
32
|
+
export type SidebarItemRenderOptions = {
|
|
33
|
+
isActive: boolean;
|
|
34
|
+
hasSubMenu?: boolean;
|
|
35
|
+
isOpen?: boolean;
|
|
36
|
+
parentId?: string;
|
|
37
|
+
indented?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Chakra's positioner type omits `children`. Internal, so not exported from the brand index.
|
|
41
|
+
*/
|
|
42
|
+
export type TooltipPositionerProps = ComponentProps<typeof Tooltip.Positioner> & {
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
};
|
|
45
|
+
/** Props for one rendered row. Internal to the sidebar, so not exported from the brand index. */
|
|
46
|
+
export type SidebarItemProps = {
|
|
47
|
+
id: string;
|
|
48
|
+
label: string;
|
|
49
|
+
route?: string;
|
|
50
|
+
icon?: ElementType;
|
|
51
|
+
count?: number;
|
|
52
|
+
isActive?: boolean;
|
|
53
|
+
hasSubMenu?: boolean;
|
|
54
|
+
isOpen?: boolean;
|
|
55
|
+
onClick?: (value: string) => void;
|
|
56
|
+
itemProps?: FlexProps;
|
|
57
|
+
labelProps?: TextProps;
|
|
58
|
+
iconProps?: BoxProps;
|
|
59
|
+
badgeProps?: TextProps;
|
|
60
|
+
visibility?: SidebarVisibility;
|
|
61
|
+
horizontal?: boolean;
|
|
62
|
+
showTooltip?: boolean;
|
|
63
|
+
linkComponent?: ElementType;
|
|
64
|
+
};
|
|
65
|
+
/** `full` shows the label. `iconsOnly` shows the icon and an optional tooltip. */
|
|
66
|
+
export type SidebarVisibility = 'full' | 'iconsOnly';
|
|
67
|
+
/** `vertical` stacks the pills. `horizontal` lays them in a scrolling row. */
|
|
68
|
+
export type SidebarLayout = 'vertical' | 'horizontal';
|
|
69
|
+
/**
|
|
70
|
+
* A single layout, or a Chakra breakpoint map such as
|
|
71
|
+
* `{ base: 'horizontal', md: 'vertical' }`.
|
|
72
|
+
*/
|
|
73
|
+
export type SidebarLayoutValue = SidebarLayout | Partial<Record<'base' | 'sm' | 'md' | 'lg' | 'xl' | '2xl', SidebarLayout>>;
|
|
74
|
+
/**
|
|
75
|
+
* Slot overrides. Each slot is applied last and wins over the v3 defaults.
|
|
76
|
+
*/
|
|
77
|
+
export type SidebarItemStyleProps = {
|
|
78
|
+
/**
|
|
79
|
+
* Props spread onto the pill. Applied last.
|
|
80
|
+
*
|
|
81
|
+
* Defaults: idle transparent, `fg.brand`, `border.input`;
|
|
82
|
+
* hover `bg.subtle`; active `accent.solid` and `accent.fg`; height 2.9rem.
|
|
83
|
+
* @example itemProps={{ bg: 'brand.subtle', _hover: { bg: 'brand.subtleHover' } }}
|
|
84
|
+
*/
|
|
85
|
+
itemProps?: FlexProps;
|
|
86
|
+
/**
|
|
87
|
+
* Props spread onto the label. Applied last.
|
|
88
|
+
* Default text style is `body.md`, with weight 600 when the row is active.
|
|
89
|
+
* @example labelProps={{ textStyle: 'body.md.medium' }}
|
|
90
|
+
*/
|
|
91
|
+
labelProps?: TextProps;
|
|
92
|
+
/**
|
|
93
|
+
* Props spread onto the icon. Applied last.
|
|
94
|
+
* Default size is 18px. Idle color is `fg.muted`, active color is `fg.brand`.
|
|
95
|
+
* @example iconProps={{ boxSize: '16px' }}
|
|
96
|
+
*/
|
|
97
|
+
iconProps?: BoxProps;
|
|
98
|
+
/**
|
|
99
|
+
* Props spread onto the count badge. Applied last.
|
|
100
|
+
* Defaults: `brand.solid`, `brand.fg`, `caption` text style at normal weight, 1.4rem tall.
|
|
101
|
+
* Icons-only places this badge on the top-right of the circle.
|
|
102
|
+
* @example badgeProps={{ bg: 'accent.solid', color: 'accent.fg' }}
|
|
103
|
+
*/
|
|
104
|
+
badgeProps?: TextProps;
|
|
105
|
+
};
|
|
106
|
+
/** Vertical nav. Defaults match the v3 self-service pills. */
|
|
107
|
+
export type SidebarBrandProps = SidebarItemStyleProps & {
|
|
108
|
+
/** Top-level rows, in order. */
|
|
109
|
+
menu: SidebarMenuItem[];
|
|
110
|
+
/**
|
|
111
|
+
* Route of the selected row. A parent is selected when one of its children matches.
|
|
112
|
+
* @default ''
|
|
113
|
+
*/
|
|
114
|
+
activeRoute?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Called with the row route, or its id when it has a submenu or no route.
|
|
117
|
+
* Submenu parents toggle open instead of calling this.
|
|
118
|
+
*/
|
|
119
|
+
onClick?: (route: string) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Component used for a row that has a route and no submenu.
|
|
122
|
+
* Receives `to` set to that route, for example React Router's `Link`.
|
|
123
|
+
* Omit it and the row is an `<a href>`. A submenu parent stays a button.
|
|
124
|
+
*/
|
|
125
|
+
linkComponent?: ElementType;
|
|
126
|
+
/**
|
|
127
|
+
* `full` shows labels. `iconsOnly` shows icons in a 2.9rem circle, with a count on the top-right corner.
|
|
128
|
+
* @default 'full'
|
|
129
|
+
*/
|
|
130
|
+
visibility?: SidebarVisibility;
|
|
131
|
+
/**
|
|
132
|
+
* Shows a label tooltip when `visibility` is `iconsOnly`.
|
|
133
|
+
* The tooltip uses `bg.elevated`, `fg.default`, `border.strong`, and `body.md`.
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
showTooltip?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* `vertical` stacks the pills and draws a right border. `horizontal` is the
|
|
139
|
+
* mobile row: labels, no icons, its own padding and a bottom border. A breakpoint map is resolved
|
|
140
|
+
* with Chakra, for example `{ base: 'horizontal', md: 'vertical' }`.
|
|
141
|
+
* `iconsOnly` applies only when the resolved layout is `vertical`.
|
|
142
|
+
* @default 'vertical'
|
|
143
|
+
*/
|
|
144
|
+
layout?: SidebarLayoutValue;
|
|
145
|
+
/**
|
|
146
|
+
* Props spread onto the nav stack. Applied last.
|
|
147
|
+
* `gap` spaces every row, including open submenu items.
|
|
148
|
+
* The vertical default is 0.7rem. The horizontal default is 0.5rem.
|
|
149
|
+
* @example rootProps={{ pt: '1.5rem', gap: '1rem' }}
|
|
150
|
+
*/
|
|
151
|
+
rootProps?: StackProps;
|
|
152
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarBrand.types.js","sourceRoot":"","sources":["../../../../../src/alicia-ui/layout/Sidebar/SidebarBrand.types.ts"],"names":[],"mappings":""}
|
|
@@ -26,3 +26,5 @@ export { Search, boldedText } from '../alicia-ui/common/Search/SearchBrand';
|
|
|
26
26
|
export { SearchVariantEnum } from '../alicia-ui/common/Search/SearchBrand.types';
|
|
27
27
|
export type { SearchProps, BoldTextI, } from '../alicia-ui/common/Search/SearchBrand.types';
|
|
28
28
|
export { RadioButtonGroup } from '../alicia-ui/form/RadioButtonGroup/RadioButtonGroupBrand';
|
|
29
|
+
export { Sidebar } from '../alicia-ui/layout/Sidebar/SidebarBrand';
|
|
30
|
+
export type { SidebarBrandProps, SidebarItemStyleProps, SidebarLayout, SidebarLayoutValue, SidebarMenuItem, SidebarVisibility, } from '../alicia-ui/layout/Sidebar/SidebarBrand';
|
package/dist/cjs/brand/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* Add new revamped components here as they are updated.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.RadioButtonGroup = exports.SearchVariantEnum = exports.boldedText = exports.Search = exports.Header = exports.Button = exports.CustomListItem = exports.List = exports.brandTheme = exports.aliciaBrandThemeConfig = exports.aliciaThemeConfig = void 0;
|
|
19
|
+
exports.Sidebar = exports.RadioButtonGroup = exports.SearchVariantEnum = exports.boldedText = exports.Search = exports.Header = exports.Button = exports.CustomListItem = exports.List = exports.brandTheme = exports.aliciaBrandThemeConfig = exports.aliciaThemeConfig = void 0;
|
|
20
20
|
// ── Theme ─────────────────────────────────────────────────────────────────────
|
|
21
21
|
var chakraTheme_1 = require("../styles/chakraTheme");
|
|
22
22
|
Object.defineProperty(exports, "aliciaThemeConfig", { enumerable: true, get: function () { return chakraTheme_1.aliciaThemeConfig; } });
|
|
@@ -38,4 +38,6 @@ var SearchBrand_types_1 = require("../alicia-ui/common/Search/SearchBrand.types"
|
|
|
38
38
|
Object.defineProperty(exports, "SearchVariantEnum", { enumerable: true, get: function () { return SearchBrand_types_1.SearchVariantEnum; } });
|
|
39
39
|
var RadioButtonGroupBrand_1 = require("../alicia-ui/form/RadioButtonGroup/RadioButtonGroupBrand");
|
|
40
40
|
Object.defineProperty(exports, "RadioButtonGroup", { enumerable: true, get: function () { return RadioButtonGroupBrand_1.RadioButtonGroup; } });
|
|
41
|
+
var SidebarBrand_1 = require("../alicia-ui/layout/Sidebar/SidebarBrand");
|
|
42
|
+
Object.defineProperty(exports, "Sidebar", { enumerable: true, get: function () { return SidebarBrand_1.Sidebar; } });
|
|
41
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/brand/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,iFAAiF;AACjF,qDAA0D;AAAjD,gHAAA,iBAAiB,OAAA;AAC1B,iEAGqC;AAFnC,2HAAA,sBAAsB,OAAA;AACtB,+GAAA,UAAU,OAAA;AAGZ,iFAAiF;AACjF,gEAA0E;AAAjE,iGAAA,IAAI,OAAA;AAAE,2GAAA,cAAc,OAAA;AAM7B,uEAAiE;AAAxD,qGAAA,MAAM,OAAA;AAGf,sEAAgE;AAAvD,qGAAA,MAAM,OAAA;AAWf,sEAA4E;AAAnE,qGAAA,MAAM,OAAA;AAAE,yGAAA,UAAU,OAAA;AAC3B,kFAAiF;AAAxE,sHAAA,iBAAiB,OAAA;AAM1B,kGAA4F;AAAnF,yHAAA,gBAAgB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/brand/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,iFAAiF;AACjF,qDAA0D;AAAjD,gHAAA,iBAAiB,OAAA;AAC1B,iEAGqC;AAFnC,2HAAA,sBAAsB,OAAA;AACtB,+GAAA,UAAU,OAAA;AAGZ,iFAAiF;AACjF,gEAA0E;AAAjE,iGAAA,IAAI,OAAA;AAAE,2GAAA,cAAc,OAAA;AAM7B,uEAAiE;AAAxD,qGAAA,MAAM,OAAA;AAGf,sEAAgE;AAAvD,qGAAA,MAAM,OAAA;AAWf,sEAA4E;AAAnE,qGAAA,MAAM,OAAA;AAAE,yGAAA,UAAU,OAAA;AAC3B,kFAAiF;AAAxE,sHAAA,iBAAiB,OAAA;AAM1B,kGAA4F;AAAnF,yHAAA,gBAAgB,OAAA;AAEzB,yEAAmE;AAA1D,uGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import type { SidebarBrandProps } from './SidebarBrand.types';
|
|
3
|
+
export type { SidebarBrandProps, SidebarItemStyleProps, SidebarLayout, SidebarLayoutValue, SidebarMenuItem, SidebarVisibility, } from './SidebarBrand.types';
|
|
4
|
+
/**
|
|
5
|
+
* Brand sidebar for the sales-funnel account nav.
|
|
6
|
+
*
|
|
7
|
+
* Renders one pill per row and, when a parent is open, its children.
|
|
8
|
+
* Defaults match the v3 self-service nav.
|
|
9
|
+
*
|
|
10
|
+
* Import via `alicia-design-system/brand`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Sidebar: FC<SidebarBrandProps>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Flex, Portal, Stack, Text, Tooltip, useBreakpointValue, } from '@chakra-ui/react';
|
|
3
|
+
import { rem } from 'polished';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { ChevronIcon } from '../../icons/brand';
|
|
6
|
+
const ITEM_HEIGHT = 46.4;
|
|
7
|
+
const HORIZONTAL_ITEM_HEIGHT = 40;
|
|
8
|
+
const HORIZONTAL_ITEM_PADDING = 15.2;
|
|
9
|
+
const HORIZONTAL_GAP = 8;
|
|
10
|
+
const HORIZONTAL_PADDING_X = 16;
|
|
11
|
+
const HORIZONTAL_PADDING_Y = 12.8;
|
|
12
|
+
const VERTICAL_PADDING = 16;
|
|
13
|
+
const ICON_SIZE = 18;
|
|
14
|
+
const BADGE_SIZE = 22.4;
|
|
15
|
+
const ROW_GAP = 11.2;
|
|
16
|
+
const SUBMENU_INDENT = 16;
|
|
17
|
+
const TooltipPositioner = Tooltip.Positioner;
|
|
18
|
+
/**
|
|
19
|
+
* Brand nav pill.
|
|
20
|
+
*
|
|
21
|
+
* Idle fill is transparent, the label is `body.md` in `fg.brand`, and the
|
|
22
|
+
* outline is `border.input`. The active pill uses `accent.solid`, `accent.fg`,
|
|
23
|
+
* and weight 600. A labeled count sits at the end of the row in `brand.solid`
|
|
24
|
+
* with `caption`. An icons-only count sits on the top-right of the circle.
|
|
25
|
+
*/
|
|
26
|
+
const SidebarItem = ({ id, label, route, icon, count, isActive = false, hasSubMenu = false, isOpen = false, onClick, itemProps, labelProps, iconProps, badgeProps, visibility = 'full', horizontal = false, showTooltip = false, linkComponent, }) => {
|
|
27
|
+
const showLabel = horizontal || visibility === 'full';
|
|
28
|
+
const isLink = !hasSubMenu && !!route;
|
|
29
|
+
const content = (_jsxs(Flex, Object.assign({ "data-testid": `sidebar-brand-item-${id}`, "data-active": isActive ? 'true' : 'false', as: isLink ? linkComponent !== null && linkComponent !== void 0 ? linkComponent : 'a' : 'button' }, (isLink
|
|
30
|
+
? linkComponent
|
|
31
|
+
? { to: route }
|
|
32
|
+
: { href: route }
|
|
33
|
+
: { type: 'button' }), { "aria-label": label }, (hasSubMenu && { 'aria-expanded': isOpen }), (visibility === 'iconsOnly' && !showTooltip && { title: label }), { alignItems: "center", justifyContent: showLabel ? 'space-between' : 'center', gap: showLabel ? rem(8) : 0, w: horizontal ? 'auto' : showLabel ? '100%' : rem(ITEM_HEIGHT), h: rem(horizontal ? HORIZONTAL_ITEM_HEIGHT : ITEM_HEIGHT), px: horizontal ? rem(HORIZONTAL_ITEM_PADDING) : showLabel ? rem(16) : 0, flexShrink: 0, borderRadius: "full", borderWidth: rem(1), borderStyle: "solid", borderColor: isActive ? 'accent.solid' : 'border.input', bg: isActive ? 'accent.solid' : 'transparent', color: isActive ? 'accent.fg' : 'fg.brand', textDecoration: "none", cursor: "pointer", textAlign: "left", appearance: "none" }, (!showLabel && { position: 'relative' }), { transition: "background 0.15s ease, border-color 0.15s ease, color 0.15s ease", _hover: {
|
|
34
|
+
bg: isActive ? 'accent.solid' : 'bg.subtle',
|
|
35
|
+
color: isActive ? 'accent.fg' : 'fg.brand',
|
|
36
|
+
borderColor: isActive ? 'accent.solid' : 'border.input',
|
|
37
|
+
textDecoration: 'none',
|
|
38
|
+
}, _focusVisible: { outline: 'none', boxShadow: 'focus' }, onClick: () => {
|
|
39
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(hasSubMenu ? id : route !== null && route !== void 0 ? route : id);
|
|
40
|
+
} }, itemProps, { children: [_jsxs(Flex, { alignItems: "center", justifyContent: showLabel ? 'flex-start' : 'center', gap: showLabel ? rem(12) : 0, minW: 0, children: [icon && !horizontal && (_jsx(Box, Object.assign({ as: icon, boxSize: rem(ICON_SIZE), color: isActive ? 'fg.brand' : 'fg.muted', flexShrink: 0, "aria-hidden": true }, iconProps))), showLabel && (_jsx(Text, Object.assign({ textStyle: "body.md" }, (isActive && { fontWeight: '600' }), { truncate: true }, labelProps, { children: label })))] }), hasSubMenu && showLabel && !horizontal && _jsx(ChevronIcon, { open: isOpen }), count !== undefined && (_jsx(Text, Object.assign({ as: "span", "data-testid": `sidebar-brand-badge-${id}`, flexShrink: 0, minW: rem(BADGE_SIZE), h: rem(BADGE_SIZE), px: rem(6.4), borderRadius: "full", display: "flex", alignItems: "center", justifyContent: "center", bg: "brand.solid", color: "brand.fg", textStyle: "caption", fontWeight: "normal", pointerEvents: "none" }, (!showLabel && {
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: 0,
|
|
43
|
+
right: 0,
|
|
44
|
+
transform: 'translate(40%, -40%)',
|
|
45
|
+
}), badgeProps, { children: count })))] })));
|
|
46
|
+
if (!showTooltip || showLabel) {
|
|
47
|
+
return content;
|
|
48
|
+
}
|
|
49
|
+
return (_jsxs(Tooltip.Root, { positioning: { placement: 'right' }, children: [_jsx(Tooltip.Trigger, { asChild: true, children: content }), _jsx(Portal, { children: _jsx(TooltipPositioner, { children: _jsx(Tooltip.Content, { bg: "bg.elevated", color: "fg.default", textStyle: "body.md", py: rem(8), px: rem(16), ml: rem(8), rounded: "full", borderWidth: rem(1), borderStyle: "solid", borderColor: "border.strong", children: label }) }) })] }));
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Brand sidebar for the sales-funnel account nav.
|
|
53
|
+
*
|
|
54
|
+
* Renders one pill per row and, when a parent is open, its children.
|
|
55
|
+
* Defaults match the v3 self-service nav.
|
|
56
|
+
*
|
|
57
|
+
* Import via `alicia-design-system/brand`.
|
|
58
|
+
*/
|
|
59
|
+
export const Sidebar = ({ menu, activeRoute = '', onClick, rootProps, itemProps, labelProps, iconProps, badgeProps, visibility = 'full', showTooltip = false, linkComponent, layout = 'vertical', }) => {
|
|
60
|
+
var _a;
|
|
61
|
+
const [openParentId, setOpenParentId] = useState();
|
|
62
|
+
const layoutAtBreakpoint = useBreakpointValue(typeof layout === 'string' ? { base: layout } : layout);
|
|
63
|
+
const horizontal = ((_a = layoutAtBreakpoint !== null && layoutAtBreakpoint !== void 0 ? layoutAtBreakpoint : (typeof layout === 'string' ? layout : layout.base)) !== null && _a !== void 0 ? _a : 'vertical') === 'horizontal';
|
|
64
|
+
const childIsActive = (item) => { var _a, _b; return (_b = (_a = item.subMenu) === null || _a === void 0 ? void 0 : _a.some((child) => child.route === activeRoute)) !== null && _b !== void 0 ? _b : false; };
|
|
65
|
+
const renderItem = (item, options) => (_jsx(SidebarItem, { id: item.id, label: item.label, route: item.route, icon: item.icon, count: item.count, itemProps: Object.assign(Object.assign({}, (options.indented &&
|
|
66
|
+
!horizontal &&
|
|
67
|
+
visibility === 'full' && {
|
|
68
|
+
ml: rem(SUBMENU_INDENT),
|
|
69
|
+
w: 'auto',
|
|
70
|
+
})), itemProps), horizontal: horizontal, labelProps: labelProps, iconProps: iconProps, badgeProps: badgeProps, visibility: visibility, showTooltip: showTooltip, linkComponent: linkComponent, isActive: options.isActive, hasSubMenu: options.hasSubMenu, isOpen: options.isOpen, onClick: (value) => {
|
|
71
|
+
if (options.hasSubMenu) {
|
|
72
|
+
setOpenParentId((current) => current === item.id ? undefined : item.id);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (options.parentId) {
|
|
76
|
+
setOpenParentId(options.parentId);
|
|
77
|
+
}
|
|
78
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(value);
|
|
79
|
+
} }, item.id));
|
|
80
|
+
return (_jsx(Stack, Object.assign({ "data-testid": "sidebar-brand", "data-layout": "vertical", flexWrap: "nowrap", w: visibility === 'full' ? '100%' : 'fit-content', gap: rem(ROW_GAP), px: rem(VERTICAL_PADDING), py: rem(VERTICAL_PADDING), borderRightWidth: rem(1), borderRightStyle: "solid", borderRightColor: "border.divider" }, (horizontal && {
|
|
81
|
+
'data-layout': 'horizontal',
|
|
82
|
+
w: '100%',
|
|
83
|
+
gap: rem(HORIZONTAL_GAP),
|
|
84
|
+
direction: 'row',
|
|
85
|
+
align: 'center',
|
|
86
|
+
px: rem(HORIZONTAL_PADDING_X),
|
|
87
|
+
py: rem(HORIZONTAL_PADDING_Y),
|
|
88
|
+
overflowX: 'auto',
|
|
89
|
+
borderRightWidth: 0,
|
|
90
|
+
borderBottomWidth: rem(1),
|
|
91
|
+
borderBottomStyle: 'solid',
|
|
92
|
+
borderBottomColor: 'border.divider',
|
|
93
|
+
css: {
|
|
94
|
+
scrollbarWidth: 'none',
|
|
95
|
+
'&::-webkit-scrollbar': { display: 'none' },
|
|
96
|
+
},
|
|
97
|
+
}), rootProps, { children: menu.flatMap((item) => {
|
|
98
|
+
var _a;
|
|
99
|
+
const hasSubMenu = !!((_a = item.subMenu) === null || _a === void 0 ? void 0 : _a.length);
|
|
100
|
+
const isOpen = openParentId === item.id || childIsActive(item);
|
|
101
|
+
return [
|
|
102
|
+
renderItem(item, {
|
|
103
|
+
isActive: item.route === activeRoute || childIsActive(item),
|
|
104
|
+
hasSubMenu,
|
|
105
|
+
isOpen,
|
|
106
|
+
}),
|
|
107
|
+
...(hasSubMenu && isOpen && item.subMenu
|
|
108
|
+
? item.subMenu.map((child) => renderItem(child, {
|
|
109
|
+
isActive: child.route === activeRoute,
|
|
110
|
+
parentId: item.id,
|
|
111
|
+
indented: true,
|
|
112
|
+
}))
|
|
113
|
+
: []),
|
|
114
|
+
];
|
|
115
|
+
}) })));
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=SidebarBrand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarBrand.js","sourceRoot":"","sources":["../../../../../src/alicia-ui/layout/Sidebar/SidebarBrand.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,MAAM,EACN,KAAK,EACL,IAAI,EACJ,OAAO,EACP,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAA+B,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmBhD,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,iBAAiB,GACrB,OAAO,CAAC,UAAmD,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,CAAC,EACnB,EAAE,EACF,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,UAAU,GAAG,KAAK,EAClB,MAAM,GAAG,KA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AAG,CAAC,CAAC,CAAC;QACzB,iBAAiB,EAAE,OAAO;QAC1B,iBAAiB,EAAE,gBAAgB;QACnC,GAAG,EAAE;YACH,cAAc,EAAE,MAAM;YACtB,sBAAsB,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;SAC5C;KACF,CAAC,EACE,SAAS,cAEZ,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;YACrB,MAAM,UAAU,GAAG,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAA,CAAC;YAC1C,MAAM,MAAM,GAAG,YAAY,KAAK,IAAI,CAAC,EAAE,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;YAE/D,OAAO;gBACL,UAAU,CAAC,IAAI,EAAE;oBACf,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,WAAW,IAAI,aAAa,CAAC,IAAI,CAAC;oBAC3D,UAAU;oBACV,MAAM;iBACP,CAAC;gBACF,GAAG,CAAC,UAAU,IAAI,MAAM,IAAI,IAAI,CAAC,OAAO;oBACtC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACzB,UAAU,CAAC,KAAK,EAAE;wBAChB,QAAQ,EAAE,KAAK,CAAC,KAAK,KAAK,WAAW;wBACrC,QAAQ,EAAE,IAAI,CAAC,EAAE;wBACjB,QAAQ,EAAE,IAAI;qBACf,CAAC,CACH;oBACH,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;QACJ,CAAC,CAAC,IACI,CACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the brand Sidebar.
|
|
3
|
+
* See SidebarBrand.tsx for implementation.
|
|
4
|
+
*/
|
|
5
|
+
import type { BoxProps, FlexProps, StackProps, TextProps, Tooltip } from '@chakra-ui/react';
|
|
6
|
+
import type { ComponentProps, ElementType, ReactNode } from 'react';
|
|
7
|
+
/**
|
|
8
|
+
* One navigation row.
|
|
9
|
+
* Parents may include a single level of `subMenu`. Nested submenus are ignored.
|
|
10
|
+
*/
|
|
11
|
+
export type SidebarMenuItem = {
|
|
12
|
+
/** Stable id. Passed to `onClick` when the row has a submenu. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Visible label. */
|
|
15
|
+
label: string;
|
|
16
|
+
/** Route passed to `onClick` when the row has no submenu. */
|
|
17
|
+
route?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Icon component. Rendered at 18px. Idle uses `fg.muted`, active uses `fg.brand`.
|
|
20
|
+
* A component that bakes in its own fill will not follow those colors.
|
|
21
|
+
*/
|
|
22
|
+
icon?: ElementType;
|
|
23
|
+
/**
|
|
24
|
+
* Count badge. Hidden when this is omitted. `0` is shown.
|
|
25
|
+
* It sits at the end of a labeled row, and on the top-right of an icons-only circle.
|
|
26
|
+
*/
|
|
27
|
+
count?: number;
|
|
28
|
+
/** Child rows. One level only. */
|
|
29
|
+
subMenu?: SidebarMenuItem[];
|
|
30
|
+
};
|
|
31
|
+
/** Options passed when the sidebar renders one row, including an open child. */
|
|
32
|
+
export type SidebarItemRenderOptions = {
|
|
33
|
+
isActive: boolean;
|
|
34
|
+
hasSubMenu?: boolean;
|
|
35
|
+
isOpen?: boolean;
|
|
36
|
+
parentId?: string;
|
|
37
|
+
indented?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Chakra's positioner type omits `children`. Internal, so not exported from the brand index.
|
|
41
|
+
*/
|
|
42
|
+
export type TooltipPositionerProps = ComponentProps<typeof Tooltip.Positioner> & {
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
};
|
|
45
|
+
/** Props for one rendered row. Internal to the sidebar, so not exported from the brand index. */
|
|
46
|
+
export type SidebarItemProps = {
|
|
47
|
+
id: string;
|
|
48
|
+
label: string;
|
|
49
|
+
route?: string;
|
|
50
|
+
icon?: ElementType;
|
|
51
|
+
count?: number;
|
|
52
|
+
isActive?: boolean;
|
|
53
|
+
hasSubMenu?: boolean;
|
|
54
|
+
isOpen?: boolean;
|
|
55
|
+
onClick?: (value: string) => void;
|
|
56
|
+
itemProps?: FlexProps;
|
|
57
|
+
labelProps?: TextProps;
|
|
58
|
+
iconProps?: BoxProps;
|
|
59
|
+
badgeProps?: TextProps;
|
|
60
|
+
visibility?: SidebarVisibility;
|
|
61
|
+
horizontal?: boolean;
|
|
62
|
+
showTooltip?: boolean;
|
|
63
|
+
linkComponent?: ElementType;
|
|
64
|
+
};
|
|
65
|
+
/** `full` shows the label. `iconsOnly` shows the icon and an optional tooltip. */
|
|
66
|
+
export type SidebarVisibility = 'full' | 'iconsOnly';
|
|
67
|
+
/** `vertical` stacks the pills. `horizontal` lays them in a scrolling row. */
|
|
68
|
+
export type SidebarLayout = 'vertical' | 'horizontal';
|
|
69
|
+
/**
|
|
70
|
+
* A single layout, or a Chakra breakpoint map such as
|
|
71
|
+
* `{ base: 'horizontal', md: 'vertical' }`.
|
|
72
|
+
*/
|
|
73
|
+
export type SidebarLayoutValue = SidebarLayout | Partial<Record<'base' | 'sm' | 'md' | 'lg' | 'xl' | '2xl', SidebarLayout>>;
|
|
74
|
+
/**
|
|
75
|
+
* Slot overrides. Each slot is applied last and wins over the v3 defaults.
|
|
76
|
+
*/
|
|
77
|
+
export type SidebarItemStyleProps = {
|
|
78
|
+
/**
|
|
79
|
+
* Props spread onto the pill. Applied last.
|
|
80
|
+
*
|
|
81
|
+
* Defaults: idle transparent, `fg.brand`, `border.input`;
|
|
82
|
+
* hover `bg.subtle`; active `accent.solid` and `accent.fg`; height 2.9rem.
|
|
83
|
+
* @example itemProps={{ bg: 'brand.subtle', _hover: { bg: 'brand.subtleHover' } }}
|
|
84
|
+
*/
|
|
85
|
+
itemProps?: FlexProps;
|
|
86
|
+
/**
|
|
87
|
+
* Props spread onto the label. Applied last.
|
|
88
|
+
* Default text style is `body.md`, with weight 600 when the row is active.
|
|
89
|
+
* @example labelProps={{ textStyle: 'body.md.medium' }}
|
|
90
|
+
*/
|
|
91
|
+
labelProps?: TextProps;
|
|
92
|
+
/**
|
|
93
|
+
* Props spread onto the icon. Applied last.
|
|
94
|
+
* Default size is 18px. Idle color is `fg.muted`, active color is `fg.brand`.
|
|
95
|
+
* @example iconProps={{ boxSize: '16px' }}
|
|
96
|
+
*/
|
|
97
|
+
iconProps?: BoxProps;
|
|
98
|
+
/**
|
|
99
|
+
* Props spread onto the count badge. Applied last.
|
|
100
|
+
* Defaults: `brand.solid`, `brand.fg`, `caption` text style at normal weight, 1.4rem tall.
|
|
101
|
+
* Icons-only places this badge on the top-right of the circle.
|
|
102
|
+
* @example badgeProps={{ bg: 'accent.solid', color: 'accent.fg' }}
|
|
103
|
+
*/
|
|
104
|
+
badgeProps?: TextProps;
|
|
105
|
+
};
|
|
106
|
+
/** Vertical nav. Defaults match the v3 self-service pills. */
|
|
107
|
+
export type SidebarBrandProps = SidebarItemStyleProps & {
|
|
108
|
+
/** Top-level rows, in order. */
|
|
109
|
+
menu: SidebarMenuItem[];
|
|
110
|
+
/**
|
|
111
|
+
* Route of the selected row. A parent is selected when one of its children matches.
|
|
112
|
+
* @default ''
|
|
113
|
+
*/
|
|
114
|
+
activeRoute?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Called with the row route, or its id when it has a submenu or no route.
|
|
117
|
+
* Submenu parents toggle open instead of calling this.
|
|
118
|
+
*/
|
|
119
|
+
onClick?: (route: string) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Component used for a row that has a route and no submenu.
|
|
122
|
+
* Receives `to` set to that route, for example React Router's `Link`.
|
|
123
|
+
* Omit it and the row is an `<a href>`. A submenu parent stays a button.
|
|
124
|
+
*/
|
|
125
|
+
linkComponent?: ElementType;
|
|
126
|
+
/**
|
|
127
|
+
* `full` shows labels. `iconsOnly` shows icons in a 2.9rem circle, with a count on the top-right corner.
|
|
128
|
+
* @default 'full'
|
|
129
|
+
*/
|
|
130
|
+
visibility?: SidebarVisibility;
|
|
131
|
+
/**
|
|
132
|
+
* Shows a label tooltip when `visibility` is `iconsOnly`.
|
|
133
|
+
* The tooltip uses `bg.elevated`, `fg.default`, `border.strong`, and `body.md`.
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
showTooltip?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* `vertical` stacks the pills and draws a right border. `horizontal` is the
|
|
139
|
+
* mobile row: labels, no icons, its own padding and a bottom border. A breakpoint map is resolved
|
|
140
|
+
* with Chakra, for example `{ base: 'horizontal', md: 'vertical' }`.
|
|
141
|
+
* `iconsOnly` applies only when the resolved layout is `vertical`.
|
|
142
|
+
* @default 'vertical'
|
|
143
|
+
*/
|
|
144
|
+
layout?: SidebarLayoutValue;
|
|
145
|
+
/**
|
|
146
|
+
* Props spread onto the nav stack. Applied last.
|
|
147
|
+
* `gap` spaces every row, including open submenu items.
|
|
148
|
+
* The vertical default is 0.7rem. The horizontal default is 0.5rem.
|
|
149
|
+
* @example rootProps={{ pt: '1.5rem', gap: '1rem' }}
|
|
150
|
+
*/
|
|
151
|
+
rootProps?: StackProps;
|
|
152
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarBrand.types.js","sourceRoot":"","sources":["../../../../../src/alicia-ui/layout/Sidebar/SidebarBrand.types.ts"],"names":[],"mappings":""}
|
|
@@ -26,3 +26,5 @@ export { Search, boldedText } from '../alicia-ui/common/Search/SearchBrand';
|
|
|
26
26
|
export { SearchVariantEnum } from '../alicia-ui/common/Search/SearchBrand.types';
|
|
27
27
|
export type { SearchProps, BoldTextI, } from '../alicia-ui/common/Search/SearchBrand.types';
|
|
28
28
|
export { RadioButtonGroup } from '../alicia-ui/form/RadioButtonGroup/RadioButtonGroupBrand';
|
|
29
|
+
export { Sidebar } from '../alicia-ui/layout/Sidebar/SidebarBrand';
|
|
30
|
+
export type { SidebarBrandProps, SidebarItemStyleProps, SidebarLayout, SidebarLayoutValue, SidebarMenuItem, SidebarVisibility, } from '../alicia-ui/layout/Sidebar/SidebarBrand';
|
package/dist/esm/brand/index.js
CHANGED
|
@@ -24,4 +24,5 @@ export { Header } from '../alicia-ui/layout/Header/HeaderBrand';
|
|
|
24
24
|
export { Search, boldedText } from '../alicia-ui/common/Search/SearchBrand';
|
|
25
25
|
export { SearchVariantEnum } from '../alicia-ui/common/Search/SearchBrand.types';
|
|
26
26
|
export { RadioButtonGroup } from '../alicia-ui/form/RadioButtonGroup/RadioButtonGroupBrand';
|
|
27
|
+
export { Sidebar } from '../alicia-ui/layout/Sidebar/SidebarBrand';
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/brand/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iFAAiF;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,UAAU,GACX,MAAM,6BAA6B,CAAC;AAErC,iFAAiF;AACjF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAM1E,OAAO,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAWhE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AAMjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/brand/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iFAAiF;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,UAAU,GACX,MAAM,6BAA6B,CAAC;AAErC,iFAAiF;AACjF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAM1E,OAAO,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAWhE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AAMjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AAE5F,OAAO,EAAE,OAAO,EAAE,MAAM,0CAA0C,CAAC"}
|