gantri-components 2.227.0 → 2.229.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.
@@ -21,13 +21,9 @@ export interface OptionSelectorItem {
21
21
  */
22
22
  intent?: OptionSelectorIntent;
23
23
  }
24
- export interface OptionSelectorProps {
24
+ interface OptionSelectorBaseProps {
25
25
  /** Array of options. Can be strings (used as both value and label) or OptionSelectorItem objects. */
26
26
  items: (string | OptionSelectorItem)[];
27
- /** Currently selected value. */
28
- value: string;
29
- /** Callback when an option is selected. */
30
- onSelected: (value: string) => void;
31
27
  /** Number of columns in the grid. */
32
28
  columns?: ResolutionAwareProp<number>;
33
29
  /** Gap between items. Defaults to '.5x' (4px). */
@@ -52,7 +48,7 @@ export interface OptionSelectorProps {
52
48
  onChange?: (event: {
53
49
  target: {
54
50
  name: string;
55
- value: string;
51
+ value: string | string[];
56
52
  };
57
53
  }) => void;
58
54
  /** Formik integration props - injected by FormikInput. */
@@ -68,14 +64,33 @@ export interface OptionSelectorProps {
68
64
  /** Error message from Formik validation. */
69
65
  errorMessage?: string;
70
66
  /**
71
- * When true, clicking the currently selected option clears the selection
72
- * (emits an empty string). Defaults to true.
67
+ * When true, clicking the currently selected option clears the selection.
68
+ * In single mode, clears to an empty string. In multi mode, toggling is
69
+ * always on and this prop is ignored. Defaults to true.
73
70
  */
74
71
  allowDeselect?: boolean;
75
72
  }
73
+ interface OptionSelectorSingleProps extends OptionSelectorBaseProps {
74
+ /** Single-selection mode (default). */
75
+ multiple?: false;
76
+ /** Currently selected value. */
77
+ value: string;
78
+ /** Callback when an option is selected. */
79
+ onSelected: (value: string) => void;
80
+ }
81
+ interface OptionSelectorMultipleProps extends OptionSelectorBaseProps {
82
+ /** Enables multi-selection. Clicking an option toggles it in/out of the selection. */
83
+ multiple: true;
84
+ /** Currently selected values. */
85
+ value: string[];
86
+ /** Callback fired with the next array of selected values. */
87
+ onSelected: (values: string[]) => void;
88
+ }
89
+ export type OptionSelectorProps = OptionSelectorSingleProps | OptionSelectorMultipleProps;
76
90
  export interface StyledOptionProps {
77
91
  $disabled: boolean;
78
92
  $selected: boolean;
79
93
  $size?: ResolutionAwareProp<OptionSelectorSize>;
80
94
  $intent?: OptionSelectorIntent;
81
95
  }
96
+ export {};