@ssa-ui-kit/core 3.24.1 → 3.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/source-map.md +119 -55
- package/dist/components/Breadcrumbs/styles.d.ts +1 -1
- package/dist/components/ContextMenu/ContextMenu.d.ts +74 -0
- package/dist/components/ContextMenu/ContextMenuOption.d.ts +18 -0
- package/dist/components/ContextMenu/index.d.ts +3 -0
- package/dist/components/ContextMenu/styles.d.ts +17 -0
- package/dist/components/ContextMenu/types.d.ts +153 -0
- package/dist/components/ContextMenu/utils.d.ts +79 -0
- package/dist/components/Dropdown/types.d.ts +7 -0
- package/dist/components/DropdownOptions/DropdownOptions.d.ts +5 -5
- package/dist/components/DropdownOptions/useToggleListKeys.d.ts +33 -0
- package/dist/components/DropdownOptions/utils.d.ts +9 -0
- package/dist/components/FiltersMultiSelect/FiltersMultiSelectProvider.d.ts +9 -0
- package/dist/components/FiltersMultiSelect/components/FiltersMultiSelectOption.d.ts +31 -1
- package/dist/components/FiltersMultiSelect/components/FiltersMultiSelectOptions.d.ts +29 -2
- package/dist/components/FiltersMultiSelect/utils.d.ts +15 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +79 -0
- package/dist/components/FloatingActionButton/index.d.ts +1 -0
- package/dist/components/FloatingActionButton/styles.d.ts +42 -0
- package/dist/components/FloatingActionButton/types.d.ts +129 -0
- package/dist/components/Header/Header.d.ts +43 -0
- package/dist/components/Header/HeaderMobileMenu.d.ts +19 -0
- package/dist/components/Header/HeaderNavMenu.d.ts +17 -0
- package/dist/components/Header/helpers.d.ts +13 -0
- package/dist/components/Header/index.d.ts +1 -0
- package/dist/components/Header/styles.d.ts +74 -0
- package/dist/components/Header/types.d.ts +104 -0
- package/dist/components/MultipleDropdown/MultipleDropdown.d.ts +4 -1
- package/dist/components/MultipleDropdown/types.d.ts +8 -0
- package/dist/components/MultipleDropdownOptions/MultipleDropdownOptions.d.ts +27 -0
- package/dist/components/Table/ColumnFreezeMenu.d.ts +2 -0
- package/dist/components/Typeahead/Typeahead.context.d.ts +9 -1
- package/dist/components/Typeahead/components/TypeaheadOptions.d.ts +13 -1
- package/dist/components/Typeahead/styles.d.ts +5 -0
- package/dist/components/Typeahead/types.d.ts +6 -0
- package/dist/components/Typeahead/useTypeahead.d.ts +10 -1
- package/dist/components/index.d.ts +6 -0
- package/dist/index.js +10204 -8167
- package/dist/index.mjs +12979 -10948
- package/dist/tsbuildcache +1 -1
- package/dist/utils/colorUtils.d.ts +15 -0
- package/package.json +3 -3
|
@@ -2,8 +2,9 @@ import { DropdownItemsListProps } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* DropdownOptions - Options menu container for Dropdown component
|
|
4
4
|
*
|
|
5
|
-
* Renders the
|
|
6
|
-
*
|
|
5
|
+
* Renders the `DropdownOption` children as a `ContextMenu` placed under (or
|
|
6
|
+
* above) the Dropdown toggle. Focus stays on the toggle; the highlighted
|
|
7
|
+
* option is driven from there and announced through `aria-activedescendant`.
|
|
7
8
|
*
|
|
8
9
|
* Placement (opening upward or downward) is driven entirely by the parent
|
|
9
10
|
* Dropdown via context — this component does not calculate position itself.
|
|
@@ -31,9 +32,8 @@ import { DropdownItemsListProps } from './types';
|
|
|
31
32
|
* @see {@link DropdownOption} - Individual option components
|
|
32
33
|
*
|
|
33
34
|
* @accessibility
|
|
34
|
-
* - Uses role="listbox"
|
|
35
|
-
* -
|
|
36
|
-
* - Screen reader friendly
|
|
35
|
+
* - Uses role="listbox" with role="option" rows
|
|
36
|
+
* - Arrow keys, Home, End, Enter, Space and Escape on the toggle
|
|
37
37
|
*/
|
|
38
38
|
declare const DropdownOptions: ({ "aria-labelledby": ariaLabelledbyNative, ariaLabelledby, id, children, }: DropdownItemsListProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
39
39
|
export default DropdownOptions;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
import { ContextMenuItem } from '../ContextMenu';
|
|
3
|
+
import { OptionValue } from './utils';
|
|
4
|
+
/** Options of {@link useToggleListKeys}. */
|
|
5
|
+
export interface UseToggleListKeysOptions {
|
|
6
|
+
/** Id of the ContextMenu the toggle controls. */
|
|
7
|
+
listId: string;
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
menuItems: ContextMenuItem<OptionValue>[];
|
|
11
|
+
/** Highlighted option. */
|
|
12
|
+
activeValue: OptionValue | null;
|
|
13
|
+
setActiveValue: (value: OptionValue | null) => void;
|
|
14
|
+
/** Opens the list; `key` is the arrow that opened it. */
|
|
15
|
+
open: (key: string) => void;
|
|
16
|
+
close: () => void;
|
|
17
|
+
/** Enter or Space on the highlighted option. */
|
|
18
|
+
onPick: (value: OptionValue) => void;
|
|
19
|
+
/** Consumer handlers, run first; `preventDefault()` skips the built-in keys. */
|
|
20
|
+
onKeyDown?: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
21
|
+
onKeyUp?: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Keyboard for a dropdown toggle that keeps focus while it drives its list:
|
|
25
|
+
* arrows open it, then Arrow/Home/End move the highlight, Enter/Space pick,
|
|
26
|
+
* Escape/Tab close. Returns the toggle's handlers and its
|
|
27
|
+
* `aria-activedescendant`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useToggleListKeys: ({ listId, isOpen, disabled, menuItems, activeValue, setActiveValue, open, close, onPick, onKeyDown, onKeyUp, }: UseToggleListKeysOptions) => {
|
|
30
|
+
onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
31
|
+
onKeyUp: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
32
|
+
'aria-activedescendant': string | undefined;
|
|
33
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ContextMenuItem } from '../ContextMenu';
|
|
3
|
+
/** Value of a Dropdown option as the list sees it. */
|
|
4
|
+
export type OptionValue = string | number;
|
|
5
|
+
/**
|
|
6
|
+
* Reads `DropdownOption` children into ContextMenu items. The label resolves
|
|
7
|
+
* as `children` → `label` → `value`, as it always has.
|
|
8
|
+
*/
|
|
9
|
+
export declare const toDropdownMenuItems: (children: React.ReactNode) => ContextMenuItem<OptionValue>[];
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
1
2
|
import { UseFiltersMultiSelectStore } from './useFiltersMultiSelect';
|
|
3
|
+
import type { FilterMenuItem } from './utils';
|
|
2
4
|
export interface FiltersMultiSelectContextValue {
|
|
3
5
|
store: UseFiltersMultiSelectStore;
|
|
4
6
|
emptyNode?: React.ReactNode;
|
|
7
|
+
/** Id of the options list, referenced by the search input. */
|
|
8
|
+
listId?: string;
|
|
9
|
+
/** Highlighted option, driven from the search input and the pointer. */
|
|
10
|
+
activeValue?: string | null;
|
|
11
|
+
setActiveValue?: (value: string | null) => void;
|
|
12
|
+
/** The rendered options, kept here for the search input's keyboard. */
|
|
13
|
+
itemsRef?: MutableRefObject<FilterMenuItem[]>;
|
|
5
14
|
}
|
|
6
15
|
export declare const FiltersMultiSelectProvider: ({ children, value, }: {
|
|
7
16
|
value: FiltersMultiSelectContextValue;
|
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
import { Filter } from '../useFiltersMultiSelect';
|
|
2
2
|
export interface FiltersMultiSelectOptionProps {
|
|
3
|
+
/** The filter this row adds. `group: true` makes it a select-only row. */
|
|
3
4
|
filter: Filter;
|
|
5
|
+
/** Row content. */
|
|
4
6
|
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Ignored — the row's state comes from the store's selected
|
|
9
|
+
* filters. Removed in the next major release.
|
|
10
|
+
*/
|
|
5
11
|
selected?: boolean;
|
|
6
12
|
}
|
|
7
|
-
|
|
13
|
+
/**
|
|
14
|
+
* FiltersMultiSelectOption - One filter row of a `FiltersMultiSelect`.
|
|
15
|
+
*
|
|
16
|
+
* Declarative: `FiltersMultiSelectOptions` reads its props and renders the
|
|
17
|
+
* row, so it renders nothing on its own. Regular filters get + (include) and
|
|
18
|
+
* − (exclude) controls; `group` filters get a single check-circle.
|
|
19
|
+
*
|
|
20
|
+
* @category Form Controls
|
|
21
|
+
* @subcategory Selection
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <FiltersMultiSelectOptions>
|
|
26
|
+
* <FiltersMultiSelectOption filter={{ id: '1', label: 'Active' }}>
|
|
27
|
+
* Active
|
|
28
|
+
* </FiltersMultiSelectOption>
|
|
29
|
+
* <FiltersMultiSelectOption filter={{ id: 'g', label: 'Saved', group: true }}>
|
|
30
|
+
* Saved
|
|
31
|
+
* </FiltersMultiSelectOption>
|
|
32
|
+
* </FiltersMultiSelectOptions>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see {@link FiltersMultiSelectOptions} - The list that renders it
|
|
36
|
+
*/
|
|
37
|
+
export declare const FiltersMultiSelectOption: (_props: FiltersMultiSelectOptionProps) => null;
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import React, { type HTMLAttributes } from 'react';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* FiltersMultiSelectOptions - The options list of a `FiltersMultiSelect`.
|
|
4
|
+
*
|
|
5
|
+
* Renders its `FiltersMultiSelectOption` children as an include / exclude
|
|
6
|
+
* `ContextMenu`: + and − on each row (one check-circle on group rows), Enter
|
|
7
|
+
* in the search input cycles the highlighted row. Shows the
|
|
8
|
+
* `FiltersMultiSelect` `emptyNode` when it has no options.
|
|
9
|
+
*
|
|
10
|
+
* @category Form Controls
|
|
11
|
+
* @subcategory Selection
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <FiltersMultiSelect store={store}>
|
|
16
|
+
* <FiltersMultiSelectOptions>
|
|
17
|
+
* {filters.map((filter) => (
|
|
18
|
+
* <FiltersMultiSelectOption key={filter.id} filter={filter}>
|
|
19
|
+
* {filter.label}
|
|
20
|
+
* </FiltersMultiSelectOption>
|
|
21
|
+
* ))}
|
|
22
|
+
* </FiltersMultiSelectOptions>
|
|
23
|
+
* </FiltersMultiSelect>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see {@link FiltersMultiSelect} - Parent component
|
|
27
|
+
* @see {@link FiltersMultiSelectOption} - One filter row
|
|
28
|
+
*/
|
|
29
|
+
export declare const FiltersMultiSelectOptions: ({ children, onMouseDown, ...props }: {
|
|
3
30
|
children: React.ReactNode;
|
|
4
|
-
} & HTMLAttributes<
|
|
31
|
+
} & Omit<HTMLAttributes<HTMLUListElement>, "onChange" | "defaultValue" | "children">) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ContextMenuIncludeExcludeEntry, ContextMenuIncludeExcludeType, ContextMenuItem } from '../ContextMenu';
|
|
3
|
+
import { Filter, SelectedFilter, UseFiltersMultiSelectStore } from './useFiltersMultiSelect';
|
|
4
|
+
/** A ContextMenu row together with the filter it stands for. */
|
|
5
|
+
export type FilterMenuItem = ContextMenuItem<string> & {
|
|
6
|
+
filter: Filter;
|
|
7
|
+
};
|
|
8
|
+
/** Reads `FiltersMultiSelectOption` children into ContextMenu items. */
|
|
9
|
+
export declare const toFilterMenuItems: (children: React.ReactNode) => FilterMenuItem[];
|
|
10
|
+
/** The store's selection in ContextMenu's `includeExclude` shape. */
|
|
11
|
+
export declare const toMenuSelection: (selectedFilters: SelectedFilter[]) => ContextMenuIncludeExcludeEntry<string>[];
|
|
12
|
+
/** The store's current type for a filter, in ContextMenu's terms. */
|
|
13
|
+
export declare const getMenuType: (store: UseFiltersMultiSelectStore, id: string) => ContextMenuIncludeExcludeType | undefined;
|
|
14
|
+
/** Selects `filter` as `type`, or unselects it when `type` is undefined. */
|
|
15
|
+
export declare const setFilterType: (store: UseFiltersMultiSelectStore, { id, label }: Filter, type: ContextMenuIncludeExcludeType | undefined) => void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { FloatingActionButtonIcon, FloatingActionButtonSize } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* FloatingActionButton - A button fixed to a corner of the viewport for the
|
|
4
|
+
* page's primary action, optionally opening a speed-dial menu of related
|
|
5
|
+
* actions.
|
|
6
|
+
*
|
|
7
|
+
* ### Look
|
|
8
|
+
* Icon-only by default; pass `label` for the extended (icon + text) FAB.
|
|
9
|
+
* `color` takes the design's `primary` / `secondary`, a theme color key or
|
|
10
|
+
* any CSS color — for custom colors the icon and label color is chosen for
|
|
11
|
+
* contrast. `shadow` and `shape` are independent of the color.
|
|
12
|
+
*
|
|
13
|
+
* ### Menu
|
|
14
|
+
* Pass `actions` to turn the button into a menu trigger. The items stack
|
|
15
|
+
* away from the corner as secondary FABs of the same size; the trigger
|
|
16
|
+
* switches to `openIcon` while open. Choosing an item, Escape, a click
|
|
17
|
+
* outside or tabbing away closes the menu. Control it with `open` +
|
|
18
|
+
* `onOpenChange`, or leave it uncontrolled (`defaultOpen`).
|
|
19
|
+
*
|
|
20
|
+
* ### Icons
|
|
21
|
+
* A kit icon name is sized for the FAB and painted with its foreground color.
|
|
22
|
+
* Any other node is rendered as-is.
|
|
23
|
+
*
|
|
24
|
+
* @category Components
|
|
25
|
+
* @subcategory Buttons
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <FloatingActionButton aria-label="Add member" onClick={addMember} />
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* // Extended, secondary, bottom-left
|
|
35
|
+
* <FloatingActionButton label="New report" color="secondary" position="bottom-left" />
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* // Speed-dial menu
|
|
41
|
+
* <FloatingActionButton
|
|
42
|
+
* aria-label="Create"
|
|
43
|
+
* actions={[
|
|
44
|
+
* { id: 'task', icon: 'plus', label: 'Task', onClick: createTask },
|
|
45
|
+
* { id: 'note', icon: 'edit', label: 'Note', onClick: createNote },
|
|
46
|
+
* ]}
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @accessibility
|
|
51
|
+
* - Icon-only FABs need an `aria-label` (a dev warning fires without one)
|
|
52
|
+
* - In menu mode the trigger has `aria-haspopup="menu"` and `aria-expanded`;
|
|
53
|
+
* the items are `menuitem`s
|
|
54
|
+
* - Opening the menu from the keyboard focuses its first item; ↑/↓, Home and
|
|
55
|
+
* End move between items (and from the trigger into the menu while it is
|
|
56
|
+
* open); Escape closes it and returns focus to the trigger
|
|
57
|
+
*/
|
|
58
|
+
export declare const FloatingActionButton: import("react").ForwardRefExoticComponent<Pick<import("react").AriaAttributes, "aria-label" | "aria-describedby"> & {
|
|
59
|
+
icon?: FloatingActionButtonIcon;
|
|
60
|
+
label?: string;
|
|
61
|
+
color?: import("./types").FloatingActionButtonColor;
|
|
62
|
+
shadow?: boolean;
|
|
63
|
+
shape?: "square" | "round";
|
|
64
|
+
size?: FloatingActionButtonSize;
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
onClick?: import("react").MouseEventHandler<HTMLButtonElement>;
|
|
67
|
+
actions?: import("./types").FloatingActionButtonAction[];
|
|
68
|
+
showActionLabels?: boolean;
|
|
69
|
+
open?: boolean;
|
|
70
|
+
defaultOpen?: boolean;
|
|
71
|
+
onOpenChange?: (open: boolean) => void;
|
|
72
|
+
openIcon?: FloatingActionButtonIcon;
|
|
73
|
+
position?: import("./types").FloatingActionButtonPosition;
|
|
74
|
+
offset?: number | {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
className?: string;
|
|
79
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FloatingActionButton';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Theme } from '@emotion/react';
|
|
2
|
+
import { FloatingActionButtonColor, FloatingActionButtonPosition, FloatingActionButtonSize } from './types';
|
|
3
|
+
type SizeTokens = {
|
|
4
|
+
/** Height, and width when icon-only. */
|
|
5
|
+
box: number;
|
|
6
|
+
/** Glyph size when icon-only. */
|
|
7
|
+
iconOnly: number;
|
|
8
|
+
/** Glyph size next to a label. */
|
|
9
|
+
iconLabelled: number;
|
|
10
|
+
paddingLeft: number;
|
|
11
|
+
paddingRight: number;
|
|
12
|
+
gap: number;
|
|
13
|
+
fontSize: number;
|
|
14
|
+
lineHeight: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Figma draws labelled FABs 4px taller than icon-only ones of the same size;
|
|
18
|
+
* that is a design bug, so both use the icon-only height here.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SIZES: Record<FloatingActionButtonSize, SizeTokens>;
|
|
21
|
+
export type ColorTokens = {
|
|
22
|
+
background: string;
|
|
23
|
+
hover: string;
|
|
24
|
+
active: string;
|
|
25
|
+
foreground: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Resolves `color` to the four colors a FAB paints with. The two named
|
|
29
|
+
* colors follow the design tokens; anything else is a theme key or CSS
|
|
30
|
+
* color whose foreground is picked for contrast.
|
|
31
|
+
*/
|
|
32
|
+
export declare const resolveColors: (theme: Theme, color: FloatingActionButtonColor) => ColorTokens;
|
|
33
|
+
export declare const container: (position: FloatingActionButtonPosition, x: number, y: number) => import("@emotion/react").SerializedStyles;
|
|
34
|
+
export declare const menu: (position: FloatingActionButtonPosition) => import("@emotion/react").SerializedStyles;
|
|
35
|
+
export declare const button: (theme: Theme, { size, colors, shadow, round, labelled, }: {
|
|
36
|
+
size: FloatingActionButtonSize;
|
|
37
|
+
colors: ColorTokens;
|
|
38
|
+
shadow: boolean;
|
|
39
|
+
round: boolean;
|
|
40
|
+
labelled: boolean;
|
|
41
|
+
}) => import("@emotion/react").SerializedStyles;
|
|
42
|
+
export {};
|
|
@@ -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
|
+
* The layout follows the Header's own width, not the window's. From 900px
|
|
15
|
+
* the navigation is centred between the logo and the right side, and scrolls
|
|
16
|
+
* sideways when it does not fit. Below 900px it moves into a drawer opened
|
|
17
|
+
* by a burger button, the logo is centred and `rightSide` 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,19 @@
|
|
|
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 400px drawer (full width on phones) holding
|
|
14
|
+
* a `TreeView`, the same engine as CollapsibleNavBar's menu. The tree owns
|
|
15
|
+
* expansion and opens the group holding the current page; this module owns
|
|
16
|
+
* the routing.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HeaderMobileMenu: ({ store, items, headerTheme, palette, pathname, navLabel, }: HeaderMobileMenuProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
|
+
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,74 @@
|
|
|
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
|
+
/** From this header width up the bar shows the nav; below it, the burger. */
|
|
9
|
+
export declare const DESKTOP_MIN_WIDTH = 900;
|
|
10
|
+
/** Design: dropdowns sit 6px below their trigger and flyouts 6px aside. */
|
|
11
|
+
export declare const MENU_OFFSET = 6;
|
|
12
|
+
export declare const resolvePalette: (theme: Theme, headerTheme: HeaderTheme) => {
|
|
13
|
+
background: string;
|
|
14
|
+
text: `rgb${string}` | undefined;
|
|
15
|
+
accent: `rgb${string}` | undefined;
|
|
16
|
+
disabled: `rgb${string}` | undefined;
|
|
17
|
+
menuBackground: `rgb${string}` | undefined;
|
|
18
|
+
menuItem: `rgb${string}` | undefined;
|
|
19
|
+
menuItemHover: `rgb${string}` | undefined;
|
|
20
|
+
menuItemOpen: `rgb${string}` | undefined;
|
|
21
|
+
menuText: `rgb${string}` | undefined;
|
|
22
|
+
menuDisabled: `rgb${string}` | undefined;
|
|
23
|
+
drawerBackground: `rgb${string}` | undefined;
|
|
24
|
+
} | {
|
|
25
|
+
background: `rgb${string}` | undefined;
|
|
26
|
+
text: `rgb${string}` | undefined;
|
|
27
|
+
accent: `rgb${string}` | "transparent";
|
|
28
|
+
disabled: `rgb${string}` | undefined;
|
|
29
|
+
menuBackground: `rgb${string}` | undefined;
|
|
30
|
+
menuItem: `rgb${string}` | undefined;
|
|
31
|
+
menuItemHover: `rgb${string}` | undefined;
|
|
32
|
+
menuItemOpen: `rgb${string}` | undefined;
|
|
33
|
+
menuText: `rgb${string}` | undefined;
|
|
34
|
+
menuDisabled: `rgb${string}` | undefined;
|
|
35
|
+
drawerBackground: `rgb${string}` | "transparent";
|
|
36
|
+
};
|
|
37
|
+
export type HeaderPalette = ReturnType<typeof resolvePalette>;
|
|
38
|
+
/**
|
|
39
|
+
* The query container. It is the `header` itself, so consumer styles such
|
|
40
|
+
* as `position: sticky` land on the outermost element; the layout that
|
|
41
|
+
* the query switches lives on the bar inside.
|
|
42
|
+
*/
|
|
43
|
+
export declare const container: (palette: HeaderPalette) => import("@emotion/react").SerializedStyles;
|
|
44
|
+
export declare const bar: (size: HeaderSize) => import("@emotion/react").SerializedStyles;
|
|
45
|
+
export declare const burger: (theme: Theme, palette: HeaderPalette) => import("@emotion/react").SerializedStyles;
|
|
46
|
+
/** Holds the burger's column when there is no menu, so the logo stays centred. */
|
|
47
|
+
export declare const burgerPlaceholder: import("@emotion/react").SerializedStyles;
|
|
48
|
+
/**
|
|
49
|
+
* Fixed height from the size; width follows the logo so wordmarks fit, but
|
|
50
|
+
* never drops below a square, so an empty box still holds its place.
|
|
51
|
+
*/
|
|
52
|
+
export declare const logo: (size: HeaderSize) => import("@emotion/react").SerializedStyles;
|
|
53
|
+
/**
|
|
54
|
+
* The scroll container. Dropdowns are portalled, so the overflow here does
|
|
55
|
+
* not clip them.
|
|
56
|
+
*/
|
|
57
|
+
export declare const nav: import("@emotion/react").SerializedStyles;
|
|
58
|
+
/** `margin: auto` centres the list while it fits and lets it scroll after. */
|
|
59
|
+
export declare const navList: import("@emotion/react").SerializedStyles;
|
|
60
|
+
export declare const rightSide: import("@emotion/react").SerializedStyles;
|
|
61
|
+
/**
|
|
62
|
+
* Selected keeps the regular weight: the design's bold resizes the item and
|
|
63
|
+
* shifts the whole bar as the route changes, so the state is marked by color
|
|
64
|
+
* alone.
|
|
65
|
+
*/
|
|
66
|
+
export declare const navItem: (theme: Theme, palette: HeaderPalette, active: boolean) => import("@emotion/react").SerializedStyles;
|
|
67
|
+
export declare const menu: (theme: Theme, palette: HeaderPalette) => import("@emotion/react").SerializedStyles;
|
|
68
|
+
export declare const menuItem: (theme: Theme, palette: HeaderPalette, active: boolean) => import("@emotion/react").SerializedStyles;
|
|
69
|
+
export declare const drawerContent: (palette: HeaderPalette) => import("@emotion/react").SerializedStyles;
|
|
70
|
+
/**
|
|
71
|
+
* Chevron of a mobile group row; flips while the group is open. Pushed to the
|
|
72
|
+
* row's end so every chevron shares one vertical line.
|
|
73
|
+
*/
|
|
74
|
+
export declare const mobileToggle: (expanded: boolean) => import("@emotion/react").SerializedStyles;
|