@leabankab/component-library 8.8.0 → 8.9.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.
@@ -5,7 +5,20 @@ export type SelectOption<Value extends string = string> = {
5
5
  label: string;
6
6
  /** Shown, but not selectable. */
7
7
  disabled?: boolean;
8
+ /**
9
+ * A picture before the label, 20px: a flag, a logo. Decoration, hidden
10
+ * from assistive tech, so the label has to say it all. In a `Select` the
11
+ * chosen option's icon also shows in the field, unless `startAdornment`
12
+ * takes its place.
13
+ */
14
+ icon?: ReactNode;
8
15
  };
16
+ /**
17
+ * `"md"`: the 54px field with a floating label. `"sm"`: a compact 32px field
18
+ * for a narrow place (the country list in the website's footer), with its
19
+ * label as a line above it.
20
+ */
21
+ export type SelectSize = "sm" | "md";
9
22
  /** The props `Select` and `MultiSelect` have in common. */
10
23
  export type SelectFieldBaseProps = {
11
24
  /** Floating label, linked to the select for you. */
@@ -48,6 +61,8 @@ export type SelectFieldBaseProps = {
48
61
  ref?: Ref<HTMLElement>;
49
62
  };
50
63
  type SelectFieldProps = SelectFieldBaseProps & {
64
+ /** `Select` only; `MultiSelect` is always `md`. */
65
+ size?: SelectSize;
51
66
  multiple: boolean;
52
67
  /** The value as Base UI holds it: `null` or an array when empty. */
53
68
  value: string | string[] | null;
@@ -66,7 +81,7 @@ type SelectFieldProps = SelectFieldBaseProps & {
66
81
  /** The `SelectFieldItem`s. */
67
82
  children: ReactNode;
68
83
  };
69
- export declare function SelectField({ label, helperText, error, required, disabled, placeholder, startAdornment, endAdornment, open: openProp, onOpenChange, onBlur, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className, style, ref, multiple, value, onValueChange, filled, display, displayHidden, valueText, children, }: SelectFieldProps): import("react").JSX.Element;
84
+ export declare function SelectField({ label, helperText, error, required, disabled, placeholder, startAdornment, endAdornment, open: openProp, onOpenChange, onBlur, name, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className, style, ref, size, multiple, value, onValueChange, filled, display, displayHidden, valueText, children, }: SelectFieldProps): import("react").JSX.Element;
70
85
  type SelectFieldItemProps = {
71
86
  option: SelectOption;
72
87
  disabled?: boolean;
@@ -75,4 +90,8 @@ type SelectFieldItemProps = {
75
90
  };
76
91
  /** One option in the list. */
77
92
  export declare function SelectFieldItem({ option, disabled, children, }: SelectFieldItemProps): import("react").JSX.Element;
93
+ /** The icon of an option, in the list or in the field: 20px, decoration. */
94
+ export declare function OptionIcon({ children }: {
95
+ children: ReactNode;
96
+ }): import("react").JSX.Element;
78
97
  export {};
@@ -1,5 +1,5 @@
1
- import { SelectFieldBaseProps, SelectOption } from './select-field';
2
- export type { SelectOption };
1
+ import { SelectFieldBaseProps, SelectOption, SelectSize } from './select-field';
2
+ export type { SelectOption, SelectSize };
3
3
  export type SelectProps<Value extends string = string> = SelectFieldBaseProps & {
4
4
  /** The choices. */
5
5
  options: readonly SelectOption<Value>[];
@@ -9,6 +9,12 @@ export type SelectProps<Value extends string = string> = SelectFieldBaseProps &
9
9
  defaultValue?: Value | "";
10
10
  /** Called with the value of the option the user picks. */
11
11
  onValueChange?: (value: Value) => void;
12
+ /**
13
+ * `"sm"` is a compact 32px field for a narrow place, with the `label`
14
+ * as a line above it instead of floating inside.
15
+ * @default "md"
16
+ */
17
+ size?: SelectSize;
12
18
  };
13
19
  /**
14
20
  * Select on Base UI's `Select`, in the same box as `Input`. The label, the
@@ -30,5 +36,9 @@ export type SelectProps<Value extends string = string> = SelectFieldBaseProps &
30
36
  * Values are strings, and `""` means nothing is chosen. Written with
31
37
  * `as const`, the options give `value` and `onValueChange` their type:
32
38
  * `"no" | "se"` here.
39
+ *
40
+ * An option can carry an `icon` (a flag, a logo), shown before its label in
41
+ * the list and, once it is chosen, in the field. `size="sm"` is a compact
42
+ * 32px field with its label above it.
33
43
  */
34
- export declare function Select<Value extends string = string>({ options, value, defaultValue, onValueChange, ...rest }: SelectProps<Value>): import("react").JSX.Element;
44
+ export declare function Select<Value extends string = string>({ options, value, defaultValue, onValueChange, startAdornment, ...rest }: SelectProps<Value>): import("react").JSX.Element;