@leabankab/component-library 7.3.0 → 8.1.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.
Files changed (193) hide show
  1. package/CHANGELOG.md +745 -0
  2. package/README.md +2 -5
  3. package/dist/component-library.es.js +2948 -5676
  4. package/dist/component-library.es.js.map +1 -1
  5. package/dist/component-library.umd.js +2 -28
  6. package/dist/component-library.umd.js.map +1 -1
  7. package/dist/components/animations/icons/status-icon.d.ts +4 -0
  8. package/dist/components/animations/illustrations/check-animation.d.ts +8 -0
  9. package/dist/components/animations/illustrations/pulse-animation.d.ts +5 -1
  10. package/dist/components/animations/illustrations/status-animation.d.ts +8 -1
  11. package/dist/components/animations/shared.d.ts +6 -32
  12. package/dist/components/animations/spinner.d.ts +18 -0
  13. package/dist/components/animations/use-animation-labels.d.ts +0 -5
  14. package/dist/components/buttons/action-button.d.ts +8 -10
  15. package/dist/components/buttons/button-base.d.ts +26 -12
  16. package/dist/components/buttons/button.d.ts +2 -2
  17. package/dist/components/buttons/close-button.d.ts +1 -1
  18. package/dist/components/buttons/icon-button.d.ts +1 -13
  19. package/dist/components/buttons/skip-link.d.ts +21 -4
  20. package/dist/components/color-roles.d.ts +8 -0
  21. package/dist/components/data-display/card.d.ts +54 -4
  22. package/dist/components/data-display/chip.d.ts +50 -8
  23. package/dist/components/data-display/data-field.d.ts +15 -4
  24. package/dist/components/data-display/tooltip.d.ts +74 -22
  25. package/dist/components/feedback/alert-parts.d.ts +10 -9
  26. package/dist/components/feedback/alert.d.ts +1 -1
  27. package/dist/components/feedback/simple-dialog.d.ts +1 -1
  28. package/dist/components/form/amount-slider.d.ts +68 -0
  29. package/dist/components/form/autocomplete.d.ts +56 -59
  30. package/dist/components/form/checkbox-box.d.ts +11 -0
  31. package/dist/components/form/checkbox.d.ts +67 -7
  32. package/dist/components/form/combo-field.d.ts +68 -0
  33. package/dist/components/form/email-input.d.ts +28 -26
  34. package/dist/components/form/field-parts.d.ts +50 -0
  35. package/dist/components/form/index.d.ts +3 -9
  36. package/dist/components/form/input.d.ts +57 -13
  37. package/dist/components/form/multi-select.d.ts +12 -14
  38. package/dist/components/form/number-input-unit.d.ts +28 -0
  39. package/dist/components/form/number-input.d.ts +46 -18
  40. package/dist/components/form/phone-number-input/phone-number-input.d.ts +44 -14
  41. package/dist/components/form/radio-card.d.ts +94 -43
  42. package/dist/components/form/radio-circle.d.ts +14 -13
  43. package/dist/components/form/radio-group-root.d.ts +88 -0
  44. package/dist/components/form/radio.d.ts +68 -24
  45. package/dist/components/form/select-field.d.ts +78 -0
  46. package/dist/components/form/select.d.ts +30 -42
  47. package/dist/components/form/slider-parts.d.ts +34 -0
  48. package/dist/components/form/slider.d.ts +40 -16
  49. package/dist/components/form/use-autocomplete-labels.d.ts +3 -16
  50. package/dist/components/form/use-blur-outside.d.ts +7 -0
  51. package/dist/components/form/use-focus-target-ref.d.ts +11 -0
  52. package/dist/components/form/use-tooltip-trigger-labels.d.ts +5 -0
  53. package/dist/components/index.d.ts +0 -1
  54. package/dist/components/navigation/form-stepper.d.ts +1 -1
  55. package/dist/components/navigation/index.d.ts +1 -1
  56. package/dist/components/navigation/linear-form-stepper.d.ts +1 -1
  57. package/dist/components/navigation/progress-circle.d.ts +14 -8
  58. package/dist/components/navigation/tabs.d.ts +37 -34
  59. package/dist/components/navigation/use-stepper-labels.d.ts +1 -1
  60. package/dist/components/typography/link.d.ts +25 -16
  61. package/dist/components/typography/lists.d.ts +20 -23
  62. package/dist/components/typography/text.d.ts +46 -10
  63. package/dist/components/ui/app-header.d.ts +9 -1
  64. package/dist/cookie-consent/react.d.ts +0 -1
  65. package/dist/cookie-consent-react.cjs +1 -1
  66. package/dist/cookie-consent-react.cjs.map +1 -1
  67. package/dist/cookie-consent-react.mjs +106 -96
  68. package/dist/cookie-consent-react.mjs.map +1 -1
  69. package/dist/cookie-consent.css +1 -1
  70. package/dist/date-picker/datepicker.d.ts +140 -0
  71. package/dist/date-picker/index.d.ts +18 -0
  72. package/dist/date-picker/theme/field-base.d.ts +23 -0
  73. package/dist/date-picker/theme/form-control.theme.d.ts +7 -0
  74. package/dist/date-picker/theme/index.d.ts +12 -0
  75. package/dist/date-picker/theme/input.theme.d.ts +6 -0
  76. package/dist/{components/form/datepicker → date-picker}/use-view-toggle-labels.d.ts +1 -1
  77. package/dist/date-picker.cjs +2 -0
  78. package/dist/date-picker.cjs.map +1 -0
  79. package/dist/date-picker.mjs +1012 -0
  80. package/dist/date-picker.mjs.map +1 -0
  81. package/dist/{components/dev-panel → dev-panel}/dev-panel-payload.d.ts +1 -1
  82. package/dist/{components/dev-panel → dev-panel}/dev-panel-status.d.ts +2 -2
  83. package/dist/{components/dev-panel → dev-panel}/dev-panel-steps.d.ts +2 -1
  84. package/dist/dev-panel/dev-panel.d.ts +118 -0
  85. package/dist/dev-panel/index.d.ts +10 -0
  86. package/dist/{components/dev-panel → dev-panel}/json-highlight.d.ts +2 -2
  87. package/dist/dev-panel/parts.d.ts +9 -0
  88. package/dist/{components/dev-panel → dev-panel}/segmented-control.d.ts +5 -4
  89. package/dist/{components/dev-panel → dev-panel}/use-dev-panel-labels.d.ts +1 -1
  90. package/dist/{components/dev-panel → dev-panel}/use-roving-radio.d.ts +2 -2
  91. package/dist/dev-panel.cjs +3 -0
  92. package/dist/dev-panel.cjs.map +1 -0
  93. package/dist/dev-panel.css +1 -0
  94. package/dist/dev-panel.mjs +919 -0
  95. package/dist/dev-panel.mjs.map +1 -0
  96. package/dist/fonts/ClashGrotesk-Variable.woff2 +0 -0
  97. package/dist/index.css +1 -1
  98. package/dist/index.d.ts +1 -3
  99. package/dist/provider/lea-provider.d.ts +4 -7
  100. package/dist/react-hook-form/form-field.d.ts +76 -0
  101. package/dist/react-hook-form/index.d.ts +1 -0
  102. package/dist/react-hook-form.cjs +2 -0
  103. package/dist/react-hook-form.cjs.map +1 -0
  104. package/dist/react-hook-form.mjs +33 -0
  105. package/dist/react-hook-form.mjs.map +1 -0
  106. package/dist/tailwind.css +103 -17
  107. package/dist/theme/index.d.ts +0 -4
  108. package/dist/theme/token-types.d.ts +15 -3
  109. package/dist/theme/tokens/colors.d.ts +13 -0
  110. package/dist/theme/tokens/font-family.d.ts +9 -0
  111. package/dist/theme/tokens/font-sizes.d.ts +8 -0
  112. package/dist/theme/tokens/index.d.ts +4 -1
  113. package/dist/theme/tokens/line-heights.d.ts +11 -0
  114. package/dist/theme/tokens/spacing.d.ts +6 -0
  115. package/dist/theme/tokens/text-styles.d.ts +61 -0
  116. package/dist/theme/tokens/type-scale.d.ts +21 -0
  117. package/dist/theme/types.d.ts +19 -30
  118. package/dist/validation/email.d.ts +18 -0
  119. package/dist/validation/mobile-patterns.d.ts +10 -0
  120. package/dist/validation/national-id.d.ts +26 -0
  121. package/dist/validation/phone.d.ts +30 -0
  122. package/package.json +45 -6
  123. package/dist/components/dev-panel/dev-panel.d.ts +0 -61
  124. package/dist/components/dev-panel/index.d.ts +0 -9
  125. package/dist/components/form/datepicker/datepicker.d.ts +0 -99
  126. package/dist/components/form/datepicker/index.d.ts +0 -1
  127. package/dist/components/form/fields/autocomplete-field.d.ts +0 -17
  128. package/dist/components/form/fields/boolean-radio-field.d.ts +0 -3
  129. package/dist/components/form/fields/checkbox-field.d.ts +0 -12
  130. package/dist/components/form/fields/datepicker-field.d.ts +0 -9
  131. package/dist/components/form/fields/email-field.d.ts +0 -10
  132. package/dist/components/form/fields/field-types.d.ts +0 -18
  133. package/dist/components/form/fields/index.d.ts +0 -14
  134. package/dist/components/form/fields/input-field.d.ts +0 -9
  135. package/dist/components/form/fields/multi-select-field.d.ts +0 -9
  136. package/dist/components/form/fields/number-field.d.ts +0 -10
  137. package/dist/components/form/fields/phone-number-field.d.ts +0 -11
  138. package/dist/components/form/fields/radio-card-field.d.ts +0 -22
  139. package/dist/components/form/fields/radio-field.d.ts +0 -16
  140. package/dist/components/form/fields/select-field.d.ts +0 -9
  141. package/dist/components/form/fields/use-field-control.d.ts +0 -6
  142. package/dist/components/form/fields/use-tooltip-trigger-labels.d.ts +0 -5
  143. package/dist/components/form/form-control/form-control-context.d.ts +0 -35
  144. package/dist/components/form/form-control/form-control-label.d.ts +0 -1
  145. package/dist/components/form/form-control/form-control.d.ts +0 -13
  146. package/dist/components/form/form-control/form-helper-text.d.ts +0 -9
  147. package/dist/components/form/form-control/form-label.d.ts +0 -9
  148. package/dist/components/form/form-control/index.d.ts +0 -5
  149. package/dist/components/form/input-label.d.ts +0 -9
  150. package/dist/theme/components/accordion.theme.d.ts +0 -7
  151. package/dist/theme/components/action-button.theme.d.ts +0 -45
  152. package/dist/theme/components/alert.theme.d.ts +0 -2
  153. package/dist/theme/components/autocomplete.theme.d.ts +0 -2
  154. package/dist/theme/components/baseline-css.d.ts +0 -2
  155. package/dist/theme/components/button.theme.d.ts +0 -2
  156. package/dist/theme/components/card.theme.d.ts +0 -2
  157. package/dist/theme/components/checkbox.theme.d.ts +0 -2
  158. package/dist/theme/components/chip.theme.d.ts +0 -2
  159. package/dist/theme/components/dev-panel.theme.d.ts +0 -95
  160. package/dist/theme/components/dialog.theme.d.ts +0 -2
  161. package/dist/theme/components/drawer.theme.d.ts +0 -4
  162. package/dist/theme/components/field-base.d.ts +0 -31
  163. package/dist/theme/components/form-control-label.theme.d.ts +0 -2
  164. package/dist/theme/components/form-control.theme.d.ts +0 -2
  165. package/dist/theme/components/index.d.ts +0 -2
  166. package/dist/theme/components/input.theme.d.ts +0 -3
  167. package/dist/theme/components/link.theme.d.ts +0 -2
  168. package/dist/theme/components/menu-item.theme.d.ts +0 -2
  169. package/dist/theme/components/number-input.theme.d.ts +0 -23
  170. package/dist/theme/components/phone-number-input.theme.d.ts +0 -43
  171. package/dist/theme/components/radio.theme.d.ts +0 -2
  172. package/dist/theme/components/select.theme.d.ts +0 -2
  173. package/dist/theme/components/slider.theme.d.ts +0 -2
  174. package/dist/theme/components/tabs.theme.d.ts +0 -34
  175. package/dist/theme/components/tooltip.theme.d.ts +0 -110
  176. package/dist/theme/components/typography.theme.d.ts +0 -2
  177. package/dist/theme/mui-augmentation.d.ts +0 -147
  178. package/dist/theme/sx-config.d.ts +0 -10
  179. /package/dist/{components/form/datepicker → date-picker}/calendar-header.d.ts +0 -0
  180. /package/dist/{components/form/datepicker → date-picker}/drawer-toolbar.d.ts +0 -0
  181. /package/dist/{theme/components → date-picker/theme}/date-picker.theme.d.ts +0 -0
  182. /package/dist/{theme/components → date-picker/theme}/icon-button.theme.d.ts +0 -0
  183. /package/dist/{theme/tokens → date-picker/theme}/typography.d.ts +0 -0
  184. /package/dist/{components/form/datepicker → date-picker}/use-calendar-header-labels.d.ts +0 -0
  185. /package/dist/{components/form/datepicker → date-picker}/use-datepicker-title-labels.d.ts +0 -0
  186. /package/dist/{components/form/datepicker → date-picker}/view-renderers.d.ts +0 -0
  187. /package/dist/{components/form/datepicker → date-picker}/view-toggle.d.ts +0 -0
  188. /package/dist/{components/dev-panel → dev-panel}/dev-panel-country.d.ts +0 -0
  189. /package/dist/{components/dev-panel → dev-panel}/dev-panel-flow.d.ts +0 -0
  190. /package/dist/{components/dev-panel → dev-panel}/dev-panel-footer.d.ts +0 -0
  191. /package/dist/{components/dev-panel → dev-panel}/dev-panel-step-state.d.ts +0 -0
  192. /package/dist/{components/dev-panel → dev-panel}/dev-panel-variant.d.ts +0 -0
  193. /package/dist/{components/dev-panel → dev-panel}/use-copy.d.ts +0 -0
