@spteck/react-controls-v2 2.5.14 → 2.5.16

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.
@@ -1,22 +1,48 @@
1
1
  import { Theme } from '@fluentui/react-components';
2
- import { IButtonMenuOption } from './IButtonMenuOption';
2
+ import { ButtonMenuItemType, IButtonMenuOption } from './IButtonMenuOption';
3
3
  import * as React from "react";
4
4
  export interface IButtonMenuStyles {
5
5
  root?: React.CSSProperties;
6
6
  menulist?: React.CSSProperties;
7
7
  menuitem?: React.CSSProperties;
8
8
  }
9
+ export interface IButtonMenuRenderHelpers {
10
+ /** True when the option is currently part of the selection. */
11
+ isSelected: boolean;
12
+ /** True when the menu is rendering this item as disabled. */
13
+ isDisabled: boolean;
14
+ /** Resolved item type after considering per-option override and `defaultItemType`. */
15
+ itemType: ButtonMenuItemType;
16
+ }
9
17
  export interface IButtonMenuProps {
10
- onSelected: (option: IButtonMenuOption) => void;
18
+ /** Single-selection / "item" mode callback. Called with the clicked option. */
19
+ onSelected?: (option: IButtonMenuOption) => void;
20
+ /** Multi-selection callback (checkbox mode). Receives the full set of selected options. */
21
+ onSelectionChange?: (selectedOptions: IButtonMenuOption[]) => void;
22
+ /** Controlled selected option for radio mode. */
11
23
  value?: IButtonMenuOption;
24
+ /** Controlled selected keys for checkbox mode. */
25
+ selectedKeys?: string[];
12
26
  label?: string;
27
+ /**
28
+ * Fixed text rendered inside the trigger button.
29
+ * - Required for `checkbox` mode and `divider/header`-only menus.
30
+ * - In `radio` and `item` modes, when omitted the button reflects the selected/last-clicked option.
31
+ */
13
32
  buttonText?: string;
14
33
  styles?: React.CSSProperties | IButtonMenuStyles;
15
34
  theme?: Theme;
16
35
  options: IButtonMenuOption[];
36
+ /** Default control to render for items that do not specify `itemType`. Defaults to `'radio'`. */
37
+ defaultItemType?: ButtonMenuItemType;
17
38
  apparence?: "primary" | "subtle" | "outline" | "transparent";
18
39
  shape?: "circular" | "square";
19
40
  size?: "small" | "medium" | "large";
41
+ /**
42
+ * Optional renderer for menu items. Return `defaultRender()` to fall back to
43
+ * the standard Fluent control for the resolved `itemType`.
44
+ */
45
+ onRenderItem?: (option: IButtonMenuOption, defaultRender: () => React.ReactNode, helpers: IButtonMenuRenderHelpers) => React.ReactNode;
20
46
  }
21
47
  export declare const ButtonMenu: React.FunctionComponent<IButtonMenuProps>;
22
48
  //# sourceMappingURL=ButtonMenu.d.ts.map
@@ -1,10 +1,22 @@
1
+ import * as React from "react";
2
+ export type ButtonMenuItemType = "radio" | "checkbox" | "item" | "divider" | "header";
1
3
  export interface IButtonMenuOption {
4
+ /** Unique key. Required for selectable items; optional for divider/header. */
2
5
  key: string;
6
+ /** Display text. Used as label and as header text when itemType === 'header'. */
3
7
  text: string;
4
8
  icon?: React.ReactElement;
5
- selected: boolean;
9
+ /** Initial selection hint (used when no `value` / `selectedKeys` is provided). */
10
+ selected?: boolean;
6
11
  disabled?: boolean;
7
12
  description?: string;
8
13
  color?: string;
14
+ /**
15
+ * Per-option override of the rendered control. When omitted, the component
16
+ * falls back to the top-level `defaultItemType` on `<ButtonMenu />`.
17
+ */
18
+ itemType?: ButtonMenuItemType;
19
+ /** Optional secondary text rendered to the right of the item. */
20
+ secondaryContent?: React.ReactNode;
9
21
  }
10
22
  //# sourceMappingURL=IButtonMenuOption.d.ts.map