@ssa-ui-kit/core 3.24.0 → 3.25.0

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.
@@ -0,0 +1,129 @@
1
+ import { AriaAttributes, MouseEventHandler, ReactNode } from 'react';
2
+ import { ColorsKeys } from '../../types/emotion';
3
+ import { IconProps } from '../Icon/types';
4
+ /**
5
+ * Size scale of a {@link FloatingActionButton}. Icon-only and labelled FABs
6
+ * share one height per size: 32 / 36 / 40 / 44px.
7
+ */
8
+ export type FloatingActionButtonSize = 'extraSmall' | 'small' | 'medium' | 'large';
9
+ /**
10
+ * Corner of the viewport the {@link FloatingActionButton} is fixed to.
11
+ */
12
+ export type FloatingActionButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
13
+ /**
14
+ * Background color of a {@link FloatingActionButton}.
15
+ * - `primary`: theme blue with a white icon (design default)
16
+ * - `secondary`: light grey with a dark icon
17
+ * - any theme color key (e.g. `'green'`) or CSS color string — the icon and
18
+ * label color is picked automatically for contrast
19
+ */
20
+ export type FloatingActionButtonColor = 'primary' | 'secondary' | ColorsKeys | (string & {});
21
+ /**
22
+ * Icon of a FAB or of a menu action: a kit icon name, sized and colored by
23
+ * the FAB, or any node — which then brings its own size and color.
24
+ */
25
+ export type FloatingActionButtonIcon = IconProps['name'] | ReactNode;
26
+ /**
27
+ * A single item of a {@link FloatingActionButton} menu.
28
+ */
29
+ export type FloatingActionButtonAction = {
30
+ /** Stable key for the item. */
31
+ id: string;
32
+ /** Icon of the item. */
33
+ icon: FloatingActionButtonIcon;
34
+ /**
35
+ * Text of the item. Always its accessible name; shown next to the icon
36
+ * unless `showActionLabels` is `false`.
37
+ */
38
+ label: string;
39
+ /** Called when the item is chosen. The menu then closes. */
40
+ onClick: () => void;
41
+ /** Disables the item. */
42
+ disabled?: boolean;
43
+ };
44
+ /**
45
+ * Props of the {@link FloatingActionButton} component.
46
+ */
47
+ export type FloatingActionButtonProps = Pick<AriaAttributes, 'aria-label' | 'aria-describedby'> & {
48
+ /**
49
+ * Icon of the button (of the menu trigger while the menu is closed).
50
+ * @default 'plus'
51
+ */
52
+ icon?: FloatingActionButtonIcon;
53
+ /**
54
+ * Text shown next to the icon (the "extended" FAB). Without it the FAB is
55
+ * icon-only and needs an `aria-label`.
56
+ */
57
+ label?: string;
58
+ /**
59
+ * Background color. Pre-defined `primary` / `secondary`, a theme color key
60
+ * or any CSS color; custom colors get an auto-contrast icon and label.
61
+ * @default 'primary'
62
+ */
63
+ color?: FloatingActionButtonColor;
64
+ /**
65
+ * Draws the elevation shadow under the button.
66
+ * @default true
67
+ */
68
+ shadow?: boolean;
69
+ /**
70
+ * Corner shape: `square` keeps the 8px radius, `round` is fully rounded
71
+ * (a circle when icon-only, a pill when labelled).
72
+ * @default 'square'
73
+ */
74
+ shape?: 'square' | 'round';
75
+ /**
76
+ * Size of the button and of its menu items.
77
+ * @default 'medium'
78
+ */
79
+ size?: FloatingActionButtonSize;
80
+ /**
81
+ * Disables the button (and, in menu mode, opening the menu).
82
+ * @default false
83
+ */
84
+ disabled?: boolean;
85
+ /**
86
+ * Click handler. In menu mode it also runs, before the menu toggles.
87
+ */
88
+ onClick?: MouseEventHandler<HTMLButtonElement>;
89
+ /**
90
+ * Items of the speed-dial menu. When given, the button toggles a stack of
91
+ * secondary FABs above it (below it for `top-*` positions).
92
+ */
93
+ actions?: FloatingActionButtonAction[];
94
+ /**
95
+ * Shows each action's `label` next to its icon. When `false` the items are
96
+ * icon-only and the label stays as their accessible name.
97
+ * @default true
98
+ */
99
+ showActionLabels?: boolean;
100
+ /** Controlled open state of the menu. */
101
+ open?: boolean;
102
+ /**
103
+ * Initial open state of the menu when uncontrolled.
104
+ * @default false
105
+ */
106
+ defaultOpen?: boolean;
107
+ /** Called when the menu opens or closes. */
108
+ onOpenChange?: (open: boolean) => void;
109
+ /**
110
+ * Icon of the trigger while the menu is open.
111
+ * @default 'cross'
112
+ */
113
+ openIcon?: FloatingActionButtonIcon;
114
+ /**
115
+ * Viewport corner the FAB is fixed to.
116
+ * @default 'bottom-right'
117
+ */
118
+ position?: FloatingActionButtonPosition;
119
+ /**
120
+ * Distance from the corner in px — one value for both axes, or `{ x, y }`.
121
+ * @default 24
122
+ */
123
+ offset?: number | {
124
+ x: number;
125
+ y: number;
126
+ };
127
+ /** Class name of the fixed container. */
128
+ className?: string;
129
+ };
@@ -0,0 +1,43 @@
1
+ import { HeaderProps } from './types';
2
+ /**
3
+ * Header - The application's top bar: logo, main navigation and a free slot
4
+ * on the right for the user profile, notifications or log out.
5
+ *
6
+ * ### Navigation
7
+ * `items` render as react-router links, so the Header must sit inside a
8
+ * router. The item matching the current location is highlighted, and so is
9
+ * every group above it. Groups open a dropdown — on hover with a mouse, on
10
+ * tap on touch screens — and a dropdown item can open a flyout one level
11
+ * further. Following a link closes them.
12
+ *
13
+ * ### Layout
14
+ * From 900px the navigation is centred between the logo and the right side,
15
+ * and scrolls sideways when it does not fit. Below 900px it moves into a
16
+ * drawer opened by a burger button, the logo is centred and `rightSide`
17
+ * stays as it is.
18
+ *
19
+ * ### Selected state
20
+ * The design sets the selected item in bold. The kit marks it by color
21
+ * only: a heavier face widens the item and shifts the whole bar whenever the
22
+ * route changes.
23
+ *
24
+ * @category Navigation
25
+ * @example
26
+ * ```tsx
27
+ * <Header
28
+ * logo={<img src="/logo.svg" alt="Acme" height={38} />}
29
+ * items={[
30
+ * { id: 'home', label: 'Home', path: '/' },
31
+ * {
32
+ * id: 'people',
33
+ * label: 'People',
34
+ * children: [
35
+ * { id: 'employees', label: 'Employees', path: '/people/employees' },
36
+ * ],
37
+ * },
38
+ * ]}
39
+ * rightSide={<UserProfile {...profile} />}
40
+ * />
41
+ * ```
42
+ */
43
+ export declare const Header: import("react").ForwardRefExoticComponent<HeaderProps & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,18 @@
1
+ import { UseDrawerStore } from '../Drawer/useDrawer';
2
+ import { HeaderNavItem, HeaderTheme } from './types';
3
+ import * as S from './styles';
4
+ interface HeaderMobileMenuProps {
5
+ store: UseDrawerStore;
6
+ items: HeaderNavItem[];
7
+ headerTheme: HeaderTheme;
8
+ palette: S.HeaderPalette;
9
+ pathname: string;
10
+ navLabel: string;
11
+ }
12
+ /**
13
+ * The navigation below 900px: a full-width drawer holding a `TreeView`, the
14
+ * same engine as CollapsibleNavBar's menu. The tree owns expansion and opens
15
+ * the group holding the current page; this module owns the routing.
16
+ */
17
+ export declare const HeaderMobileMenu: ({ store, items, headerTheme, palette, pathname, navLabel, }: HeaderMobileMenuProps) => import("@emotion/react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -0,0 +1,17 @@
1
+ import { HeaderNavItem } from './types';
2
+ import * as S from './styles';
3
+ interface NavEntryProps {
4
+ item: HeaderNavItem;
5
+ /** 0 — the bar itself, 1 — dropdown, 2 — flyout */
6
+ depth: number;
7
+ palette: S.HeaderPalette;
8
+ pathname: string;
9
+ /** Closes every menu above this one once a link is followed */
10
+ onNavigate?: () => void;
11
+ }
12
+ /**
13
+ * Top-level entry. Each group roots its own floating tree, so a flyout's
14
+ * hover and dismiss events reach the dropdown that opened it.
15
+ */
16
+ export declare const HeaderNavEntry: (props: NavEntryProps) => import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,13 @@
1
+ import { HeaderNavItem } from './types';
2
+ /** Submenus nest this deep at most: top level → dropdown → flyout. */
3
+ export declare const MAX_DEPTH = 2;
4
+ /**
5
+ * Same rule as react-router's `NavLink` without `end`: the path itself or
6
+ * anything below it, matched on whole segments — `/people` covers
7
+ * `/people/42` but not `/peoples`. `/` only matches itself, as with NavLink.
8
+ */
9
+ export declare const isPathActive: (pathname: string, path: string) => boolean;
10
+ /** Leaf: its own path. Group: any descendant up to `MAX_DEPTH`. */
11
+ export declare const isItemActive: (item: HeaderNavItem, pathname: string, depth?: number) => boolean;
12
+ export declare const hasSubmenu: (item: HeaderNavItem, depth: number) => boolean;
13
+ export declare const renderItemIcon: (icon: HeaderNavItem["icon"], size: number) => import("@emotion/react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export * from './Header';
@@ -0,0 +1,63 @@
1
+ import { Theme } from '@emotion/react';
2
+ import { HeaderSize, HeaderTheme } from './types';
3
+ export declare const SIZES: Record<HeaderSize, {
4
+ height: number;
5
+ logo: number;
6
+ }>;
7
+ export declare const MENU_WIDTH = 164;
8
+ /** Design: dropdowns sit 6px below their trigger and flyouts 6px aside. */
9
+ export declare const MENU_OFFSET = 6;
10
+ export declare const resolvePalette: (theme: Theme, headerTheme: HeaderTheme) => {
11
+ background: string;
12
+ text: `rgb${string}` | undefined;
13
+ accent: `rgb${string}` | undefined;
14
+ disabled: `rgb${string}` | undefined;
15
+ menuBackground: `rgb${string}` | undefined;
16
+ menuItem: `rgb${string}` | undefined;
17
+ menuItemHover: `rgb${string}` | undefined;
18
+ menuItemOpen: `rgb${string}` | undefined;
19
+ menuText: `rgb${string}` | undefined;
20
+ menuDisabled: `rgb${string}` | undefined;
21
+ drawerBackground: `rgb${string}` | undefined;
22
+ } | {
23
+ background: `rgb${string}` | undefined;
24
+ text: `rgb${string}` | undefined;
25
+ accent: `rgb${string}` | "transparent";
26
+ disabled: `rgb${string}` | undefined;
27
+ menuBackground: `rgb${string}` | undefined;
28
+ menuItem: `rgb${string}` | undefined;
29
+ menuItemHover: `rgb${string}` | undefined;
30
+ menuItemOpen: `rgb${string}` | undefined;
31
+ menuText: `rgb${string}` | undefined;
32
+ menuDisabled: `rgb${string}` | undefined;
33
+ drawerBackground: `rgb${string}` | "transparent";
34
+ };
35
+ export type HeaderPalette = ReturnType<typeof resolvePalette>;
36
+ export declare const root: (theme: Theme, palette: HeaderPalette, size: HeaderSize) => import("@emotion/react").SerializedStyles;
37
+ export declare const burger: (theme: Theme, palette: HeaderPalette) => import("@emotion/react").SerializedStyles;
38
+ /** Holds the burger's column when there is no menu, so the logo stays centred. */
39
+ export declare const burgerPlaceholder: (theme: Theme) => import("@emotion/react").SerializedStyles;
40
+ /**
41
+ * Fixed height from the size; width follows the logo so wordmarks fit, but
42
+ * never drops below a square, so an empty box still holds its place.
43
+ */
44
+ export declare const logo: (size: HeaderSize) => import("@emotion/react").SerializedStyles;
45
+ /**
46
+ * The scroll container. Dropdowns are portalled, so the overflow here does
47
+ * not clip them.
48
+ */
49
+ export declare const nav: (theme: Theme) => import("@emotion/react").SerializedStyles;
50
+ /** `margin: auto` centres the list while it fits and lets it scroll after. */
51
+ export declare const navList: import("@emotion/react").SerializedStyles;
52
+ export declare const rightSide: import("@emotion/react").SerializedStyles;
53
+ /**
54
+ * Selected keeps the regular weight: the design's bold resizes the item and
55
+ * shifts the whole bar as the route changes, so the state is marked by color
56
+ * alone.
57
+ */
58
+ export declare const navItem: (theme: Theme, palette: HeaderPalette, active: boolean) => import("@emotion/react").SerializedStyles;
59
+ export declare const menu: (theme: Theme, palette: HeaderPalette) => import("@emotion/react").SerializedStyles;
60
+ export declare const menuItem: (theme: Theme, palette: HeaderPalette, active: boolean) => import("@emotion/react").SerializedStyles;
61
+ export declare const drawerContent: (palette: HeaderPalette) => import("@emotion/react").SerializedStyles;
62
+ /** Chevron of a mobile group row; flips while the group is open. */
63
+ export declare const mobileToggle: (expanded: boolean) => import("@emotion/react").SerializedStyles;
@@ -0,0 +1,104 @@
1
+ import { HTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ import type { MapIconsType } from '../Icon/types';
3
+ /**
4
+ * Header size. Sets the bar height — 64px, 84px or 92px — and the logo box.
5
+ */
6
+ export type HeaderSize = 'small' | 'medium' | 'large';
7
+ /**
8
+ * Header color scheme: white bar, or the dark graphite gradient.
9
+ */
10
+ export type HeaderTheme = 'light' | 'dark';
11
+ /**
12
+ * One entry of the Header navigation.
13
+ *
14
+ * A leaf item with a `path` renders as a router link. An item with `children`
15
+ * is a group: on desktop it opens a dropdown (hover with a mouse, tap on touch
16
+ * screens), in the mobile menu it expands in place. Groups nest two levels
17
+ * deep at most — the third level is not rendered.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * const items: HeaderNavItem[] = [
22
+ * { id: 'home', label: 'Home', path: '/' },
23
+ * {
24
+ * id: 'people',
25
+ * label: 'People',
26
+ * children: [
27
+ * { id: 'employees', label: 'Employees', path: '/people/employees' },
28
+ * { id: 'vacancies', label: 'Vacancies', path: '/people/vacancies' },
29
+ * ],
30
+ * },
31
+ * ];
32
+ * ```
33
+ */
34
+ export interface HeaderNavItem {
35
+ /** Unique key of the item within its level */
36
+ id: string;
37
+ /** Visible label */
38
+ label: ReactNode;
39
+ /**
40
+ * Leading icon — a kit icon name, or an element rendered as-is. A string is
41
+ * always read as an icon name; wrap anything else (an emoji, text) in an
42
+ * element. Shown in the mobile menu and before the label on desktop.
43
+ */
44
+ icon?: keyof MapIconsType | ReactElement;
45
+ /**
46
+ * Route the item links to. Ignored on group items (those with `children`),
47
+ * which only open their submenu; a group is highlighted when any of its
48
+ * descendants matches the current location.
49
+ */
50
+ path?: string;
51
+ /** Renders the item greyed out and not interactive */
52
+ disabled?: boolean;
53
+ /** Submenu items; makes this item a group */
54
+ children?: HeaderNavItem[];
55
+ }
56
+ /**
57
+ * Props for the Header component.
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * <Header
62
+ * logo={<img src="/logo.svg" alt="Acme" />}
63
+ * items={items}
64
+ * rightSide={<UserProfile {...profile} />}
65
+ * />
66
+ * ```
67
+ */
68
+ export interface HeaderProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
69
+ /**
70
+ * Project logo, placed in a box of fixed height. Leave it out and the box
71
+ * stays empty, so the layout does not shift between apps with and without
72
+ * a logo.
73
+ */
74
+ logo?: ReactNode;
75
+ /** Navigation items. Rendered centred; scrolls sideways when it overflows. */
76
+ items?: HeaderNavItem[];
77
+ /**
78
+ * Right-hand content — user profile, notifications, log out, whatever the
79
+ * app needs. Rendered as-is on every screen size.
80
+ */
81
+ rightSide?: ReactNode;
82
+ /**
83
+ * Color scheme of the bar and its menus. Named after the kit's other
84
+ * light/dark components (TreeView, CollapsibleNavBar) — not the Emotion
85
+ * theme.
86
+ * @default 'light'
87
+ */
88
+ theme?: HeaderTheme;
89
+ /**
90
+ * Bar height and logo size
91
+ * @default 'small'
92
+ */
93
+ size?: HeaderSize;
94
+ /**
95
+ * Accessible name of the navigation landmark
96
+ * @default 'Main'
97
+ */
98
+ navLabel?: string;
99
+ /**
100
+ * Accessible name of the burger button shown below 900px
101
+ * @default 'Open menu'
102
+ */
103
+ menuButtonLabel?: string;
104
+ }
@@ -2,6 +2,8 @@ export { default as Button } from './Button';
2
2
  export type * from './Button/types';
3
3
  export * from './ButtonGroup';
4
4
  export * from './IconButton';
5
+ export * from './FloatingActionButton';
6
+ export type * from './FloatingActionButton/types';
5
7
  export * from './Breadcrumbs';
6
8
  export { default as Checkbox } from './Checkbox';
7
9
  export * from './Checkbox';
@@ -115,6 +117,8 @@ export type * from './ResponsiveImage/types';
115
117
  export { default as NavBar } from './NavBar';
116
118
  export * from './NavBar';
117
119
  export * from './CollapsibleNavBar';
120
+ export * from './Header';
121
+ export type * from './Header/types';
118
122
  export * from './TreeView';
119
123
  export { default as Tab } from './Tab';
120
124
  export { default as TabBar } from './TabBar';