@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ControllerFieldState, FieldPath, FieldPathValue, FieldValues, RefCallBack, UseControllerProps, UseFormStateReturn } from 'react-hook-form';
|
|
3
|
+
/** What every bound control gets, whatever kind of value it holds. */
|
|
4
|
+
type FormFieldSharedProps = {
|
|
5
|
+
/** The field's name in the form. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Marks the field as touched, and validates it if the form's `mode` says so. */
|
|
8
|
+
onBlur: () => void;
|
|
9
|
+
/** Lets the form move focus to the control when it is the first invalid one. */
|
|
10
|
+
ref: RefCallBack;
|
|
11
|
+
/** Whether the field currently fails validation. */
|
|
12
|
+
error: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The validation message. Only present while there is one, so a
|
|
15
|
+
* `helperText` written before `{...field}` shows the rest of the time.
|
|
16
|
+
*/
|
|
17
|
+
helperText?: string;
|
|
18
|
+
/** Only present when the field or the whole form is disabled through the form. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** Props for a control that holds a value: spread them last. */
|
|
22
|
+
export type FormFieldControlProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FormFieldSharedProps & {
|
|
23
|
+
/** The field's current value. */
|
|
24
|
+
value: FieldPathValue<TFieldValues, TName>;
|
|
25
|
+
/**
|
|
26
|
+
* Writes a new value to the form. Loosely typed, like react-hook-form's own
|
|
27
|
+
* `onChange`: a control reports the type it works in (a `Select` reports
|
|
28
|
+
* `string`), which is often wider than the field's type (`"no" | "se"`).
|
|
29
|
+
*/
|
|
30
|
+
onValueChange: (value: any) => void;
|
|
31
|
+
};
|
|
32
|
+
/** Props for a control that is on or off (`Checkbox`): spread them last. */
|
|
33
|
+
export type FormFieldCheckedProps = FormFieldSharedProps & {
|
|
34
|
+
/** Whether the field's value is truthy. */
|
|
35
|
+
checked: boolean;
|
|
36
|
+
/** Writes `true` or `false` to the form. */
|
|
37
|
+
onCheckedChange: (checked: boolean) => void;
|
|
38
|
+
};
|
|
39
|
+
export type FormFieldRenderProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
40
|
+
/** For controls with a value: `<Input {...field} />`. */
|
|
41
|
+
field: FormFieldControlProps<TFieldValues, TName>;
|
|
42
|
+
/** For controls that are on or off: `<Checkbox {...checkedField} />`. */
|
|
43
|
+
checkedField: FormFieldCheckedProps;
|
|
44
|
+
/** react-hook-form's state for this field (`error`, `isTouched`, `isDirty`, …). */
|
|
45
|
+
fieldState: ControllerFieldState;
|
|
46
|
+
/** react-hook-form's state for the whole form (`isSubmitting`, `errors`, …). */
|
|
47
|
+
formState: UseFormStateReturn<TFieldValues>;
|
|
48
|
+
};
|
|
49
|
+
export type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues> = UseControllerProps<TFieldValues, TName, TTransformedValues> & {
|
|
50
|
+
/** Renders the control. Spread `field` (or `checkedField`) onto it, last. */
|
|
51
|
+
render: (props: FormFieldRenderProps<TFieldValues, TName>) => ReactNode;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Binds one form control to react-hook-form.
|
|
55
|
+
*
|
|
56
|
+
* Every form control in the library takes the same props for its value, its
|
|
57
|
+
* error state and its ref, so one binding fits them all: `FormField` reads
|
|
58
|
+
* the field from the form and hands you those props to spread onto the
|
|
59
|
+
* control. Everything else on the control (`label`, `options`, `placeholder`,
|
|
60
|
+
* …) you write as usual.
|
|
61
|
+
*
|
|
62
|
+
* Takes `control` as a prop, or reads it from a surrounding `FormProvider`.
|
|
63
|
+
* `name`, `rules`, `defaultValue`, `disabled` and `shouldUnregister` are
|
|
64
|
+
* passed to react-hook-form's `useController` unchanged.
|
|
65
|
+
*
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <FormField
|
|
68
|
+
* control={control}
|
|
69
|
+
* name="email"
|
|
70
|
+
* rules={{ required: "Skriv inn e-postadressen din." }}
|
|
71
|
+
* render={({ field }) => <Input label="E-post" type="email" {...field} />}
|
|
72
|
+
* />
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues>({ render, ...controller }: FormFieldProps<TFieldValues, TName, TTransformedValues>): ReactNode;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormField, type FormFieldCheckedProps, type FormFieldControlProps, type FormFieldProps, type FormFieldRenderProps, } from './form-field';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react-hook-form");function t({render:t,...n}){let r=(0,e.useFormContext)();if(!n.control&&!r)throw Error(`<FormField name="${n.name}"> needs a \`control\` prop or a surrounding <FormProvider>.`);let{field:i,fieldState:a,formState:o}=(0,e.useController)(n),s=a.error?.message,c={name:i.name,onBlur:i.onBlur,ref:i.ref,error:a.invalid,...s?{helperText:s}:{},...i.disabled===void 0?{}:{disabled:i.disabled}};return t({field:{...c,value:i.value,onValueChange:i.onChange},checkedField:{...c,checked:!!i.value,onCheckedChange:i.onChange},fieldState:a,formState:o})}exports.FormField=t;
|
|
2
|
+
//# sourceMappingURL=react-hook-form.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-hook-form.cjs","names":[],"sources":["../src/react-hook-form/form-field.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport {\n useController,\n useFormContext,\n type ControllerFieldState,\n type FieldPath,\n type FieldPathValue,\n type FieldValues,\n type RefCallBack,\n type UseControllerProps,\n type UseFormStateReturn,\n} from \"react-hook-form\";\n\n/** What every bound control gets, whatever kind of value it holds. */\ntype FormFieldSharedProps = {\n /** The field's name in the form. */\n name: string;\n /** Marks the field as touched, and validates it if the form's `mode` says so. */\n onBlur: () => void;\n /** Lets the form move focus to the control when it is the first invalid one. */\n ref: RefCallBack;\n /** Whether the field currently fails validation. */\n error: boolean;\n /**\n * The validation message. Only present while there is one, so a\n * `helperText` written before `{...field}` shows the rest of the time.\n */\n helperText?: string;\n /** Only present when the field or the whole form is disabled through the form. */\n disabled?: boolean;\n};\n\n/** Props for a control that holds a value: spread them last. */\nexport type FormFieldControlProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = FormFieldSharedProps & {\n /** The field's current value. */\n value: FieldPathValue<TFieldValues, TName>;\n /**\n * Writes a new value to the form. Loosely typed, like react-hook-form's own\n * `onChange`: a control reports the type it works in (a `Select` reports\n * `string`), which is often wider than the field's type (`\"no\" | \"se\"`).\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onValueChange: (value: any) => void;\n};\n\n/** Props for a control that is on or off (`Checkbox`): spread them last. */\nexport type FormFieldCheckedProps = FormFieldSharedProps & {\n /** Whether the field's value is truthy. */\n checked: boolean;\n /** Writes `true` or `false` to the form. */\n onCheckedChange: (checked: boolean) => void;\n};\n\nexport type FormFieldRenderProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n /** For controls with a value: `<Input {...field} />`. */\n field: FormFieldControlProps<TFieldValues, TName>;\n /** For controls that are on or off: `<Checkbox {...checkedField} />`. */\n checkedField: FormFieldCheckedProps;\n /** react-hook-form's state for this field (`error`, `isTouched`, `isDirty`, …). */\n fieldState: ControllerFieldState;\n /** react-hook-form's state for the whole form (`isSubmitting`, `errors`, …). */\n formState: UseFormStateReturn<TFieldValues>;\n};\n\nexport type FormFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n> = UseControllerProps<TFieldValues, TName, TTransformedValues> & {\n /** Renders the control. Spread `field` (or `checkedField`) onto it, last. */\n render: (props: FormFieldRenderProps<TFieldValues, TName>) => ReactNode;\n};\n\n/**\n * Binds one form control to react-hook-form.\n *\n * Every form control in the library takes the same props for its value, its\n * error state and its ref, so one binding fits them all: `FormField` reads\n * the field from the form and hands you those props to spread onto the\n * control. Everything else on the control (`label`, `options`, `placeholder`,\n * …) you write as usual.\n *\n * Takes `control` as a prop, or reads it from a surrounding `FormProvider`.\n * `name`, `rules`, `defaultValue`, `disabled` and `shouldUnregister` are\n * passed to react-hook-form's `useController` unchanged.\n *\n * ```tsx\n * <FormField\n * control={control}\n * name=\"email\"\n * rules={{ required: \"Skriv inn e-postadressen din.\" }}\n * render={({ field }) => <Input label=\"E-post\" type=\"email\" {...field} />}\n * />\n * ```\n */\nexport function FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n>({\n render,\n ...controller\n}: FormFieldProps<TFieldValues, TName, TTransformedValues>) {\n const form = useFormContext<TFieldValues, unknown, TTransformedValues>();\n if (!controller.control && !form) {\n throw new Error(\n `<FormField name=\"${controller.name}\"> needs a \\`control\\` prop or a surrounding <FormProvider>.`,\n );\n }\n\n const { field, fieldState, formState } = useController(controller);\n const message = fieldState.error?.message;\n\n const shared: FormFieldSharedProps = {\n name: field.name,\n onBlur: field.onBlur,\n ref: field.ref,\n error: fieldState.invalid,\n ...(message ? { helperText: message } : {}),\n ...(field.disabled !== undefined ? { disabled: field.disabled } : {}),\n };\n\n return render({\n field: { ...shared, value: field.value, onValueChange: field.onChange },\n checkedField: {\n ...shared,\n checked: Boolean(field.value),\n onCheckedChange: field.onChange,\n },\n fieldState,\n formState,\n });\n}\n"],"mappings":"iHAuGA,SAAgB,EAId,CACA,SACA,GAAG,GACuD,CAC1D,IAAM,GAAA,EAAO,EAAA,eAAA,CAA0D,EACvE,GAAI,CAAC,EAAW,SAAW,CAAC,EAC1B,MAAU,MACR,oBAAoB,EAAW,KAAK,6DACtC,EAGF,GAAM,CAAE,QAAO,aAAY,cAAA,EAAc,EAAA,cAAA,CAAc,CAAU,EAC3D,EAAU,EAAW,OAAO,QAE5B,EAA+B,CACnC,KAAM,EAAM,KACZ,OAAQ,EAAM,OACd,IAAK,EAAM,IACX,MAAO,EAAW,QAClB,GAAI,EAAU,CAAE,WAAY,CAAQ,EAAI,CAAC,EACzC,GAAI,EAAM,WAAa,IAAA,GAA2C,CAAC,EAAhC,CAAE,SAAU,EAAM,QAAS,CAChE,EAEA,OAAO,EAAO,CACZ,MAAO,CAAE,GAAG,EAAQ,MAAO,EAAM,MAAO,cAAe,EAAM,QAAS,EACtE,aAAc,CACZ,GAAG,EACH,QAAS,EAAQ,EAAM,MACvB,gBAAiB,EAAM,QACzB,EACA,aACA,WACF,CAAC,CACH"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useController as e, useFormContext as t } from "react-hook-form";
|
|
3
|
+
//#region src/react-hook-form/form-field.tsx
|
|
4
|
+
function n({ render: n, ...r }) {
|
|
5
|
+
let i = t();
|
|
6
|
+
if (!r.control && !i) throw Error(`<FormField name="${r.name}"> needs a \`control\` prop or a surrounding <FormProvider>.`);
|
|
7
|
+
let { field: a, fieldState: o, formState: s } = e(r), c = o.error?.message, l = {
|
|
8
|
+
name: a.name,
|
|
9
|
+
onBlur: a.onBlur,
|
|
10
|
+
ref: a.ref,
|
|
11
|
+
error: o.invalid,
|
|
12
|
+
...c ? { helperText: c } : {},
|
|
13
|
+
...a.disabled === void 0 ? {} : { disabled: a.disabled }
|
|
14
|
+
};
|
|
15
|
+
return n({
|
|
16
|
+
field: {
|
|
17
|
+
...l,
|
|
18
|
+
value: a.value,
|
|
19
|
+
onValueChange: a.onChange
|
|
20
|
+
},
|
|
21
|
+
checkedField: {
|
|
22
|
+
...l,
|
|
23
|
+
checked: !!a.value,
|
|
24
|
+
onCheckedChange: a.onChange
|
|
25
|
+
},
|
|
26
|
+
fieldState: o,
|
|
27
|
+
formState: s
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { n as FormField };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=react-hook-form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-hook-form.mjs","names":[],"sources":["../src/react-hook-form/form-field.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport {\n useController,\n useFormContext,\n type ControllerFieldState,\n type FieldPath,\n type FieldPathValue,\n type FieldValues,\n type RefCallBack,\n type UseControllerProps,\n type UseFormStateReturn,\n} from \"react-hook-form\";\n\n/** What every bound control gets, whatever kind of value it holds. */\ntype FormFieldSharedProps = {\n /** The field's name in the form. */\n name: string;\n /** Marks the field as touched, and validates it if the form's `mode` says so. */\n onBlur: () => void;\n /** Lets the form move focus to the control when it is the first invalid one. */\n ref: RefCallBack;\n /** Whether the field currently fails validation. */\n error: boolean;\n /**\n * The validation message. Only present while there is one, so a\n * `helperText` written before `{...field}` shows the rest of the time.\n */\n helperText?: string;\n /** Only present when the field or the whole form is disabled through the form. */\n disabled?: boolean;\n};\n\n/** Props for a control that holds a value: spread them last. */\nexport type FormFieldControlProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = FormFieldSharedProps & {\n /** The field's current value. */\n value: FieldPathValue<TFieldValues, TName>;\n /**\n * Writes a new value to the form. Loosely typed, like react-hook-form's own\n * `onChange`: a control reports the type it works in (a `Select` reports\n * `string`), which is often wider than the field's type (`\"no\" | \"se\"`).\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onValueChange: (value: any) => void;\n};\n\n/** Props for a control that is on or off (`Checkbox`): spread them last. */\nexport type FormFieldCheckedProps = FormFieldSharedProps & {\n /** Whether the field's value is truthy. */\n checked: boolean;\n /** Writes `true` or `false` to the form. */\n onCheckedChange: (checked: boolean) => void;\n};\n\nexport type FormFieldRenderProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n /** For controls with a value: `<Input {...field} />`. */\n field: FormFieldControlProps<TFieldValues, TName>;\n /** For controls that are on or off: `<Checkbox {...checkedField} />`. */\n checkedField: FormFieldCheckedProps;\n /** react-hook-form's state for this field (`error`, `isTouched`, `isDirty`, …). */\n fieldState: ControllerFieldState;\n /** react-hook-form's state for the whole form (`isSubmitting`, `errors`, …). */\n formState: UseFormStateReturn<TFieldValues>;\n};\n\nexport type FormFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n> = UseControllerProps<TFieldValues, TName, TTransformedValues> & {\n /** Renders the control. Spread `field` (or `checkedField`) onto it, last. */\n render: (props: FormFieldRenderProps<TFieldValues, TName>) => ReactNode;\n};\n\n/**\n * Binds one form control to react-hook-form.\n *\n * Every form control in the library takes the same props for its value, its\n * error state and its ref, so one binding fits them all: `FormField` reads\n * the field from the form and hands you those props to spread onto the\n * control. Everything else on the control (`label`, `options`, `placeholder`,\n * …) you write as usual.\n *\n * Takes `control` as a prop, or reads it from a surrounding `FormProvider`.\n * `name`, `rules`, `defaultValue`, `disabled` and `shouldUnregister` are\n * passed to react-hook-form's `useController` unchanged.\n *\n * ```tsx\n * <FormField\n * control={control}\n * name=\"email\"\n * rules={{ required: \"Skriv inn e-postadressen din.\" }}\n * render={({ field }) => <Input label=\"E-post\" type=\"email\" {...field} />}\n * />\n * ```\n */\nexport function FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n>({\n render,\n ...controller\n}: FormFieldProps<TFieldValues, TName, TTransformedValues>) {\n const form = useFormContext<TFieldValues, unknown, TTransformedValues>();\n if (!controller.control && !form) {\n throw new Error(\n `<FormField name=\"${controller.name}\"> needs a \\`control\\` prop or a surrounding <FormProvider>.`,\n );\n }\n\n const { field, fieldState, formState } = useController(controller);\n const message = fieldState.error?.message;\n\n const shared: FormFieldSharedProps = {\n name: field.name,\n onBlur: field.onBlur,\n ref: field.ref,\n error: fieldState.invalid,\n ...(message ? { helperText: message } : {}),\n ...(field.disabled !== undefined ? { disabled: field.disabled } : {}),\n };\n\n return render({\n field: { ...shared, value: field.value, onValueChange: field.onChange },\n checkedField: {\n ...shared,\n checked: Boolean(field.value),\n onCheckedChange: field.onChange,\n },\n fieldState,\n formState,\n });\n}\n"],"mappings":";;;AAuGA,SAAgB,EAId,EACA,WACA,GAAG,KACuD;CAC1D,IAAM,IAAO,EAA0D;CACvE,IAAI,CAAC,EAAW,WAAW,CAAC,GAC1B,MAAU,MACR,oBAAoB,EAAW,KAAK,6DACtC;CAGF,IAAM,EAAE,UAAO,eAAY,iBAAc,EAAc,CAAU,GAC3D,IAAU,EAAW,OAAO,SAE5B,IAA+B;EACnC,MAAM,EAAM;EACZ,QAAQ,EAAM;EACd,KAAK,EAAM;EACX,OAAO,EAAW;EAClB,GAAI,IAAU,EAAE,YAAY,EAAQ,IAAI,CAAC;EACzC,GAAI,EAAM,aAAa,KAAA,IAA2C,CAAC,IAAhC,EAAE,UAAU,EAAM,SAAS;CAChE;CAEA,OAAO,EAAO;EACZ,OAAO;GAAE,GAAG;GAAQ,OAAO,EAAM;GAAO,eAAe,EAAM;EAAS;EACtE,cAAc;GACZ,GAAG;GACH,SAAS,EAAQ,EAAM;GACvB,iBAAiB,EAAM;EACzB;EACA;EACA;CACF,CAAC;AACH"}
|
package/dist/tailwind.css
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
--color-bg-muted: var(--lea-palette-bg-muted);
|
|
20
20
|
--color-bg-contrast: var(--lea-palette-bg-contrast);
|
|
21
21
|
--color-bg-accent: var(--lea-palette-bg-accent);
|
|
22
|
+
--color-bg-overlay: var(--lea-palette-bg-overlay);
|
|
22
23
|
--color-text-base: var(--lea-palette-text-base);
|
|
23
24
|
--color-text-subtle: var(--lea-palette-text-subtle);
|
|
24
25
|
--color-text-muted: var(--lea-palette-text-muted);
|
|
@@ -29,22 +30,18 @@
|
|
|
29
30
|
--color-border-strong: var(--lea-palette-border-strong);
|
|
30
31
|
--color-border-accent: var(--lea-palette-border-accent);
|
|
31
32
|
--color-border-contrast: var(--lea-palette-border-contrast);
|
|
32
|
-
--color-primary-
|
|
33
|
-
--color-primary-
|
|
34
|
-
--color-primary-
|
|
35
|
-
--color-primary-
|
|
36
|
-
--color-
|
|
37
|
-
--color-
|
|
38
|
-
--color-
|
|
39
|
-
--color-
|
|
40
|
-
--color-
|
|
41
|
-
--color-
|
|
42
|
-
--color-
|
|
43
|
-
--color-
|
|
44
|
-
--color-secondary-main: var(--lea-palette-secondary-main);
|
|
45
|
-
--color-secondary-dark: var(--lea-palette-secondary-dark);
|
|
46
|
-
--color-secondary-light: var(--lea-palette-secondary-light);
|
|
47
|
-
--color-secondary-contrastText: var(--lea-palette-secondary-contrastText);
|
|
33
|
+
--color-primary-base: var(--lea-palette-primary-base);
|
|
34
|
+
--color-primary-hover: var(--lea-palette-primary-hover);
|
|
35
|
+
--color-primary-subtle: var(--lea-palette-primary-subtle);
|
|
36
|
+
--color-primary-contrast: var(--lea-palette-primary-contrast);
|
|
37
|
+
--color-secondary-base: var(--lea-palette-secondary-base);
|
|
38
|
+
--color-secondary-hover: var(--lea-palette-secondary-hover);
|
|
39
|
+
--color-secondary-subtle: var(--lea-palette-secondary-subtle);
|
|
40
|
+
--color-secondary-contrast: var(--lea-palette-secondary-contrast);
|
|
41
|
+
--color-tertiary-base: var(--lea-palette-tertiary-base);
|
|
42
|
+
--color-tertiary-hover: var(--lea-palette-tertiary-hover);
|
|
43
|
+
--color-tertiary-subtle: var(--lea-palette-tertiary-subtle);
|
|
44
|
+
--color-tertiary-contrast: var(--lea-palette-tertiary-contrast);
|
|
48
45
|
--color-status-error-base: var(--lea-palette-status-error-base);
|
|
49
46
|
--color-status-error-subtle: var(--lea-palette-status-error-subtle);
|
|
50
47
|
--color-status-warning-base: var(--lea-palette-status-warning-base);
|
|
@@ -97,6 +94,17 @@
|
|
|
97
94
|
--color-orange-800: var(--lea-color-orange-800);
|
|
98
95
|
--color-orange-900: var(--lea-color-orange-900);
|
|
99
96
|
--color-orange-950: var(--lea-color-orange-950);
|
|
97
|
+
--color-amber-50: var(--lea-color-amber-50);
|
|
98
|
+
--color-amber-100: var(--lea-color-amber-100);
|
|
99
|
+
--color-amber-200: var(--lea-color-amber-200);
|
|
100
|
+
--color-amber-300: var(--lea-color-amber-300);
|
|
101
|
+
--color-amber-400: var(--lea-color-amber-400);
|
|
102
|
+
--color-amber-500: var(--lea-color-amber-500);
|
|
103
|
+
--color-amber-600: var(--lea-color-amber-600);
|
|
104
|
+
--color-amber-700: var(--lea-color-amber-700);
|
|
105
|
+
--color-amber-800: var(--lea-color-amber-800);
|
|
106
|
+
--color-amber-900: var(--lea-color-amber-900);
|
|
107
|
+
--color-amber-950: var(--lea-color-amber-950);
|
|
100
108
|
--color-red-50: var(--lea-color-red-50);
|
|
101
109
|
--color-red-100: var(--lea-color-red-100);
|
|
102
110
|
--color-red-200: var(--lea-color-red-200);
|
|
@@ -163,7 +171,10 @@
|
|
|
163
171
|
--shadow-2xl: var(--lea-shadow-2xl);
|
|
164
172
|
--shadow-inner: var(--lea-shadow-inner);
|
|
165
173
|
|
|
166
|
-
/* Font
|
|
174
|
+
/* Font family: `font-sans`, which is also what Tailwind's preflight puts on the page */
|
|
175
|
+
--font-sans: var(--lea-font-family);
|
|
176
|
+
|
|
177
|
+
/* Font sizes (`text-md`, `text-2xl`). Deprecated: use the text styles below. */
|
|
167
178
|
--text-*: initial;
|
|
168
179
|
--text-xs: var(--lea-font-size-xs);
|
|
169
180
|
--text-sm: var(--lea-font-size-sm);
|
|
@@ -176,6 +187,64 @@
|
|
|
176
187
|
--text-5xl: var(--lea-font-size-5xl);
|
|
177
188
|
--text-6xl: var(--lea-font-size-6xl);
|
|
178
189
|
|
|
190
|
+
/* Text styles (`text-heading-lg`, `text-body-sm`): one utility sets size, line height, letter spacing and weight */
|
|
191
|
+
--text-display-sm: var(--lea-text-display-sm-font-size);
|
|
192
|
+
--text-display-sm--line-height: var(--lea-text-display-sm-line-height);
|
|
193
|
+
--text-display-sm--letter-spacing: var(--lea-text-display-sm-letter-spacing);
|
|
194
|
+
--text-display-sm--font-weight: var(--lea-text-display-sm-font-weight);
|
|
195
|
+
--text-display-md: var(--lea-text-display-md-font-size);
|
|
196
|
+
--text-display-md--line-height: var(--lea-text-display-md-line-height);
|
|
197
|
+
--text-display-md--letter-spacing: var(--lea-text-display-md-letter-spacing);
|
|
198
|
+
--text-display-md--font-weight: var(--lea-text-display-md-font-weight);
|
|
199
|
+
--text-heading-xs: var(--lea-text-heading-xs-font-size);
|
|
200
|
+
--text-heading-xs--line-height: var(--lea-text-heading-xs-line-height);
|
|
201
|
+
--text-heading-xs--letter-spacing: var(--lea-text-heading-xs-letter-spacing);
|
|
202
|
+
--text-heading-xs--font-weight: var(--lea-text-heading-xs-font-weight);
|
|
203
|
+
--text-heading-sm: var(--lea-text-heading-sm-font-size);
|
|
204
|
+
--text-heading-sm--line-height: var(--lea-text-heading-sm-line-height);
|
|
205
|
+
--text-heading-sm--letter-spacing: var(--lea-text-heading-sm-letter-spacing);
|
|
206
|
+
--text-heading-sm--font-weight: var(--lea-text-heading-sm-font-weight);
|
|
207
|
+
--text-heading-md: var(--lea-text-heading-md-font-size);
|
|
208
|
+
--text-heading-md--line-height: var(--lea-text-heading-md-line-height);
|
|
209
|
+
--text-heading-md--letter-spacing: var(--lea-text-heading-md-letter-spacing);
|
|
210
|
+
--text-heading-md--font-weight: var(--lea-text-heading-md-font-weight);
|
|
211
|
+
--text-heading-lg: var(--lea-text-heading-lg-font-size);
|
|
212
|
+
--text-heading-lg--line-height: var(--lea-text-heading-lg-line-height);
|
|
213
|
+
--text-heading-lg--letter-spacing: var(--lea-text-heading-lg-letter-spacing);
|
|
214
|
+
--text-heading-lg--font-weight: var(--lea-text-heading-lg-font-weight);
|
|
215
|
+
--text-heading-xl: var(--lea-text-heading-xl-font-size);
|
|
216
|
+
--text-heading-xl--line-height: var(--lea-text-heading-xl-line-height);
|
|
217
|
+
--text-heading-xl--letter-spacing: var(--lea-text-heading-xl-letter-spacing);
|
|
218
|
+
--text-heading-xl--font-weight: var(--lea-text-heading-xl-font-weight);
|
|
219
|
+
--text-body-xs: var(--lea-text-body-xs-font-size);
|
|
220
|
+
--text-body-xs--line-height: var(--lea-text-body-xs-line-height);
|
|
221
|
+
--text-body-xs--letter-spacing: var(--lea-text-body-xs-letter-spacing);
|
|
222
|
+
--text-body-xs--font-weight: var(--lea-text-body-xs-font-weight);
|
|
223
|
+
--text-body-sm: var(--lea-text-body-sm-font-size);
|
|
224
|
+
--text-body-sm--line-height: var(--lea-text-body-sm-line-height);
|
|
225
|
+
--text-body-sm--letter-spacing: var(--lea-text-body-sm-letter-spacing);
|
|
226
|
+
--text-body-sm--font-weight: var(--lea-text-body-sm-font-weight);
|
|
227
|
+
--text-body-md: var(--lea-text-body-md-font-size);
|
|
228
|
+
--text-body-md--line-height: var(--lea-text-body-md-line-height);
|
|
229
|
+
--text-body-md--letter-spacing: var(--lea-text-body-md-letter-spacing);
|
|
230
|
+
--text-body-md--font-weight: var(--lea-text-body-md-font-weight);
|
|
231
|
+
--text-body-lg: var(--lea-text-body-lg-font-size);
|
|
232
|
+
--text-body-lg--line-height: var(--lea-text-body-lg-line-height);
|
|
233
|
+
--text-body-lg--letter-spacing: var(--lea-text-body-lg-letter-spacing);
|
|
234
|
+
--text-body-lg--font-weight: var(--lea-text-body-lg-font-weight);
|
|
235
|
+
--text-label-sm: var(--lea-text-label-sm-font-size);
|
|
236
|
+
--text-label-sm--line-height: var(--lea-text-label-sm-line-height);
|
|
237
|
+
--text-label-sm--letter-spacing: var(--lea-text-label-sm-letter-spacing);
|
|
238
|
+
--text-label-sm--font-weight: var(--lea-text-label-sm-font-weight);
|
|
239
|
+
--text-label-md: var(--lea-text-label-md-font-size);
|
|
240
|
+
--text-label-md--line-height: var(--lea-text-label-md-line-height);
|
|
241
|
+
--text-label-md--letter-spacing: var(--lea-text-label-md-letter-spacing);
|
|
242
|
+
--text-label-md--font-weight: var(--lea-text-label-md-font-weight);
|
|
243
|
+
--text-label-lg: var(--lea-text-label-lg-font-size);
|
|
244
|
+
--text-label-lg--line-height: var(--lea-text-label-lg-line-height);
|
|
245
|
+
--text-label-lg--letter-spacing: var(--lea-text-label-lg-letter-spacing);
|
|
246
|
+
--text-label-lg--font-weight: var(--lea-text-label-lg-font-weight);
|
|
247
|
+
|
|
179
248
|
/* Font weights */
|
|
180
249
|
--font-weight-*: initial;
|
|
181
250
|
--font-weight-thin: var(--lea-font-weight-thin);
|
|
@@ -186,6 +255,23 @@
|
|
|
186
255
|
--font-weight-bold: var(--lea-font-weight-bold);
|
|
187
256
|
--font-weight-black: var(--lea-font-weight-black);
|
|
188
257
|
|
|
258
|
+
/* Line heights (`leading-tight`, `leading-normal`) */
|
|
259
|
+
--leading-*: initial;
|
|
260
|
+
--leading-none: var(--lea-line-height-none);
|
|
261
|
+
--leading-tight: var(--lea-line-height-tight);
|
|
262
|
+
--leading-snug: var(--lea-line-height-snug);
|
|
263
|
+
--leading-normal: var(--lea-line-height-normal);
|
|
264
|
+
|
|
265
|
+
/* State opacities, for `opacity-hover` and as a colour modifier: `bg-primary-base/hover`. Tailwind wants a percentage here. */
|
|
266
|
+
--opacity-hover: calc(var(--lea-opacity-hover) * 100%);
|
|
267
|
+
--opacity-pressed: calc(var(--lea-opacity-pressed) * 100%);
|
|
268
|
+
--opacity-highlight: calc(var(--lea-opacity-highlight) * 100%);
|
|
269
|
+
|
|
270
|
+
/* Durations (`duration-fast`, `duration-normal`) */
|
|
271
|
+
--transition-duration-fast: var(--lea-duration-fast);
|
|
272
|
+
--transition-duration-normal: var(--lea-duration-normal);
|
|
273
|
+
--transition-duration-emphasis: var(--lea-duration-emphasis);
|
|
274
|
+
|
|
189
275
|
/* Easings (`ease-standard`, `ease-spring`) */
|
|
190
276
|
--ease-*: initial;
|
|
191
277
|
--ease-standard: var(--lea-easing-standard);
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
export type ColorToken = "base" | "subtle" | "muted" | "contrast" | "accent";
|
|
2
|
-
export type BgColorToken = ColorToken;
|
|
2
|
+
export type BgColorToken = ColorToken | "overlay";
|
|
3
3
|
export type TextColorToken = ColorToken;
|
|
4
4
|
export type BorderColorToken = ColorToken;
|
|
5
|
-
export type BrandColorToken =
|
|
5
|
+
export type BrandColorToken = "base" | "hover" | "subtle" | "contrast";
|
|
6
6
|
export type StatusColorToken = "base" | "subtle";
|
|
7
|
-
export type ColorPath = `bg.${BgColorToken}` | `text.${TextColorToken}` | `border.${BorderColorToken}` | `primary.${BrandColorToken}` | `secondary.${BrandColorToken}` | `status.error.${StatusColorToken}` | `status.warning.${StatusColorToken}` | `status.info.${StatusColorToken}` | `status.success.${StatusColorToken}`;
|
|
7
|
+
export type ColorPath = `bg.${BgColorToken}` | `text.${TextColorToken}` | `border.${BorderColorToken}` | `primary.${BrandColorToken}` | `secondary.${BrandColorToken}` | `tertiary.${BrandColorToken}` | `status.error.${StatusColorToken}` | `status.warning.${StatusColorToken}` | `status.info.${StatusColorToken}` | `status.success.${StatusColorToken}`;
|
|
8
|
+
/**
|
|
9
|
+
* The values a component's `color` prop can take. Each names a group of colour
|
|
10
|
+
* tokens (a brand colour, a status, the neutrals), never a hue, so a rebrand
|
|
11
|
+
* changes the tokens and no call site. A component accepts the subset it has a
|
|
12
|
+
* design for: `ButtonColor`, `ChipColor`, `LinkColor` and so on.
|
|
13
|
+
*
|
|
14
|
+
* - `primary`, `secondary`, `tertiary`: the brand colours of the palette.
|
|
15
|
+
* - `neutral`: the greys, for something that should carry no meaning.
|
|
16
|
+
* - `success`, `info`, `warning`, `error`: the statuses.
|
|
17
|
+
* - `contrast`: for use on a dark surface.
|
|
18
|
+
*/
|
|
19
|
+
export type ColorRole = "primary" | "secondary" | "tertiary" | "neutral" | "success" | "info" | "warning" | "error" | "contrast";
|
|
8
20
|
/** Allowed values for MUI `Typography` `color` prop (semantic text tokens). */
|
|
9
21
|
export type TypographyColorToken = `text.${TextColorToken}`;
|
|
10
22
|
/** Common spacing scale factors (8px base via `theme.spacing` / `theme.space`). */
|
|
@@ -51,6 +51,19 @@ export declare const colors: {
|
|
|
51
51
|
readonly 900: "#611E0F";
|
|
52
52
|
readonly 950: "#401408";
|
|
53
53
|
};
|
|
54
|
+
readonly amber: {
|
|
55
|
+
readonly 50: "#FFF9EB";
|
|
56
|
+
readonly 100: "#FFEFC7";
|
|
57
|
+
readonly 200: "#FFE299";
|
|
58
|
+
readonly 300: "#FFCF5C";
|
|
59
|
+
readonly 400: "#F7A800";
|
|
60
|
+
readonly 500: "#D98F00";
|
|
61
|
+
readonly 600: "#B37400";
|
|
62
|
+
readonly 700: "#8C5A00";
|
|
63
|
+
readonly 800: "#6B4500";
|
|
64
|
+
readonly 900: "#4A3000";
|
|
65
|
+
readonly 950: "#2E1D00";
|
|
66
|
+
};
|
|
54
67
|
readonly red: {
|
|
55
68
|
readonly 50: "#FEF2F2";
|
|
56
69
|
readonly 100: "#FCDCDC";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The font stack, emitted as `--lea-font-family`.
|
|
3
|
+
*
|
|
4
|
+
* `ClashGrotesk` is the variable font declared in `theme/fonts.css`.
|
|
5
|
+
* `ClashGrotesk Fallback` is declared there too: Arial resized to Clash
|
|
6
|
+
* Grotesk's average letter width, so text keeps its place while the font file
|
|
7
|
+
* loads.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fontFamily = "\"ClashGrotesk\", \"ClashGrotesk Fallback\", sans-serif";
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first font-size scale, from before the text styles.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Use a text style (`textStyles`, `--lea-text-{role}-{size}-*`,
|
|
5
|
+
* `text-heading-lg`) or, for a size on its own, a step on the type scale
|
|
6
|
+
* (`fontStep`, `--lea-font-step-{n}`). Kept for the components that still use
|
|
7
|
+
* it, and removed in a later major.
|
|
8
|
+
*/
|
|
1
9
|
export declare const fontSizes: {
|
|
2
10
|
readonly xs: "0.75rem";
|
|
3
11
|
readonly sm: "0.875rem";
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export * from './breakpoints';
|
|
2
2
|
export * from './colors';
|
|
3
|
+
export * from './font-family';
|
|
3
4
|
export * from './font-sizes';
|
|
4
5
|
export * from './font-weights';
|
|
6
|
+
export * from './line-heights';
|
|
5
7
|
export * from './opacity';
|
|
6
8
|
export * from './palette';
|
|
7
9
|
export * from './shadows';
|
|
8
10
|
export * from './shape';
|
|
9
11
|
export * from './spacing';
|
|
12
|
+
export * from './text-styles';
|
|
10
13
|
export * from './transitions';
|
|
11
|
-
export * from './
|
|
14
|
+
export * from './type-scale';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unitless, so a line height follows whichever font size it lands on. `none`
|
|
3
|
+
* is for a display headline, `tight` for large headings and control labels,
|
|
4
|
+
* `snug` for small headings and `normal` for running text.
|
|
5
|
+
*/
|
|
6
|
+
export declare const lineHeights: {
|
|
7
|
+
readonly none: 1;
|
|
8
|
+
readonly tight: 1.25;
|
|
9
|
+
readonly snug: 1.4;
|
|
10
|
+
readonly normal: 1.5;
|
|
11
|
+
};
|
|
@@ -1 +1,7 @@
|
|
|
1
1
|
export declare const spacing: (factor: number) => string;
|
|
2
|
+
/**
|
|
3
|
+
* The steps emitted as `--lea-spacing-{step}`, the point of a half step written
|
|
4
|
+
* as a hyphen: `--lea-spacing-1-5` is `spacing(1.5)`. Half steps stop at 2.5
|
|
5
|
+
* and the gaps widen from there, so neighbouring steps stay visibly distinct.
|
|
6
|
+
*/
|
|
7
|
+
export declare const spacingSteps: readonly [0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { fontWeights } from './font-weights';
|
|
2
|
+
import { lineHeights } from './line-heights';
|
|
3
|
+
import { FontStep } from './type-scale';
|
|
4
|
+
type TextStyleDefinition = {
|
|
5
|
+
/** The step on the type scale, see type-scale.ts. */
|
|
6
|
+
step: FontStep;
|
|
7
|
+
fontWeight: keyof typeof fontWeights;
|
|
8
|
+
lineHeight: keyof typeof lineHeights;
|
|
9
|
+
letterSpacing: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Text styles, named `{role}-{size}` after what the text does, not after the
|
|
13
|
+
* element it sits in: `heading-lg` is an `h1` on one page and an `h3` on the
|
|
14
|
+
* next. Take the element from the page hierarchy and the style from the design.
|
|
15
|
+
*
|
|
16
|
+
* A style holds no values of its own. It points at a step on the type scale, a
|
|
17
|
+
* font weight and a line height, so a size is retuned in one place. `body` and
|
|
18
|
+
* `label` move one step at a time; `heading` and `display` move two, because
|
|
19
|
+
* neighbouring steps are too close to tell two headings apart.
|
|
20
|
+
*
|
|
21
|
+
* The Figma text styles `heading/lg` and so on mirror this file.
|
|
22
|
+
*/
|
|
23
|
+
export declare const textStyles: {
|
|
24
|
+
display: {
|
|
25
|
+
sm: TextStyleDefinition;
|
|
26
|
+
md: TextStyleDefinition;
|
|
27
|
+
};
|
|
28
|
+
heading: {
|
|
29
|
+
xs: TextStyleDefinition;
|
|
30
|
+
sm: TextStyleDefinition;
|
|
31
|
+
md: TextStyleDefinition;
|
|
32
|
+
lg: TextStyleDefinition;
|
|
33
|
+
xl: TextStyleDefinition;
|
|
34
|
+
};
|
|
35
|
+
body: {
|
|
36
|
+
xs: TextStyleDefinition;
|
|
37
|
+
sm: TextStyleDefinition;
|
|
38
|
+
md: TextStyleDefinition;
|
|
39
|
+
lg: TextStyleDefinition;
|
|
40
|
+
};
|
|
41
|
+
label: {
|
|
42
|
+
sm: TextStyleDefinition;
|
|
43
|
+
md: TextStyleDefinition;
|
|
44
|
+
lg: TextStyleDefinition;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
type TextStyles = typeof textStyles;
|
|
48
|
+
/** `"heading-lg"`, `"body-sm"` and so on. */
|
|
49
|
+
export type TextStyleToken = {
|
|
50
|
+
[Role in keyof TextStyles]: `${Role & string}-${keyof TextStyles[Role] & string}`;
|
|
51
|
+
}[keyof TextStyles];
|
|
52
|
+
/** Every style as `[name, definition]`, in the order above. */
|
|
53
|
+
export declare const textStyleEntries: (readonly [TextStyleToken, TextStyleDefinition])[];
|
|
54
|
+
/** The CSS values of a text style, for `sx` and theme files. */
|
|
55
|
+
export declare const resolveTextStyle: (name: TextStyleToken) => {
|
|
56
|
+
fontSize: string;
|
|
57
|
+
fontWeight: 200 | 300 | 400 | 500 | 600 | 700 | 800;
|
|
58
|
+
lineHeight: 1 | 1.25 | 1.5 | 1.4;
|
|
59
|
+
letterSpacing: string;
|
|
60
|
+
};
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The modular type scale behind the text styles: a font size is
|
|
3
|
+
* `base × ratio^step`. Step 0 is body text and the ratio is a major second.
|
|
4
|
+
*/
|
|
5
|
+
export declare const typeScale: {
|
|
6
|
+
readonly base: 16;
|
|
7
|
+
readonly ratio: 1.125;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A step in pixels, rounded to a whole pixel. Figma variables can't calculate,
|
|
11
|
+
* so rounding here is what lets `fontStep/6` in Figma and `--lea-font-step-6`
|
|
12
|
+
* in CSS hold the same number.
|
|
13
|
+
*/
|
|
14
|
+
export declare const fontStepPx: (step: number) => number;
|
|
15
|
+
export declare const fontStep: (step: number) => string;
|
|
16
|
+
/**
|
|
17
|
+
* The steps emitted as `--lea-font-step-{step}`. A step below body text spells
|
|
18
|
+
* out the minus sign: `--lea-font-step-minus-1` is `fontStep(-1)`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const fontSteps: readonly [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
21
|
+
export type FontStep = (typeof fontSteps)[number];
|
package/dist/theme/types.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { SxProps } from '@mui/material/styles';
|
|
2
1
|
export type ColorScaleTokens = typeof import('./tokens/colors').colors;
|
|
3
2
|
export type ColorScaleStep = keyof ColorScaleTokens["purple"];
|
|
3
|
+
/** The four steps every brand colour (`primary`, `secondary`, `tertiary`) has. */
|
|
4
|
+
export type BrandColor = {
|
|
5
|
+
base: string;
|
|
6
|
+
hover: string;
|
|
7
|
+
subtle: string;
|
|
8
|
+
contrast: string;
|
|
9
|
+
};
|
|
4
10
|
export type Palette = {
|
|
5
11
|
bg: {
|
|
6
12
|
base: string;
|
|
@@ -8,6 +14,8 @@ export type Palette = {
|
|
|
8
14
|
muted: string;
|
|
9
15
|
contrast: string;
|
|
10
16
|
accent: string;
|
|
17
|
+
/** The see-through layer behind a dialog or drawer. */
|
|
18
|
+
overlay: string;
|
|
11
19
|
};
|
|
12
20
|
text: {
|
|
13
21
|
base: string;
|
|
@@ -23,30 +31,12 @@ export type Palette = {
|
|
|
23
31
|
accent: string;
|
|
24
32
|
contrast: string;
|
|
25
33
|
};
|
|
26
|
-
purple:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
primary: {
|
|
33
|
-
main: string;
|
|
34
|
-
dark: string;
|
|
35
|
-
light: string;
|
|
36
|
-
contrastText: string;
|
|
37
|
-
};
|
|
38
|
-
teal: {
|
|
39
|
-
base: string;
|
|
40
|
-
hover: string;
|
|
41
|
-
subtle: string;
|
|
42
|
-
contrast: string;
|
|
43
|
-
};
|
|
44
|
-
secondary: {
|
|
45
|
-
main: string;
|
|
46
|
-
dark: string;
|
|
47
|
-
light: string;
|
|
48
|
-
contrastText: string;
|
|
49
|
-
};
|
|
34
|
+
/** Brand purple: the main action colour. */
|
|
35
|
+
primary: BrandColor;
|
|
36
|
+
/** Near-black: the second action colour. */
|
|
37
|
+
secondary: BrandColor;
|
|
38
|
+
/** Brand teal: progress and completion. */
|
|
39
|
+
tertiary: BrandColor;
|
|
50
40
|
status: {
|
|
51
41
|
error: {
|
|
52
42
|
base: string;
|
|
@@ -67,14 +57,13 @@ export type Palette = {
|
|
|
67
57
|
};
|
|
68
58
|
};
|
|
69
59
|
export type PaletteTokens = typeof import('./tokens/palette').palette;
|
|
70
|
-
/**
|
|
71
|
-
export type LeaBankTheme = import('@mui/material/styles').Theme;
|
|
72
|
-
/** Typed `SxProps` bound to the Lea Bank theme. */
|
|
73
|
-
export type LeaSxProps = SxProps<LeaBankTheme>;
|
|
60
|
+
/** @deprecated Use `TextStyleToken`. See `fontSizes`. */
|
|
74
61
|
export type FontSizeToken = keyof typeof import('./tokens/font-sizes').fontSizes;
|
|
75
62
|
export type ShapeToken = keyof typeof import('./tokens/shape').shape;
|
|
76
63
|
export type ShadowToken = keyof typeof import('./tokens/shadows').shadows;
|
|
77
64
|
export type FontWeightToken = keyof typeof import('./tokens/font-weights').fontWeights;
|
|
78
65
|
export type EasingToken = keyof typeof import('./tokens/transitions').easings;
|
|
79
66
|
export type DurationToken = keyof typeof import('./tokens/transitions').durations;
|
|
80
|
-
export type
|
|
67
|
+
export type LineHeightToken = keyof typeof import('./tokens/line-heights').lineHeights;
|
|
68
|
+
export type { TextStyleToken } from './tokens/text-styles';
|
|
69
|
+
export type { BgColorToken, BorderColorToken, BrandColorToken, ColorPath, ColorRole, ColorToken, SpacingFactor, StatusColorToken, TextColorToken, TypographyColorToken, } from './token-types';
|
|
@@ -22,3 +22,21 @@ export declare function isValidEmail(value: string): boolean;
|
|
|
22
22
|
* getEmailDomainSuggestions("alice@gm") // → ["alice@gmail.com"]
|
|
23
23
|
*/
|
|
24
24
|
export declare function getEmailDomainSuggestions(value: string, domains?: readonly string[]): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Whether two email addresses are the same, ignoring case and surrounding
|
|
27
|
+
* spaces, as for "the co-applicant must not be the main applicant". An empty
|
|
28
|
+
* address never matches.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isSameEmail(a: string | null | undefined, b: string | null | undefined): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Suggests a correction for a mistyped email domain, or `undefined` when there
|
|
33
|
+
* is nothing to suggest. It never changes a domain it knows, nor a domain that
|
|
34
|
+
* is merely uncommon (`anna@firma.se` stays).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* suggestEmailCorrection("anna@gnail.con") // → "anna@gmail.com"
|
|
38
|
+
* suggestEmailCorrection("anna@hotmial.com") // → "anna@hotmail.com"
|
|
39
|
+
* suggestEmailCorrection("anna@firma.con") // → "anna@firma.com"
|
|
40
|
+
* suggestEmailCorrection("anna@firma.se") // → undefined
|
|
41
|
+
*/
|
|
42
|
+
export declare function suggestEmailCorrection(value: string, domains?: readonly string[]): string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The national number of a mobile phone, per country. A number is a mobile
|
|
3
|
+
* when the whole national number matches.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MOBILE_PATTERNS: {
|
|
6
|
+
readonly SE: "7[023689]\\d{7}";
|
|
7
|
+
readonly FI: "4946\\d{2,6}|(?:4[0-8]|50)\\d{4,8}";
|
|
8
|
+
readonly NO: "(?:4[015-9]|9\\d)\\d{6}";
|
|
9
|
+
readonly ES: "96906(?:09|10)\\d\\d|(?:590(?:10[0-2]|600)|97390\\d)\\d{3}|(?:6\\d|7[1-48])\\d{7}";
|
|
10
|
+
};
|