@@ -11,7 +11,7 @@ export type { AlertColor, AlertProps, AlertSeverity, AlertSize, AlertVariant, }
11
11
  * name — override it per-instance with `closeLabel`.
12
12
  *
13
13
  * ```tsx
14
- * <Alert color="purple" size="sm">
14
+ * <Alert color="primary" size="sm">
15
15
  * Lånet forutsetter at du løser skulder for totalt 80 000 kr.
16
16
  * </Alert>
17
17
  * ```
@@ -33,7 +33,7 @@ export type SimpleDialogProps = Omit<Dialog.RootProps, "children"> & {
33
33
  * title="Update your details"
34
34
  * description="Keep your contact information up to date."
35
35
  * >
36
- * <TextField label="Phone" />
36
+ * <Input label="Phone" />
37
37
  * </SimpleDialog>
38
38
  * ```
39
39
  */
@@ -0,0 +1,68 @@
1
+ import { ComponentPropsWithRef, ReactNode } from 'react';
2
+ export type AmountSliderProps = Omit<ComponentPropsWithRef<"div">, "children" | "defaultValue" | "onChange"> & {
3
+ /**
4
+ * The question above the amount, e.g. "Hur mycket vill du låna?". It labels
5
+ * the amount field and names the slider, so it is required.
6
+ */
7
+ label: ReactNode;
8
+ /** The lowest amount that can be chosen. */
9
+ min: number;
10
+ /** The highest amount that can be chosen. */
11
+ max: number;
12
+ /**
13
+ * How far the slider, and the arrow keys in the amount field, move the
14
+ * amount. A typed amount is kept as typed, also between two steps.
15
+ * @default 1
16
+ */
17
+ step?: number;
18
+ /** The amount. Use with `onValueChange` to control the component. */
19
+ value?: number;
20
+ /**
21
+ * The amount when first rendered, for uncontrolled use.
22
+ * @default min
23
+ */
24
+ defaultValue?: number;
25
+ /**
26
+ * Called with the new amount when the slider moves, and when an amount
27
+ * within `min` and `max` is typed.
28
+ */
29
+ onValueChange?: (value: number) => void;
30
+ /** How the amount, `min` and `max` are written, e.g. as a currency. */
31
+ format?: Intl.NumberFormatOptions;
32
+ /** The locale the amount is written and typed in. Defaults to the runtime locale. */
33
+ locale?: Intl.LocalesArgument;
34
+ /** Submits the amount under this name when inside a form. */
35
+ name?: string;
36
+ /** Disables both the amount field and the slider. */
37
+ disabled?: boolean;
38
+ /** Helper / error text shown below the slider and linked via `aria-describedby`. */
39
+ helperText?: ReactNode;
40
+ /** Puts the amount field, the slider and the helper text into the error state. */
41
+ error?: boolean;
42
+ };
43
+ /**
44
+ * An amount chosen by dragging a slider or by typing it, for questions like
45
+ * "how much do you want to borrow?". The amount field and the slider share one
46
+ * value: moving the slider rewrites the amount, and typing moves the thumb.
47
+ *
48
+ * The `label` is a real `<label>` for the amount field and also names the
49
+ * slider, and the helper text describes both. A typed amount outside `min`
50
+ * and `max` is brought back into range when the field loses focus, and an
51
+ * emptied field goes back to the last amount.
52
+ *
53
+ * Use `Slider` instead when the value does not need to be typed.
54
+ *
55
+ * ```tsx
56
+ * <AmountSlider
57
+ * label="Hur mycket vill du låna?"
58
+ * min={20000}
59
+ * max={600000}
60
+ * step={5000}
61
+ * defaultValue={200000}
62
+ * locale="sv-SE"
63
+ * format={{ style: "currency", currency: "SEK", maximumFractionDigits: 0 }}
64
+ * onValueChange={(amount) => setAmount(amount)}
65
+ * />
66
+ * ```
67
+ */
68
+ export declare function AmountSlider({ label, min, max, step, value: valueProp, defaultValue, onValueChange, format, locale, name, disabled, helperText, error, className, ...rest }: AmountSliderProps): import("react").JSX.Element;
@@ -1,71 +1,68 @@
1
- import { AutocompleteProps as MuiAutocompleteProps } from '@mui/material';
2
- import { ReactNode } from 'react';
3
- import { SelectOption } from './select';
4
- type AutocompleteOption = SelectOption | string;
5
- /** MUI props we forward untouched (free-solo so both modes type-check). */
6
- type ForwardedMuiProps = Omit<MuiAutocompleteProps<AutocompleteOption, false, false, true>, "ref" | "renderInput" | "renderValue" | "options" | "value" | "defaultValue" | "onChange" | "onInputChange" | "inputValue" | "freeSolo" | "multiple" | "getOptionLabel" | "getOptionDisabled" | "isOptionEqualToValue" | "filterOptions">;
7
- type AutocompleteBaseProps = ForwardedMuiProps & {
8
- /** Floating label. Rendered as an `InputLabel` and linked automatically. */
9
- label?: ReactNode;
10
- /** Helper / error text shown below the control and linked via `aria-describedby`. */
11
- helperText?: ReactNode;
12
- /** Searchable options. Ignored in `email` mode, where suggestions are derived from the input. */
13
- options?: SelectOption[];
14
- /** Puts the control in an error state. */
15
- error?: boolean;
16
- /** Marks the control as required. */
17
- required?: boolean;
18
- /** Placeholder shown in the text input. */
19
- placeholder?: string;
20
- };
21
- type AutocompleteSingleProps = {
22
- /** Enable selecting multiple values. Omit (or `false`) for single-select. */
23
- multiple?: false;
24
- /** Selected value (controlled). */
25
- value?: string;
26
- /** Initial value (uncontrolled). */
27
- defaultValue?: string;
28
- /** Called with the next string value. */
29
- onChange?: (value: string) => void;
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { ComboFieldBaseProps } from './combo-field';
3
+ import { SelectOption } from './select-field';
4
+ type AutocompleteBaseProps<Value extends string> = ComboFieldBaseProps & {
5
+ /** The choices. Typing filters them by their label. */
6
+ options: readonly SelectOption<Value>[];
7
+ /** Shown in the list when nothing matches. Translated by default. */
8
+ noOptionsText?: ReactNode;
30
9
  /**
31
- * Email mode: lets the user type freely and, once they type `@`, suggests
32
- * completions from common providers (gmail, outlook, …).
10
+ * Whether the options are on their way. While there are none to show, the
11
+ * list says so instead of "no options".
33
12
  */
34
- email?: boolean;
35
- /** Domains offered in `email` mode. @default COMMON_EMAIL_DOMAINS */
36
- domains?: readonly string[];
37
- /** Maximum number of email suggestions to show. @default 6 */
38
- maxSuggestions?: number;
13
+ loading?: boolean;
39
14
  };
40
- type AutocompleteMultipleProps = {
41
- /** Enable selecting multiple values, rendered as removable chips. */
15
+ type SingleValueProps<Value extends string> = {
16
+ /** Choose several values, shown as chips. */
17
+ multiple?: false;
18
+ /** The chosen value (controlled). `""` means nothing is chosen. */
19
+ value?: Value | "";
20
+ /** The chosen value when first rendered, for uncontrolled use. */
21
+ defaultValue?: Value | "";
22
+ /** Called with the chosen value, or `""` when the control is emptied. */
23
+ onValueChange?: (value: Value | "") => void;
24
+ };
25
+ type MultipleValueProps<Value extends string> = {
26
+ /** Choose several values, shown as chips. */
42
27
  multiple: true;
43
- /** Currently selected values (controlled). */
44
- value?: string[];
45
- /** Initially selected values (uncontrolled). */
46
- defaultValue?: string[];
47
- /** Called with the next array of selected values. */
48
- onChange?: (value: string[]) => void;
49
- /** Minimum number of values that must stay selected. @default 1 */
28
+ /** The chosen values (controlled). */
29
+ value?: Value[];
30
+ /** The chosen values when first rendered, for uncontrolled use. */
31
+ defaultValue?: Value[];
32
+ /** Called with the next array of chosen values. */
33
+ onValueChange?: (value: Value[]) => void;
34
+ /** Fewest values that must stay chosen. @default 1 */
50
35
  min?: number;
51
- /** Maximum number of values that can be selected. Unlimited when omitted. */
36
+ /** Most values that can be chosen. Unlimited when omitted. */
52
37
  max?: number;
53
38
  };
54
- export type AutocompleteProps = AutocompleteBaseProps & (AutocompleteSingleProps | AutocompleteMultipleProps);
39
+ type AutocompleteSingleProps<Value extends string = string> = AutocompleteBaseProps<Value> & SingleValueProps<Value>;
40
+ type AutocompleteMultipleProps<Value extends string = string> = AutocompleteBaseProps<Value> & MultipleValueProps<Value>;
41
+ export type AutocompleteProps<Value extends string = string> = AutocompleteSingleProps<Value> | AutocompleteMultipleProps<Value>;
55
42
  /**
56
- * Searchable select built on MUI's `Autocomplete`.
43
+ * A select to search in, on Base UI's `Combobox`, in the same box as `Input`.
44
+ * Typing filters the options. The label, the helper text and the ids that
45
+ * link them to the input are all rendered and wired for you.
46
+ *
47
+ * ```tsx
48
+ * <Autocomplete
49
+ * label="Land"
50
+ * options={[
51
+ * { value: "no", label: "Norge" },
52
+ * { value: "se", label: "Sverige" },
53
+ * ]}
54
+ * value={country}
55
+ * onValueChange={setCountry}
56
+ * />
57
+ * ```
57
58
  *
58
- * Works two ways:
59
- * - **Standalone (all-in-one):** pass `label` / `helperText` and `options` and
60
- * it renders its own `FormControl`, label and helper text, generating and
61
- * wiring all ids for you.
62
- * - **Composed:** drop it inside a `FormControl` next to `InputLabel` /
63
- * `FormHelperText` and it picks up the shared ids from context.
59
+ * Values are strings, typed from the options as in `Select`, and `""` means
60
+ * nothing is chosen. Pass `multiple` to choose several: they show as chips
61
+ * inside the field, bounded by `min` (default 1) and `max`.
64
62
  *
65
- * Pass `multiple` to select several values at once, shown as removable chips and
66
- * bounded by `min` (default 1) and `max`. Pass `email` (single mode only) to
67
- * turn it into an email field that suggests common domains once the user types
68
- * `@` — the same autocomplete behaviour, driven by free text.
63
+ * For an email address with suggested domains, use `EmailInput`.
69
64
  */
70
- export declare const Autocomplete: import('react').ForwardRefExoticComponent<AutocompleteProps & import('react').RefAttributes<HTMLDivElement>>;
65
+ export declare function Autocomplete<Value extends string = string>(props: AutocompleteMultipleProps<Value>): ReactElement;
66
+ export declare function Autocomplete<Value extends string = string>(props: AutocompleteSingleProps<Value>): ReactElement;
67
+ export declare function Autocomplete<Value extends string = string>(props: AutocompleteProps<Value>): ReactElement;
71
68
  export {};
@@ -0,0 +1,11 @@
1
+ /** The tick. It is drawn in by a transition when its box becomes checked. */
2
+ export declare const checkboxTick: import("react").JSX.Element;
3
+ /**
4
+ * Internal. The checkbox box as a picture only, for places where something
5
+ * else is the control: `MultiSelect` shows it inside each option, and the
6
+ * option is what gets picked. It looks exactly like `Checkbox`, which uses
7
+ * the same class on the real control.
8
+ */
9
+ export declare const CheckboxBox: ({ checked }: {
10
+ checked: boolean;
11
+ }) => import("react").JSX.Element;
@@ -1,12 +1,72 @@
1
- import { CheckboxProps as MuiCheckboxProps } from '@mui/material';
2
- export type CheckboxProps = Omit<MuiCheckboxProps, "color" | "size">;
1
+ import { CSSProperties, FocusEventHandler, ReactNode, Ref } from 'react';
3
2
  /**
4
- * Checkbox built on MUI's `Checkbox`, styled by the global theme
5
- * (`checkbox.theme.tsx`). Kept composite — pair it with `FormControlLabel` for a
6
- * label instead of forwarding label / typography props:
3
+ * Requires an accessible name so the checkbox is never nameless. Provide a
4
+ * visible `label`, or an `aria-label` / `aria-labelledby` when the design has
5
+ * none (a row in a table, say).
6
+ */
7
+ type CheckboxAccessibleName = {
8
+ label: ReactNode;
9
+ "aria-label"?: never;
10
+ "aria-labelledby"?: never;
11
+ } | {
12
+ label?: never;
13
+ "aria-label": string;
14
+ "aria-labelledby"?: never;
15
+ } | {
16
+ label?: never;
17
+ "aria-label"?: never;
18
+ "aria-labelledby": string;
19
+ };
20
+ export type CheckboxProps = CheckboxAccessibleName & {
21
+ /** Whether the box is ticked (controlled). Pair with `onCheckedChange`. */
22
+ checked?: boolean;
23
+ /** Whether the box is ticked when first rendered, for uncontrolled use. */
24
+ defaultChecked?: boolean;
25
+ /** Called with the new state when the box is ticked or cleared. */
26
+ onCheckedChange?: (checked: boolean) => void;
27
+ /** Helper / error text shown below the checkbox and linked via `aria-describedby`. */
28
+ helperText?: ReactNode;
29
+ /** Puts the checkbox and its helper text into the error state. */
30
+ error?: boolean;
31
+ /** Submits the checkbox under this name when inside a form. */
32
+ name?: string;
33
+ /** The value submitted when ticked. The browser default is `"on"`. */
34
+ value?: string;
35
+ /** Disables the checkbox. */
36
+ disabled?: boolean;
37
+ /** Marks the checkbox as required and adds the asterisk to the label. */
38
+ required?: boolean;
39
+ /** Id of the checkbox itself, the element with the `checkbox` role. */
40
+ id?: string;
41
+ onBlur?: FocusEventHandler<HTMLElement>;
42
+ onFocus?: FocusEventHandler<HTMLElement>;
43
+ /** Extra ids describing the checkbox, alongside the helper text. */
44
+ "aria-describedby"?: string;
45
+ /** Class on the outermost element, for layout. */
46
+ className?: string;
47
+ /** Inline style on the outermost element, for layout. */
48
+ style?: CSSProperties;
49
+ /**
50
+ * The `<input type="checkbox">` that holds the value. It is hidden, but
51
+ * `ref.current.focus()` moves focus to the visible box.
52
+ */
53
+ ref?: Ref<HTMLInputElement>;
54
+ };
55
+ /**
56
+ * Checkbox with its label, helper text and error state built in, on Base UI's
57
+ * accessible `Checkbox` primitive.
58
+ *
59
+ * Pass `label` for the text next to the box; it is a real `<label>`, so
60
+ * clicking it ticks the box. Without a visible label, pass `aria-label`.
61
+ * `className` and `style` go on the outermost element.
7
62
  *
8
63
  * ```tsx
9
- * <FormControlLabel control={<Checkbox />} label="Label" />
64
+ * <Checkbox
65
+ * label="Jeg godtar vilkårene"
66
+ * checked={accepted}
67
+ * onCheckedChange={setAccepted}
68
+ * />
10
69
  * ```
11
70
  */
12
- export declare const Checkbox: import('react').ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
71
+ export declare function Checkbox({ label, helperText, error, checked, defaultChecked, onCheckedChange, name, value, disabled, required, id, onBlur, onFocus, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className, style, ref, }: CheckboxProps): import("react").JSX.Element;
72
+ export {};
@@ -0,0 +1,68 @@
1
+ import { CSSProperties, FocusEvent, InputHTMLAttributes, ReactNode, Ref } from 'react';
2
+ /** The props `Autocomplete` and `EmailInput` have in common. */
3
+ export type ComboFieldBaseProps = {
4
+ /** Floating label, linked to the input for you. */
5
+ label?: ReactNode;
6
+ /** Helper / error text shown below the control and linked via `aria-describedby`. */
7
+ helperText?: ReactNode;
8
+ /** Puts the control, its label and its helper text into the error state. */
9
+ error?: boolean;
10
+ /**
11
+ * A message for a value that is allowed but unusual, such as an unusually
12
+ * high amount. Shown in amber in place of the helper text, without the
13
+ * error state: the field is not marked invalid. `error` wins when both are set.
14
+ */
15
+ warning?: ReactNode;
16
+ /** Marks the control as required, with an asterisk after the label. */
17
+ required?: boolean;
18
+ disabled?: boolean;
19
+ /**
20
+ * Text shown while the input is empty. With a `label` it appears once the
21
+ * label has floated up, on focus.
22
+ */
23
+ placeholder?: string;
24
+ /** Called when focus leaves the control, its list included. */
25
+ onBlur?: (event: FocusEvent<HTMLElement>) => void;
26
+ /** Submits the value under this name in a native form. */
27
+ name?: string;
28
+ /** Id of the text `<input>`. */
29
+ id?: string;
30
+ /** Names the control when there is no visible `label`. */
31
+ "aria-label"?: string;
32
+ "aria-labelledby"?: string;
33
+ "aria-describedby"?: string;
34
+ /** Class on the outermost element, for layout. */
35
+ className?: string;
36
+ /** Inline style on the outermost element, for layout. */
37
+ style?: CSSProperties;
38
+ /** The text `<input>`. */
39
+ ref?: Ref<HTMLInputElement>;
40
+ };
41
+ type ComboFieldProps = Omit<ComboFieldBaseProps, "name"> & {
42
+ /** Wraps the field and its popup in the Base UI root that drives them. */
43
+ renderRoot: (children: ReactNode) => ReactNode;
44
+ /** More attributes for the `<input>`: `type`, `name`, `autoComplete`, … */
45
+ inputProps?: InputHTMLAttributes<HTMLInputElement>;
46
+ /**
47
+ * The chosen values of a multiple control, as `Combobox.Chip`s. They share
48
+ * the field with the input and wrap onto new lines.
49
+ */
50
+ chips?: ReactNode;
51
+ /** Whether a multiple control has values, which is what floats its label. */
52
+ filled?: boolean;
53
+ /** Shows the button that empties the control, while there is something to empty. */
54
+ clearable?: boolean;
55
+ /** Shows the arrow button that opens and closes the list. */
56
+ trigger?: boolean;
57
+ /**
58
+ * Selects the text on the first click into the input, so that typing
59
+ * replaces it. For a control whose text is the label of the chosen option.
60
+ */
61
+ selectTextOnClick?: boolean;
62
+ /** The content of the popup: the list, and what stands in for it when empty. */
63
+ children: ReactNode;
64
+ /** More below the helper text, inside the outermost element. */
65
+ afterHelperText?: ReactNode;
66
+ };
67
+ export declare function ComboField({ label, helperText, error, warning, required, disabled, placeholder, onBlur, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className, style, ref, renderRoot, inputProps, chips, filled, clearable, trigger, selectTextOnClick, children, afterHelperText, }: ComboFieldProps): import("react").JSX.Element;
68
+ export {};
@@ -1,35 +1,37 @@
1
- import { FocusEventHandler, ReactNode } from 'react';
2
- export type EmailInputProps = {
3
- /** Current value (controlled). */
1
+ import { ComboFieldBaseProps } from './combo-field';
2
+ export type EmailInputProps = ComboFieldBaseProps & {
3
+ /** The address (controlled). Pair with `onValueChange`. */
4
4
  value?: string;
5
- /** Initial value (uncontrolled). */
5
+ /** The address when first rendered, for uncontrolled use. */
6
6
  defaultValue?: string;
7
- /** Called with the next string value. */
8
- onChange?: (value: string) => void;
7
+ /** Called with the new text on every change, and with a suggestion when one is picked. */
8
+ onValueChange?: (value: string) => void;
9
9
  /** Domains offered once the user types `@`. Defaults to common providers. */
10
10
  domains?: readonly string[];
11
- /** Maximum number of suggestions to show. @default 6 */
11
+ /** Most suggestions shown at once. @default 6 */
12
12
  maxSuggestions?: number;
13
- /** Floating label. Rendered as an `InputLabel` and linked automatically. */
14
- label?: ReactNode;
15
- /** Helper / error text shown below the control and linked via `aria-describedby`. */
16
- helperText?: ReactNode;
17
- /** Placeholder shown in the text input. */
18
- placeholder?: string;
19
- /** Puts the control in an error state. */
20
- error?: boolean;
21
- /** Marks the control as required. */
22
- required?: boolean;
23
- /** Disables the control. */
24
- disabled?: boolean;
25
- /** Blur handler (e.g. for react-hook-form touched state). */
26
- onBlur?: FocusEventHandler<HTMLDivElement>;
13
+ /**
14
+ * When focus leaves the field, offers a fix for a mistyped domain below it:
15
+ * "Mente du anna@gmail.com?" for `anna@gnail.con`, with the address as a
16
+ * button that puts it in the field. The value never changes by itself, and
17
+ * validation is not affected. See `suggestEmailCorrection`.
18
+ * @default true
19
+ */
20
+ suggestCorrection?: boolean;
21
+ /**
22
+ * What the browser may fill in. The default lets it offer the user's own
23
+ * address; pass `"off"` when the address is somebody else's.
24
+ * @default "email"
25
+ */
26
+ autoComplete?: string;
27
27
  };
28
28
  /**
29
- * Email text field that suggests common domains in a dropdown once the user
30
- * types `@`. Works controlled (`value` + `onChange`) or uncontrolled
31
- * (`defaultValue`), standalone (`label` / `helperText`) or inside a
32
- * `FormControl`.
29
+ * Email text field that suggests common domains in a list once the user
30
+ * types `@`, on Base UI's `Autocomplete`, in the same box as `Input`. The
31
+ * text is the value: a suggestion only saves typing.
33
32
  *
33
+ * ```tsx
34
+ * <EmailInput label="E-post" value={email} onValueChange={setEmail} />
35
+ * ```
34
36
  */
35
- export declare const EmailInput: import('react').ForwardRefExoticComponent<EmailInputProps & import('react').RefAttributes<HTMLDivElement>>;
37
+ export declare function EmailInput({ value, defaultValue, onValueChange, domains, maxSuggestions, autoComplete, suggestCorrection, name, onBlur, ref, ...field }: EmailInputProps): import("react").JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { ReactNode } from 'react';
2
+ /** The ` *` after the label of a required control. Decorative: `required` is on the control. */
3
+ export declare const RequiredAsterisk: ({ className }: {
4
+ className?: string;
5
+ }) => import("react").JSX.Element;
6
+ type FieldHelperTextProps = {
7
+ /** Id the control points at with `aria-describedby`. */
8
+ id: string;
9
+ error: boolean;
10
+ /** The text is a warning: amber, and announced politely. */
11
+ warning?: boolean;
12
+ children: ReactNode;
13
+ };
14
+ /**
15
+ * Helper text below a control. Announced as an alert while in error, and as a
16
+ * status while it is a warning.
17
+ */
18
+ export declare function FieldHelperText({ id, error, warning, children, }: FieldHelperTextProps): import("react").JSX.Element;
19
+ /**
20
+ * What the line below a control shows: the warning while there is one,
21
+ * otherwise the helper text. An error wins over a warning, so with `error`
22
+ * the line is the helper text (where a form puts its error message).
23
+ */
24
+ export declare function fieldMessage(helperText: ReactNode, warning: ReactNode, error: boolean): {
25
+ content: ReactNode;
26
+ warning: boolean;
27
+ };
28
+ type FieldGroupLabelProps = {
29
+ /** Id the group points at with `aria-labelledby`. It sits on the text alone. */
30
+ id: string;
31
+ /**
32
+ * Id of a single control this labels. The text is then a real `<label>`, so
33
+ * a click on it moves focus to the control.
34
+ */
35
+ htmlFor?: string;
36
+ /** Help text behind an info button next to the label. */
37
+ tooltip?: ReactNode;
38
+ required?: boolean;
39
+ error?: boolean;
40
+ disabled?: boolean;
41
+ children: ReactNode;
42
+ };
43
+ /**
44
+ * The label above a group of choices, or above a field whose label sits
45
+ * outside it. The element is not a `<label>`: it names its control through
46
+ * `aria-labelledby`, and a `<label>` around the info button would pass clicks
47
+ * on the text to that button. With `htmlFor`, the text alone is a `<label>`.
48
+ */
49
+ export declare function FieldGroupLabel({ id, htmlFor, tooltip, required, error, disabled, children, }: FieldGroupLabelProps): import("react").JSX.Element;
50
+ export {};
@@ -1,19 +1,13 @@
1
+ export * from './amount-slider';
1
2
  export * from './autocomplete';
2
3
  export * from './checkbox';
3
- export * from './datepicker';
4
4
  export * from './email-input';
5
- export * from './fields';
6
- export * from './form-control';
7
- export * from './form-control/form-helper-text';
8
5
  export * from './input';
9
- export * from './input-label';
10
6
  export * from './multi-select';
11
7
  export * from './number-input';
12
8
  export * from './phone-number-input';
13
- export * from './radio';
14
- export * from './radio-card';
15
- export * from './radio-circle';
9
+ export * as RadioGroup from './radio';
10
+ export * as RadioCard from './radio-card';
16
11
  export * from './select';
17
12
  export * from './slider';
18
13
  export * from './switch';
19
- export { FormControlLabel, InputAdornment, type FormControlLabelProps, type InputAdornmentProps, } from '@mui/material';
@@ -1,19 +1,63 @@
1
- import { OutlinedInputProps } from '@mui/material';
2
- import { ReactNode } from 'react';
3
- export type InputProps = OutlinedInputProps & {
4
- /** Floating label. Rendered as an `InputLabel` and linked automatically. */
1
+ import { ComponentPropsWithoutRef, CSSProperties, ReactNode, Ref } from 'react';
2
+ type NativeInputProps = Omit<ComponentPropsWithoutRef<"input">, "value" | "defaultValue" | "size" | "color" | "children" | "className" | "style">;
3
+ export type InputProps = NativeInputProps & {
4
+ /** Floating label, linked to the input for you. */
5
5
  label?: ReactNode;
6
- /** Helper / error text shown below the control and linked via `aria-describedby`. */
6
+ /** Helper / error text shown below the input and linked via `aria-describedby`. */
7
7
  helperText?: ReactNode;
8
+ /** Puts the input, its label and its helper text into the error state. */
9
+ error?: boolean;
10
+ /**
11
+ * A message for a value that is allowed but unusual, such as an unusually
12
+ * high amount. Shown in amber in place of the helper text, without the
13
+ * error state: the field is not marked invalid. `error` wins when both are set.
14
+ */
15
+ warning?: ReactNode;
16
+ /** The text (controlled). Pair with `onValueChange`. */
17
+ value?: string;
18
+ /** The text when first rendered, for uncontrolled use. */
19
+ defaultValue?: string;
20
+ /** Called with the new text on every change. `onChange` still gets the event. */
21
+ onValueChange?: (value: string) => void;
22
+ /** Content before the text, inside the field, e.g. an icon. */
23
+ startAdornment?: ReactNode;
24
+ /** Content after the text, inside the field, e.g. a show / hide button. */
25
+ endAdornment?: ReactNode;
26
+ /**
27
+ * Renders a `<textarea>` that grows with its content. The native attributes
28
+ * and event handlers then apply to the textarea.
29
+ */
30
+ multiline?: boolean;
31
+ /** Fixed number of rows when `multiline`. */
32
+ rows?: number;
33
+ /** Fewest rows shown when `multiline`. */
34
+ minRows?: number;
35
+ /** Most rows shown when `multiline`, before it scrolls. */
36
+ maxRows?: number;
37
+ /** Class on the outermost element, for layout. */
38
+ className?: string;
39
+ /** Inline style on the outermost element, for layout. */
40
+ style?: CSSProperties;
41
+ /** The `<input>`, or the `<textarea>` when `multiline`. */
42
+ ref?: Ref<HTMLInputElement | HTMLTextAreaElement>;
8
43
  };
9
44
  /**
10
- * Text input built on MUI's `OutlinedInput`.
45
+ * Text input, on Base UI's `Input` primitive. The label, the helper text and
46
+ * the ids that link them to the input are all rendered and wired for you.
11
47
  *
12
- * Works two ways:
13
- * - **Standalone (all-in-one):** pass `label` / `helperText` and it renders its
14
- * own `FormControl`, label and helper text, generating and wiring all ids for
15
- * you. Pass `multiline` (+ `minRows`) for a textarea.
16
- * - **Composed:** drop it inside a `FormControl` next to `InputLabel` /
17
- * `FormHelperText` and it picks up the shared ids from context.
48
+ * Takes the native `<input>` attributes (`type`, `name`, `placeholder`,
49
+ * `autoComplete`, `inputMode`, `maxLength`, `onKeyDown`, …), which land on the
50
+ * input itself. `className` and `style` go on the outermost element. Pass
51
+ * `multiline` (and `minRows`) for a textarea.
52
+ *
53
+ * ```tsx
54
+ * <Input
55
+ * label="E-post"
56
+ * helperText="Vi deler den aldri."
57
+ * value={email}
58
+ * onValueChange={setEmail}
59
+ * />
60
+ * ```
18
61
  */
19
- export declare const Input: import('react').ForwardRefExoticComponent<Omit<InputProps, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
62
+ export declare function Input({ label, helperText, error, warning, value, defaultValue, onValueChange, startAdornment, endAdornment, multiline, rows, minRows, maxRows, className, style, ref, id, disabled, required, placeholder, "aria-describedby": ariaDescribedBy, ...inputAttributes }: InputProps): import("react").JSX.Element;
63
+ export {};