@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.
- package/CHANGELOG.md +745 -0
- package/README.md +2 -5
- package/dist/component-library.es.js +2948 -5676
- package/dist/component-library.es.js.map +1 -1
- package/dist/component-library.umd.js +2 -28
- package/dist/component-library.umd.js.map +1 -1
- package/dist/components/animations/icons/status-icon.d.ts +4 -0
- package/dist/components/animations/illustrations/check-animation.d.ts +8 -0
- package/dist/components/animations/illustrations/pulse-animation.d.ts +5 -1
- package/dist/components/animations/illustrations/status-animation.d.ts +8 -1
- package/dist/components/animations/shared.d.ts +6 -32
- package/dist/components/animations/spinner.d.ts +18 -0
- package/dist/components/animations/use-animation-labels.d.ts +0 -5
- package/dist/components/buttons/action-button.d.ts +8 -10
- package/dist/components/buttons/button-base.d.ts +26 -12
- package/dist/components/buttons/button.d.ts +2 -2
- package/dist/components/buttons/close-button.d.ts +1 -1
- package/dist/components/buttons/icon-button.d.ts +1 -13
- package/dist/components/buttons/skip-link.d.ts +21 -4
- package/dist/components/color-roles.d.ts +8 -0
- package/dist/components/data-display/card.d.ts +54 -4
- package/dist/components/data-display/chip.d.ts +50 -8
- package/dist/components/data-display/data-field.d.ts +15 -4
- package/dist/components/data-display/tooltip.d.ts +74 -22
- package/dist/components/feedback/alert-parts.d.ts +10 -9
- package/dist/components/feedback/alert.d.ts +1 -1
- package/dist/components/feedback/simple-dialog.d.ts +1 -1
- package/dist/components/form/amount-slider.d.ts +68 -0
- package/dist/components/form/autocomplete.d.ts +56 -59
- package/dist/components/form/checkbox-box.d.ts +11 -0
- package/dist/components/form/checkbox.d.ts +67 -7
- package/dist/components/form/combo-field.d.ts +68 -0
- package/dist/components/form/email-input.d.ts +28 -26
- package/dist/components/form/field-parts.d.ts +50 -0
- package/dist/components/form/index.d.ts +3 -9
- package/dist/components/form/input.d.ts +57 -13
- package/dist/components/form/multi-select.d.ts +12 -14
- package/dist/components/form/number-input-unit.d.ts +28 -0
- package/dist/components/form/number-input.d.ts +46 -18
- package/dist/components/form/phone-number-input/phone-number-input.d.ts +44 -14
- package/dist/components/form/radio-card.d.ts +94 -43
- package/dist/components/form/radio-circle.d.ts +14 -13
- package/dist/components/form/radio-group-root.d.ts +88 -0
- package/dist/components/form/radio.d.ts +68 -24
- package/dist/components/form/select-field.d.ts +78 -0
- package/dist/components/form/select.d.ts +30 -42
- package/dist/components/form/slider-parts.d.ts +34 -0
- package/dist/components/form/slider.d.ts +40 -16
- package/dist/components/form/use-autocomplete-labels.d.ts +3 -16
- package/dist/components/form/use-blur-outside.d.ts +7 -0
- package/dist/components/form/use-focus-target-ref.d.ts +11 -0
- package/dist/components/form/use-tooltip-trigger-labels.d.ts +5 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/components/navigation/form-stepper.d.ts +1 -1
- package/dist/components/navigation/index.d.ts +1 -1
- package/dist/components/navigation/linear-form-stepper.d.ts +1 -1
- package/dist/components/navigation/progress-circle.d.ts +14 -8
- package/dist/components/navigation/tabs.d.ts +37 -34
- package/dist/components/navigation/use-stepper-labels.d.ts +1 -1
- package/dist/components/typography/link.d.ts +25 -16
- package/dist/components/typography/lists.d.ts +20 -23
- package/dist/components/typography/text.d.ts +46 -10
- package/dist/components/ui/app-header.d.ts +9 -1
- package/dist/cookie-consent/react.d.ts +0 -1
- package/dist/cookie-consent-react.cjs +1 -1
- package/dist/cookie-consent-react.cjs.map +1 -1
- package/dist/cookie-consent-react.mjs +106 -96
- package/dist/cookie-consent-react.mjs.map +1 -1
- package/dist/cookie-consent.css +1 -1
- package/dist/date-picker/datepicker.d.ts +140 -0
- package/dist/date-picker/index.d.ts +18 -0
- package/dist/date-picker/theme/field-base.d.ts +23 -0
- package/dist/date-picker/theme/form-control.theme.d.ts +7 -0
- package/dist/date-picker/theme/index.d.ts +12 -0
- package/dist/date-picker/theme/input.theme.d.ts +6 -0
- package/dist/{components/form/datepicker → date-picker}/use-view-toggle-labels.d.ts +1 -1
- package/dist/date-picker.cjs +2 -0
- package/dist/date-picker.cjs.map +1 -0
- package/dist/date-picker.mjs +1012 -0
- package/dist/date-picker.mjs.map +1 -0
- package/dist/{components/dev-panel → dev-panel}/dev-panel-payload.d.ts +1 -1
- package/dist/{components/dev-panel → dev-panel}/dev-panel-status.d.ts +2 -2
- package/dist/{components/dev-panel → dev-panel}/dev-panel-steps.d.ts +2 -1
- package/dist/dev-panel/dev-panel.d.ts +118 -0
- package/dist/dev-panel/index.d.ts +10 -0
- package/dist/{components/dev-panel → dev-panel}/json-highlight.d.ts +2 -2
- package/dist/dev-panel/parts.d.ts +9 -0
- package/dist/{components/dev-panel → dev-panel}/segmented-control.d.ts +5 -4
- package/dist/{components/dev-panel → dev-panel}/use-dev-panel-labels.d.ts +1 -1
- package/dist/{components/dev-panel → dev-panel}/use-roving-radio.d.ts +2 -2
- package/dist/dev-panel.cjs +3 -0
- package/dist/dev-panel.cjs.map +1 -0
- package/dist/dev-panel.css +1 -0
- package/dist/dev-panel.mjs +919 -0
- package/dist/dev-panel.mjs.map +1 -0
- package/dist/fonts/ClashGrotesk-Variable.woff2 +0 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/provider/lea-provider.d.ts +4 -7
- package/dist/react-hook-form/form-field.d.ts +76 -0
- package/dist/react-hook-form/index.d.ts +1 -0
- package/dist/react-hook-form.cjs +2 -0
- package/dist/react-hook-form.cjs.map +1 -0
- package/dist/react-hook-form.mjs +33 -0
- package/dist/react-hook-form.mjs.map +1 -0
- package/dist/tailwind.css +103 -17
- package/dist/theme/index.d.ts +0 -4
- package/dist/theme/token-types.d.ts +15 -3
- package/dist/theme/tokens/colors.d.ts +13 -0
- package/dist/theme/tokens/font-family.d.ts +9 -0
- package/dist/theme/tokens/font-sizes.d.ts +8 -0
- package/dist/theme/tokens/index.d.ts +4 -1
- package/dist/theme/tokens/line-heights.d.ts +11 -0
- package/dist/theme/tokens/spacing.d.ts +6 -0
- package/dist/theme/tokens/text-styles.d.ts +61 -0
- package/dist/theme/tokens/type-scale.d.ts +21 -0
- package/dist/theme/types.d.ts +19 -30
- package/dist/validation/email.d.ts +18 -0
- package/dist/validation/mobile-patterns.d.ts +10 -0
- package/dist/validation/national-id.d.ts +26 -0
- package/dist/validation/phone.d.ts +30 -0
- package/package.json +45 -6
- package/dist/components/dev-panel/dev-panel.d.ts +0 -61
- package/dist/components/dev-panel/index.d.ts +0 -9
- package/dist/components/form/datepicker/datepicker.d.ts +0 -99
- package/dist/components/form/datepicker/index.d.ts +0 -1
- package/dist/components/form/fields/autocomplete-field.d.ts +0 -17
- package/dist/components/form/fields/boolean-radio-field.d.ts +0 -3
- package/dist/components/form/fields/checkbox-field.d.ts +0 -12
- package/dist/components/form/fields/datepicker-field.d.ts +0 -9
- package/dist/components/form/fields/email-field.d.ts +0 -10
- package/dist/components/form/fields/field-types.d.ts +0 -18
- package/dist/components/form/fields/index.d.ts +0 -14
- package/dist/components/form/fields/input-field.d.ts +0 -9
- package/dist/components/form/fields/multi-select-field.d.ts +0 -9
- package/dist/components/form/fields/number-field.d.ts +0 -10
- package/dist/components/form/fields/phone-number-field.d.ts +0 -11
- package/dist/components/form/fields/radio-card-field.d.ts +0 -22
- package/dist/components/form/fields/radio-field.d.ts +0 -16
- package/dist/components/form/fields/select-field.d.ts +0 -9
- package/dist/components/form/fields/use-field-control.d.ts +0 -6
- package/dist/components/form/fields/use-tooltip-trigger-labels.d.ts +0 -5
- package/dist/components/form/form-control/form-control-context.d.ts +0 -35
- package/dist/components/form/form-control/form-control-label.d.ts +0 -1
- package/dist/components/form/form-control/form-control.d.ts +0 -13
- package/dist/components/form/form-control/form-helper-text.d.ts +0 -9
- package/dist/components/form/form-control/form-label.d.ts +0 -9
- package/dist/components/form/form-control/index.d.ts +0 -5
- package/dist/components/form/input-label.d.ts +0 -9
- package/dist/theme/components/accordion.theme.d.ts +0 -7
- package/dist/theme/components/action-button.theme.d.ts +0 -45
- package/dist/theme/components/alert.theme.d.ts +0 -2
- package/dist/theme/components/autocomplete.theme.d.ts +0 -2
- package/dist/theme/components/baseline-css.d.ts +0 -2
- package/dist/theme/components/button.theme.d.ts +0 -2
- package/dist/theme/components/card.theme.d.ts +0 -2
- package/dist/theme/components/checkbox.theme.d.ts +0 -2
- package/dist/theme/components/chip.theme.d.ts +0 -2
- package/dist/theme/components/dev-panel.theme.d.ts +0 -95
- package/dist/theme/components/dialog.theme.d.ts +0 -2
- package/dist/theme/components/drawer.theme.d.ts +0 -4
- package/dist/theme/components/field-base.d.ts +0 -31
- package/dist/theme/components/form-control-label.theme.d.ts +0 -2
- package/dist/theme/components/form-control.theme.d.ts +0 -2
- package/dist/theme/components/index.d.ts +0 -2
- package/dist/theme/components/input.theme.d.ts +0 -3
- package/dist/theme/components/link.theme.d.ts +0 -2
- package/dist/theme/components/menu-item.theme.d.ts +0 -2
- package/dist/theme/components/number-input.theme.d.ts +0 -23
- package/dist/theme/components/phone-number-input.theme.d.ts +0 -43
- package/dist/theme/components/radio.theme.d.ts +0 -2
- package/dist/theme/components/select.theme.d.ts +0 -2
- package/dist/theme/components/slider.theme.d.ts +0 -2
- package/dist/theme/components/tabs.theme.d.ts +0 -34
- package/dist/theme/components/tooltip.theme.d.ts +0 -110
- package/dist/theme/components/typography.theme.d.ts +0 -2
- package/dist/theme/mui-augmentation.d.ts +0 -147
- package/dist/theme/sx-config.d.ts +0 -10
- /package/dist/{components/form/datepicker → date-picker}/calendar-header.d.ts +0 -0
- /package/dist/{components/form/datepicker → date-picker}/drawer-toolbar.d.ts +0 -0
- /package/dist/{theme/components → date-picker/theme}/date-picker.theme.d.ts +0 -0
- /package/dist/{theme/components → date-picker/theme}/icon-button.theme.d.ts +0 -0
- /package/dist/{theme/tokens → date-picker/theme}/typography.d.ts +0 -0
- /package/dist/{components/form/datepicker → date-picker}/use-calendar-header-labels.d.ts +0 -0
- /package/dist/{components/form/datepicker → date-picker}/use-datepicker-title-labels.d.ts +0 -0
- /package/dist/{components/form/datepicker → date-picker}/view-renderers.d.ts +0 -0
- /package/dist/{components/form/datepicker → date-picker}/view-toggle.d.ts +0 -0
- /package/dist/{components/dev-panel → dev-panel}/dev-panel-country.d.ts +0 -0
- /package/dist/{components/dev-panel → dev-panel}/dev-panel-flow.d.ts +0 -0
- /package/dist/{components/dev-panel → dev-panel}/dev-panel-footer.d.ts +0 -0
- /package/dist/{components/dev-panel → dev-panel}/dev-panel-step-state.d.ts +0 -0
- /package/dist/{components/dev-panel → dev-panel}/dev-panel-variant.d.ts +0 -0
- /package/dist/{components/dev-panel → dev-panel}/use-copy.d.ts +0 -0
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { SelectChangeEvent } from '@mui/material';
|
|
2
1
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export type MultiSelectProps
|
|
5
|
-
/**
|
|
6
|
-
options: SelectOption[];
|
|
2
|
+
import { SelectFieldBaseProps, SelectOption } from './select-field';
|
|
3
|
+
export type MultiSelectProps<Value extends string = string> = SelectFieldBaseProps & {
|
|
4
|
+
/** The choices, shown with a checkbox each. */
|
|
5
|
+
options: readonly SelectOption<Value>[];
|
|
7
6
|
/** Currently selected values (controlled). */
|
|
8
|
-
value?:
|
|
7
|
+
value?: Value[];
|
|
9
8
|
/** Initially selected values (uncontrolled). */
|
|
10
|
-
defaultValue?:
|
|
9
|
+
defaultValue?: Value[];
|
|
11
10
|
/** Called with the next array of selected values. */
|
|
12
|
-
|
|
11
|
+
onValueChange?: (value: Value[]) => void;
|
|
13
12
|
/** Minimum number of values that must stay selected. @default 1 */
|
|
14
13
|
min?: number;
|
|
15
14
|
/** Maximum number of values that can be selected. Unlimited when omitted. */
|
|
16
15
|
max?: number;
|
|
17
16
|
/** Override how the selected values are summarised in the closed control. */
|
|
18
|
-
renderValue?: (selected:
|
|
17
|
+
renderValue?: (selected: Value[]) => ReactNode;
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
|
-
* Multi-select
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* chips by default.
|
|
20
|
+
* Multi-select on Base UI's `Select`, in the same box as `Select`, with the
|
|
21
|
+
* label, the helper text and their ids wired. Each option has a checkbox, and
|
|
22
|
+
* the closed control shows the selection as removable chips by default.
|
|
25
23
|
*
|
|
26
24
|
* The selection is bounded by `min` (default 1, so the last value can't be
|
|
27
25
|
* removed) and `max` (unlimited by default): options that would breach either
|
|
@@ -29,4 +27,4 @@ export type MultiSelectProps = Omit<SelectProps, "multiple" | "value" | "default
|
|
|
29
27
|
*
|
|
30
28
|
* Works controlled (`value`) or uncontrolled (`defaultValue`).
|
|
31
29
|
*/
|
|
32
|
-
export declare
|
|
30
|
+
export declare function MultiSelect<Value extends string = string>({ options, value, defaultValue, onValueChange, renderValue, min, max, disabled, ref, ...rest }: MultiSelectProps<Value>): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Currency } from '../../hooks/country/countries';
|
|
3
|
+
import { Language } from '../../i18n';
|
|
4
|
+
/**
|
|
5
|
+
* A unit the library writes for you, in the language of `LeaProvider`:
|
|
6
|
+
*
|
|
7
|
+
* - `{ type: "years" }`: "år", "vuotta", "años". The word follows the number
|
|
8
|
+
* in the field, so Finnish and Spanish read "1 vuosi" and "2 vuotta",
|
|
9
|
+
* "1 año" and "2 años".
|
|
10
|
+
* - `{ type: "currency" }`: the symbol of the currency, "kr" or "€". The
|
|
11
|
+
* currency is the one of the language (`no` NOK, `se` SEK, `fi` and `es`
|
|
12
|
+
* EUR); pass `currency` for another.
|
|
13
|
+
*/
|
|
14
|
+
export type NumberInputUnitSpec = {
|
|
15
|
+
type: "years";
|
|
16
|
+
} | {
|
|
17
|
+
type: "currency";
|
|
18
|
+
currency?: Currency;
|
|
19
|
+
};
|
|
20
|
+
/** What `NumberInput` takes as `unit`: your own content, or a unit spec. */
|
|
21
|
+
export type NumberInputUnit = ReactNode | NumberInputUnitSpec;
|
|
22
|
+
/** A spec, as opposed to a string, a number or an element. */
|
|
23
|
+
export declare function isUnitSpec(unit: NumberInputUnit): unit is NumberInputUnitSpec;
|
|
24
|
+
/**
|
|
25
|
+
* The text of a unit spec for a language. `value` picks the plural of "years"
|
|
26
|
+
* and is ignored for a currency; an empty field counts as zero.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatUnit(unit: NumberInputUnitSpec, language: Language, value: number | null | undefined): string;
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
import { NumberField as BaseNumberField } from '@base-ui/react/number-field';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
3
|
+
import { NumberInputUnit } from './number-input-unit';
|
|
4
|
+
export type { NumberInputUnit, NumberInputUnitSpec } from './number-input-unit';
|
|
5
|
+
export type NumberInputProps = Omit<BaseNumberField.Root.Props, "ref" | "inputRef" | "render" | "className" | "style"> & {
|
|
6
|
+
/** The visible `<input>`. */
|
|
7
|
+
ref?: Ref<HTMLInputElement>;
|
|
8
|
+
/** The label, linked to the input for you. */
|
|
5
9
|
label?: ReactNode;
|
|
6
|
-
/**
|
|
10
|
+
/** Floating inside the field, or as a line above it. @default "inside" */
|
|
7
11
|
labelPlacement?: "inside" | "outside";
|
|
12
|
+
/**
|
|
13
|
+
* Help text behind an info button next to the label. Needs
|
|
14
|
+
* `labelPlacement="outside"`: a floating label has no room for it.
|
|
15
|
+
*/
|
|
16
|
+
tooltip?: ReactNode;
|
|
8
17
|
/** Helper / error text shown below the control and linked via `aria-describedby`. */
|
|
9
18
|
helperText?: ReactNode;
|
|
10
19
|
/** Renders the field in its error state (border, label and helper colour). */
|
|
11
20
|
error?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* A message for a value that is allowed but unusual, such as an unusually
|
|
23
|
+
* high amount. Shown in amber in place of the helper text, without the
|
|
24
|
+
* error state: the field is not marked invalid. `error` wins when both are set.
|
|
25
|
+
*/
|
|
26
|
+
warning?: ReactNode;
|
|
12
27
|
/** Reflects `required` onto the control and the label asterisk. */
|
|
13
28
|
required?: boolean;
|
|
14
29
|
/** Disables the input and the stepper buttons. */
|
|
15
30
|
disabled?: boolean;
|
|
16
|
-
/** Control density. @default "medium" */
|
|
17
|
-
size?: "small" | "medium";
|
|
18
31
|
/** Placeholder shown while the field is empty. */
|
|
19
32
|
placeholder?: string;
|
|
20
33
|
/**
|
|
@@ -23,30 +36,45 @@ export type NumberInputProps = BaseNumberField.Root.Props & {
|
|
|
23
36
|
*/
|
|
24
37
|
startIcon?: ReactNode;
|
|
25
38
|
/**
|
|
26
|
-
* Trailing unit shown inside the field
|
|
27
|
-
*
|
|
28
|
-
*
|
|
39
|
+
* Trailing unit shown inside the field. Rendered as real text linked to the
|
|
40
|
+
* input via `aria-describedby` — not a placeholder — so it is announced and
|
|
41
|
+
* survives typing.
|
|
42
|
+
*
|
|
43
|
+
* - Your own content: `unit="kr/mnd"`. It is not translated.
|
|
44
|
+
* - `{ type: "years" }`: "år", "vuotta" or "años" in the language of
|
|
45
|
+
* `LeaProvider`, in the plural that fits the number in the field.
|
|
46
|
+
* - `{ type: "currency" }`: "kr" or "€" for the language (`{ type:
|
|
47
|
+
* "currency", currency: "EUR" }` for another currency).
|
|
29
48
|
*/
|
|
30
|
-
unit?:
|
|
49
|
+
unit?: NumberInputUnit;
|
|
31
50
|
/**
|
|
32
51
|
* Whether to render the increment / decrement stepper buttons.
|
|
33
52
|
* @default true
|
|
34
53
|
*/
|
|
35
54
|
showSteppers?: boolean;
|
|
55
|
+
/** Class on the outermost element, for layout. */
|
|
56
|
+
className?: string;
|
|
57
|
+
/** Inline style on the outermost element, for layout. */
|
|
58
|
+
style?: CSSProperties;
|
|
36
59
|
};
|
|
37
60
|
/**
|
|
38
61
|
* Numeric input built on Base UI's `NumberField` (value / min / max / step /
|
|
39
|
-
* formatting)
|
|
40
|
-
* decrement buttons.
|
|
62
|
+
* formatting), in the same box as `Input`, with increment / decrement buttons.
|
|
41
63
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* - **Composed:** drop it inside a `FormControl` and it picks up the shared ids
|
|
46
|
-
* and state from context.
|
|
64
|
+
* The label, the helper text and the ids that link them to the input are all
|
|
65
|
+
* rendered and wired for you. Set `labelPlacement="outside"` for a label above
|
|
66
|
+
* the field, which can also carry a `tooltip`.
|
|
47
67
|
*
|
|
48
68
|
* For money and other open-ended amounts, set `showSteppers={false}` and use a
|
|
49
69
|
* `unit` (e.g. `kr`) instead — a stepper is only helpful for small bounded
|
|
50
70
|
* counts.
|
|
71
|
+
*
|
|
72
|
+
* `unit` takes your own text, or a unit the library writes in the language of
|
|
73
|
+
* `LeaProvider`:
|
|
74
|
+
*
|
|
75
|
+
* ```tsx
|
|
76
|
+
* <NumberInput label="Lånebeløp" unit={{ type: "currency" }} showSteppers={false} />
|
|
77
|
+
* <NumberInput label="Nedbetalingstid" unit={{ type: "years" }} min={1} max={15} />
|
|
78
|
+
* ```
|
|
51
79
|
*/
|
|
52
|
-
export declare function NumberInput({ label, labelPlacement, helperText, error, required, disabled, id,
|
|
80
|
+
export declare function NumberInput({ label, labelPlacement, tooltip, helperText, error, warning, required, disabled, id, placeholder, startIcon, unit, showSteppers, className, style, ref, value, defaultValue, onValueChange, ...rest }: NumberInputProps): import("react").JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, CSSProperties, ReactNode, Ref } from 'react';
|
|
3
2
|
import { CountryCode } from './countries';
|
|
4
3
|
/** Details reported alongside every change so the consumer can react to validity. */
|
|
5
4
|
export interface PhoneNumberMeta {
|
|
@@ -10,44 +9,75 @@ export interface PhoneNumberMeta {
|
|
|
10
9
|
/** Whether the current number is a valid phone number for the country. */
|
|
11
10
|
isValid: boolean;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
type NativeInputProps = Omit<ComponentPropsWithoutRef<"input">, "value" | "defaultValue" | "onChange" | "type" | "size" | "color" | "children" | "className" | "style">;
|
|
13
|
+
export type PhoneNumberInputProps = NativeInputProps & {
|
|
14
|
+
/** Floating label, linked to the input for you. */
|
|
15
15
|
label?: ReactNode;
|
|
16
16
|
/** Helper / error text shown below the control and linked via `aria-describedby`. */
|
|
17
17
|
helperText?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Puts the input, its label and its helper text into the error state. When
|
|
20
|
+
* set, true or false, the built-in check on blur stays out of it.
|
|
21
|
+
*/
|
|
22
|
+
error?: boolean;
|
|
18
23
|
/** Selected country (controlled). Pair with `onCountryChange`. */
|
|
19
24
|
country?: CountryCode;
|
|
20
25
|
/** Initial country when uncontrolled. Defaults to the country for the active locale. */
|
|
21
26
|
defaultCountry?: CountryCode;
|
|
22
27
|
/** Fired when the user picks a different country. */
|
|
23
28
|
onCountryChange?: (country: CountryCode) => void;
|
|
24
|
-
/** The national number as displayed (controlled). Pair with `
|
|
29
|
+
/** The national number as displayed (controlled). Pair with `onValueChange`. */
|
|
25
30
|
value?: string;
|
|
26
31
|
/** Initial national number when uncontrolled. */
|
|
27
32
|
defaultValue?: string;
|
|
28
33
|
/** Fired on every keystroke with the formatted national number and validity meta. */
|
|
29
|
-
|
|
34
|
+
onValueChange?: (value: string, meta: PhoneNumberMeta) => void;
|
|
35
|
+
/**
|
|
36
|
+
* The countries the number may be from. With one, there is no country
|
|
37
|
+
* list: its dial code stands fixed at the start of the field (`+46`). With
|
|
38
|
+
* several, the list holds these alone.
|
|
39
|
+
*
|
|
40
|
+
* Either way the value is the national number without the trunk `0`
|
|
41
|
+
* (`70 123 45 67`): a pasted `+46 70…`, `0046 70…` or `070…` is cleaned up to
|
|
42
|
+
* it, and when focus leaves the field. A number of another country is
|
|
43
|
+
* invalid. Left out, every country is in the list and the number is kept as
|
|
44
|
+
* typed, as before.
|
|
45
|
+
*/
|
|
46
|
+
countries?: readonly CountryCode[];
|
|
47
|
+
/**
|
|
48
|
+
* Accept mobile numbers only: a landline is invalid, with a message of its
|
|
49
|
+
* own ("Skriv inn et mobilnummer"). Applies to Sweden, Finland, Norway and
|
|
50
|
+
* Spain, as `validateMobileNumber`; a number of another country is checked
|
|
51
|
+
* as any number. `meta.isValid` follows it.
|
|
52
|
+
*/
|
|
53
|
+
mobileOnly?: boolean;
|
|
30
54
|
/**
|
|
31
55
|
* Show a built-in "invalid number" error once the field is blurred with a
|
|
32
56
|
* non-empty, invalid value. Ignored when the consumer drives `error`.
|
|
33
57
|
* @default true
|
|
34
58
|
*/
|
|
35
59
|
validateOnBlur?: boolean;
|
|
60
|
+
/** Class on the outermost element, for layout. */
|
|
61
|
+
className?: string;
|
|
62
|
+
/** Inline style on the outermost element, for layout. */
|
|
63
|
+
style?: CSSProperties;
|
|
64
|
+
/** The phone number `<input>`. */
|
|
65
|
+
ref?: Ref<HTMLInputElement>;
|
|
36
66
|
};
|
|
37
67
|
/**
|
|
38
|
-
* Phone number input with a searchable country-code picker
|
|
39
|
-
*
|
|
68
|
+
* Phone number input with a searchable country-code picker at its start, in
|
|
69
|
+
* the same box as `Input`. The number is formatted as you type and validated
|
|
40
70
|
* with `libphonenumber-js`. Lea Bank's core markets (Finland, Sweden, Norway,
|
|
41
71
|
* Spain) are pinned to the top of the country list; the default country follows
|
|
42
72
|
* the active locale.
|
|
43
73
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* - **Composed:** drop it inside a `FormControl` and it picks up the shared ids.
|
|
74
|
+
* The label, the helper text and the ids that link them to the input are all
|
|
75
|
+
* rendered and wired for you. Takes the native `<input>` attributes (`name`,
|
|
76
|
+
* `placeholder`, `onBlur`, `autoComplete`, …), which land on the number input.
|
|
48
77
|
*
|
|
49
78
|
* Both country and number can be **controlled** (`country` + `onCountryChange`,
|
|
50
|
-
* `value` + `
|
|
79
|
+
* `value` + `onValueChange`) or left **uncontrolled** (`defaultCountry` /
|
|
51
80
|
* `defaultValue`).
|
|
52
81
|
*/
|
|
53
|
-
export declare function PhoneNumberInput({ label, helperText, error, required, disabled, id, country, defaultCountry, onCountryChange, value, defaultValue,
|
|
82
|
+
export declare function PhoneNumberInput({ label, helperText, error, required, disabled, id, country, defaultCountry, onCountryChange, value, defaultValue, onValueChange, onBlur, countries, mobileOnly, validateOnBlur, className, style, ref, "aria-describedby": ariaDescribedBy, ...inputAttributes }: PhoneNumberInputProps): import("react").JSX.Element;
|
|
83
|
+
export {};
|
|
@@ -1,53 +1,61 @@
|
|
|
1
|
-
import { SxProps, Theme } from '@mui/material';
|
|
2
1
|
import { LucideIcon } from 'lucide-react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
3
|
+
import { Option } from './radio';
|
|
4
|
+
import { RadioSize } from './radio-circle';
|
|
5
|
+
import { RadioCardSize, RadioGroupBaseProps, RadioValue } from './radio-group-root';
|
|
6
|
+
export type RootProps<T extends RadioValue = RadioValue> = {
|
|
7
|
+
/** What `onValueChange` on the group is called with when this card is picked. */
|
|
8
|
+
value: T;
|
|
7
9
|
/** `"horizontal"` (indicator + text in a row) or `"vertical"` (icon stacked above text). */
|
|
8
10
|
orientation?: "horizontal" | "vertical";
|
|
11
|
+
/** Disables this card only. */
|
|
9
12
|
disabled?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/** Padding of the card. Defaults to the group's `size`. */
|
|
14
|
+
size?: RadioCardSize;
|
|
15
|
+
/** Class on the card. */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Inline style on the card. */
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
/** The card, which is a `<label>` around the radio. */
|
|
20
|
+
ref?: Ref<HTMLLabelElement>;
|
|
15
21
|
children?: ReactNode;
|
|
16
|
-
size?: "sm" | "lg";
|
|
17
22
|
};
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `RadioCardDescription`.
|
|
24
|
+
* One choice in a `RadioCard.Group`, for when the `options` list is not
|
|
25
|
+
* enough. The whole card is clickable, and it is built from composable
|
|
26
|
+
* pieces: `RadioCard.Content` (wraps the text), `RadioCard.Indicator`
|
|
27
|
+
* (optional), `RadioCard.Icon`, `RadioCard.Label`, `RadioCard.Description`.
|
|
24
28
|
*
|
|
25
29
|
* Children are laid out as plain flex items, so the indicator is just another
|
|
26
|
-
* child — place it before or after `
|
|
30
|
+
* child — place it before or after `RadioCard.Content` and it sits at that edge
|
|
27
31
|
* (the content grows to fill the row, pushing the indicator to the side).
|
|
28
32
|
*
|
|
29
|
-
*
|
|
30
|
-
* card derives its checked styling from the group automatically.
|
|
33
|
+
* The group holds the value, so a `RadioCard.Root` only works inside one.
|
|
31
34
|
*
|
|
32
35
|
* ```tsx
|
|
33
|
-
* <
|
|
34
|
-
* <RadioCard value=
|
|
35
|
-
* <
|
|
36
|
-
* <
|
|
37
|
-
* <
|
|
38
|
-
* </
|
|
39
|
-
* <
|
|
40
|
-
* </RadioCard>
|
|
41
|
-
* </
|
|
36
|
+
* <RadioCard.Group label="Nedbetalingstid" value={value} onValueChange={setValue}>
|
|
37
|
+
* <RadioCard.Root value={10}>
|
|
38
|
+
* <RadioCard.Content>
|
|
39
|
+
* <RadioCard.Label>1316 kr/mnd</RadioCard.Label>
|
|
40
|
+
* <RadioCard.Description>Over 10 år</RadioCard.Description>
|
|
41
|
+
* </RadioCard.Content>
|
|
42
|
+
* <RadioCard.Indicator />
|
|
43
|
+
* </RadioCard.Root>
|
|
44
|
+
* </RadioCard.Group>
|
|
42
45
|
* ```
|
|
43
46
|
*/
|
|
44
|
-
export declare
|
|
47
|
+
export declare function Root<T extends RadioValue = RadioValue>({ value, orientation, disabled, size, className, style, ref, children, }: RootProps<T>): import("react").JSX.Element;
|
|
48
|
+
export type IndicatorProps = {
|
|
49
|
+
/** Size of the circle. @default "md" */
|
|
50
|
+
size?: RadioSize;
|
|
51
|
+
};
|
|
45
52
|
/**
|
|
46
|
-
* Optional radio dot for a `RadioCard`.
|
|
47
|
-
*
|
|
53
|
+
* Optional radio dot for a `RadioCard.Root`. It is a picture of the card's
|
|
54
|
+
* state, drawn like a `RadioGroup.Item`; the card's own radio is what gets
|
|
55
|
+
* picked. Omit it for icon-only cards.
|
|
48
56
|
*/
|
|
49
|
-
export declare const
|
|
50
|
-
export type
|
|
57
|
+
export declare const Indicator: ({ size }: IndicatorProps) => import("react").JSX.Element;
|
|
58
|
+
export type IconProps = {
|
|
51
59
|
/** Icon box size (predefined, overridable). */
|
|
52
60
|
size?: number | string;
|
|
53
61
|
icon: LucideIcon;
|
|
@@ -56,22 +64,65 @@ export type RadioCardIconProps = {
|
|
|
56
64
|
* Fixed-size icon slot so every card's icon renders at the same size regardless
|
|
57
65
|
* of the icon passed in.
|
|
58
66
|
*/
|
|
59
|
-
export declare const
|
|
67
|
+
export declare const Icon: ({ size, icon }: IconProps) => import("react").JSX.Element;
|
|
60
68
|
/**
|
|
61
|
-
* Wraps the text lines (`
|
|
62
|
-
* Grows to fill the row in `horizontal` orientation — so a sibling
|
|
63
|
-
* `
|
|
69
|
+
* Wraps the text lines (`RadioCard.Label` / `RadioCard.Description`) into a
|
|
70
|
+
* column. Grows to fill the row in `horizontal` orientation — so a sibling
|
|
71
|
+
* `RadioCard.Indicator` is pushed to the opposite edge — and centers in
|
|
64
72
|
* `vertical`.
|
|
65
73
|
*/
|
|
66
|
-
export declare const
|
|
74
|
+
export declare const Content: ({ children, className, style, }: {
|
|
67
75
|
children: ReactNode;
|
|
68
|
-
|
|
76
|
+
className?: string;
|
|
77
|
+
style?: CSSProperties;
|
|
69
78
|
}) => import("react").JSX.Element;
|
|
70
|
-
/** Primary line of a `RadioCard`. */
|
|
71
|
-
export declare const
|
|
79
|
+
/** Primary line of a `RadioCard.Root`. */
|
|
80
|
+
export declare const Label: ({ children }: {
|
|
72
81
|
children: ReactNode;
|
|
73
82
|
}) => import("react").JSX.Element;
|
|
74
|
-
/** Secondary, muted line of a `RadioCard`. */
|
|
75
|
-
export declare const
|
|
83
|
+
/** Secondary, muted line of a `RadioCard.Root`. */
|
|
84
|
+
export declare const Description: ({ children }: {
|
|
76
85
|
children: ReactNode;
|
|
77
86
|
}) => import("react").JSX.Element;
|
|
87
|
+
export type GroupProps<T extends RadioValue = string> = RadioGroupBaseProps<T> & {
|
|
88
|
+
/**
|
|
89
|
+
* The choices, each rendered as a card with a radio dot and its label.
|
|
90
|
+
* For icons, descriptions or cards without the dot, pass `RadioCard.Root`
|
|
91
|
+
* children instead.
|
|
92
|
+
*/
|
|
93
|
+
options?: Option<T>[];
|
|
94
|
+
/** How many cards sit side by side. @default 1 */
|
|
95
|
+
columns?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Padding of the cards. A `size` on a `RadioCard.Root` wins.
|
|
98
|
+
* @default "lg"
|
|
99
|
+
*/
|
|
100
|
+
size?: RadioCardSize;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* A question with one answer, as a set of selectable cards, on Base UI's
|
|
104
|
+
* accessible `RadioGroup` primitive. The label, the tooltip, the helper text
|
|
105
|
+
* and the error state are handled for you. Arrow keys move between the cards.
|
|
106
|
+
*
|
|
107
|
+
* Pass the choices as `options`. Values are compared with `===` and can be
|
|
108
|
+
* strings, numbers or booleans, so a yes / no question can hold a real
|
|
109
|
+
* `boolean`:
|
|
110
|
+
*
|
|
111
|
+
* ```tsx
|
|
112
|
+
* <RadioCard.Group
|
|
113
|
+
* label="Vil du legge til en medsøker?"
|
|
114
|
+
* columns={2}
|
|
115
|
+
* size="sm"
|
|
116
|
+
* options={[
|
|
117
|
+
* { value: true, label: "Ja" },
|
|
118
|
+
* { value: false, label: "Nei" },
|
|
119
|
+
* ]}
|
|
120
|
+
* value={hasCoApplicant}
|
|
121
|
+
* onValueChange={setHasCoApplicant}
|
|
122
|
+
* />
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* For richer cards, pass `RadioCard.Root` children.
|
|
126
|
+
*/
|
|
127
|
+
export declare function Group<T extends RadioValue = string>({ options, columns, size, children, ...rest }: GroupProps<T>): import("react").JSX.Element;
|
|
128
|
+
export type { Option, RadioCardSize as Size, RadioValue as Value };
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type RadioSize = "sm" | "md";
|
|
2
|
+
/** The classes of the radio visual, for the real control to wear. */
|
|
3
|
+
export declare const radioCircleClassName: string;
|
|
4
|
+
export declare const radioDotClassName: string;
|
|
3
5
|
export type RadioCircleProps = {
|
|
4
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Fills the circle and springs the dot in. Leave it out when a parent
|
|
8
|
+
* selector decides instead, as `RadioCard.Root` does for its indicator.
|
|
9
|
+
*/
|
|
5
10
|
checked?: boolean;
|
|
6
11
|
size?: RadioSize;
|
|
7
|
-
|
|
12
|
+
className?: string;
|
|
8
13
|
};
|
|
9
14
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Self-styled (not a MUI theme override) because it renders outside `MuiRadio`
|
|
16
|
-
* too. When used as `Radio`'s icons, swapping `<RadioCircle />` ⇄
|
|
17
|
-
* `<RadioCircle checked />` reconciles in place, so the dot animates.
|
|
15
|
+
* Internal. The radio visual as a picture only, for places where something else
|
|
16
|
+
* is the control: `RadioCard.Indicator` shows it inside a card, and the card's
|
|
17
|
+
* own hidden radio is what gets picked. It looks exactly like
|
|
18
|
+
* `RadioGroup.Item`, which puts the same classes on the real control.
|
|
18
19
|
*/
|
|
19
|
-
export declare const RadioCircle: ({ checked, size,
|
|
20
|
+
export declare const RadioCircle: ({ checked, size, className, }: RadioCircleProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CSSProperties, FocusEvent, ReactNode, Ref } from 'react';
|
|
2
|
+
import { RadioSize } from './radio-circle';
|
|
3
|
+
/** What a radio can stand for. Compared with `===`, so `true` is not `"true"`. */
|
|
4
|
+
export type RadioValue = string | number | boolean;
|
|
5
|
+
export type RadioCardSize = "sm" | "lg";
|
|
6
|
+
type RadioGroupContextValue = {
|
|
7
|
+
/** Size of the radio circle, set by `RadioGroup.Root`. */
|
|
8
|
+
size?: RadioSize;
|
|
9
|
+
/** Size of the cards, set by `RadioCard.Group`. */
|
|
10
|
+
cardSize?: RadioCardSize;
|
|
11
|
+
};
|
|
12
|
+
/** Reads the surrounding group. A radio cannot work without one. */
|
|
13
|
+
export declare const useRadioGroupContext: (component: string) => RadioGroupContextValue;
|
|
14
|
+
/**
|
|
15
|
+
* Requires an accessible name so the group is never nameless. Provide a
|
|
16
|
+
* visible `label`, or an `aria-label` / `aria-labelledby` when the question
|
|
17
|
+
* is written somewhere else on the page.
|
|
18
|
+
*/
|
|
19
|
+
type RadioGroupAccessibleName = {
|
|
20
|
+
label: ReactNode;
|
|
21
|
+
"aria-label"?: never;
|
|
22
|
+
"aria-labelledby"?: never;
|
|
23
|
+
} | {
|
|
24
|
+
label?: never;
|
|
25
|
+
"aria-label": string;
|
|
26
|
+
"aria-labelledby"?: never;
|
|
27
|
+
} | {
|
|
28
|
+
label?: never;
|
|
29
|
+
"aria-label"?: never;
|
|
30
|
+
"aria-labelledby": string;
|
|
31
|
+
};
|
|
32
|
+
/** The props `RadioGroup.Root` and `RadioCard.Group` have in common. */
|
|
33
|
+
export type RadioGroupBaseProps<T extends RadioValue> = RadioGroupAccessibleName & {
|
|
34
|
+
/** Help text behind an info button next to the label. Needs a `label`. */
|
|
35
|
+
tooltip?: ReactNode;
|
|
36
|
+
/** Helper / error text shown below the options and linked via `aria-describedby`. */
|
|
37
|
+
helperText?: ReactNode;
|
|
38
|
+
/** Puts the group and its helper text into the error state. */
|
|
39
|
+
error?: boolean;
|
|
40
|
+
/** The chosen value (controlled). `null` means nothing is chosen. */
|
|
41
|
+
value?: T | null;
|
|
42
|
+
/** The chosen value when first rendered, for uncontrolled use. */
|
|
43
|
+
defaultValue?: T;
|
|
44
|
+
/** Called with the value of the option the user picks. */
|
|
45
|
+
onValueChange?: (value: T) => void;
|
|
46
|
+
/** Submits the choice under this name when inside a form. */
|
|
47
|
+
name?: string;
|
|
48
|
+
/** Disables every option. */
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
/** Marks the group as required and adds the asterisk to the label. */
|
|
51
|
+
required?: boolean;
|
|
52
|
+
/** Called when focus leaves the group, not when it moves between options. */
|
|
53
|
+
onBlur?: (event: FocusEvent<HTMLDivElement>) => void;
|
|
54
|
+
/** Id of the element with the `radiogroup` role. */
|
|
55
|
+
id?: string;
|
|
56
|
+
/** Extra ids describing the group, alongside the helper text. */
|
|
57
|
+
"aria-describedby"?: string;
|
|
58
|
+
/** Class on the outermost element, for layout. */
|
|
59
|
+
className?: string;
|
|
60
|
+
/** Inline style on the outermost element, for layout. */
|
|
61
|
+
style?: CSSProperties;
|
|
62
|
+
/**
|
|
63
|
+
* The `<input>` of the radio that takes focus: the chosen one, or the
|
|
64
|
+
* first that is not disabled. It is hidden, but `ref.current.focus()`
|
|
65
|
+
* moves focus to the visible radio.
|
|
66
|
+
*/
|
|
67
|
+
ref?: Ref<HTMLInputElement>;
|
|
68
|
+
/**
|
|
69
|
+
* `RadioGroup.Item` / `RadioCard.Root` elements, instead of or after `options`.
|
|
70
|
+
*/
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
};
|
|
73
|
+
type RadioGroupRootProps<T extends RadioValue> = RadioGroupBaseProps<T> & {
|
|
74
|
+
size?: RadioSize;
|
|
75
|
+
cardSize?: RadioCardSize;
|
|
76
|
+
/** Layout of the options. */
|
|
77
|
+
optionsClassName: string;
|
|
78
|
+
optionsStyle?: CSSProperties;
|
|
79
|
+
/** `"many"` when the options sit in more than one column. */
|
|
80
|
+
optionsDataColumns?: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Internal. Everything `RadioGroup.Root` and `RadioCard.Group` share: Base UI's
|
|
84
|
+
* `RadioGroup`, which holds the value and moves focus with the arrow keys,
|
|
85
|
+
* and the label, tooltip, helper text and error state around the options.
|
|
86
|
+
*/
|
|
87
|
+
export declare function RadioGroupRoot<T extends RadioValue>({ label, tooltip, helperText, error, value, defaultValue, onValueChange, name, disabled, required, onBlur, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, className, style, ref, size, cardSize, optionsClassName, optionsStyle, optionsDataColumns, children, }: RadioGroupRootProps<T>): import("react").JSX.Element;
|
|
88
|
+
export {};
|