@navikt/ds-react 2.1.1-next.1 → 2.1.2
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/_docs.json +480 -312
- package/esm/accordion/Accordion.d.ts +17 -0
- package/esm/accordion/AccordionContent.d.ts +10 -0
- package/esm/accordion/AccordionHeader.d.ts +10 -0
- package/esm/accordion/AccordionItem.d.ts +26 -0
- package/esm/accordion/index.d.ts +1 -0
- package/esm/alert/Alert.d.ts +31 -0
- package/esm/alert/index.d.ts +2 -0
- package/esm/button/Button.d.ts +39 -0
- package/esm/button/index.d.ts +2 -0
- package/esm/chat/Bubble.d.ts +26 -0
- package/esm/chat/Chat.d.ts +43 -0
- package/esm/chat/index.d.ts +1 -0
- package/esm/chips/Chips.d.ts +17 -0
- package/esm/chips/Removable.d.ts +23 -0
- package/esm/chips/Toggle.d.ts +13 -0
- package/esm/chips/index.d.ts +1 -0
- package/esm/date/DateInput.d.ts +25 -0
- package/esm/date/datepicker/DatePicker.d.ts +97 -0
- package/esm/date/datepicker/DatePickerStandalone.d.ts +12 -0
- package/esm/date/datepicker/DayButton.d.ts +3 -0
- package/esm/date/datepicker/Head.d.ts +3 -0
- package/esm/date/datepicker/caption/Caption.d.ts +4 -0
- package/esm/date/datepicker/caption/DropdownCaption.d.ts +4 -0
- package/esm/date/datepicker/caption/index.d.ts +2 -0
- package/esm/date/hooks/index.d.ts +8 -0
- package/esm/date/hooks/useDateInputContext.d.ts +18 -0
- package/esm/date/hooks/useDatepicker.d.ts +73 -0
- package/esm/date/hooks/useMonthPicker.d.ts +68 -0
- package/esm/date/hooks/useRangeDatepicker.d.ts +58 -0
- package/esm/date/hooks/useSharedMonthContext.d.ts +21 -0
- package/esm/date/index.d.ts +6 -0
- package/esm/date/monthpicker/MonthButton.d.ts +11 -0
- package/esm/date/monthpicker/MonthCaption.d.ts +3 -0
- package/esm/date/monthpicker/MonthPicker.d.ts +92 -0
- package/esm/date/monthpicker/MonthPickerStandalone.d.ts +11 -0
- package/esm/date/monthpicker/MonthSelector.d.ts +3 -0
- package/esm/date/utils/check-dates.d.ts +4 -0
- package/esm/date/utils/dates-disabled.d.ts +1 -0
- package/esm/date/utils/format-date.d.ts +1 -0
- package/esm/date/utils/get-dates.d.ts +2 -0
- package/esm/date/utils/get-initial-year.d.ts +5 -0
- package/esm/date/utils/index.d.ts +10 -0
- package/esm/date/utils/is-match.d.ts +4 -0
- package/esm/date/utils/labels.d.ts +6 -0
- package/esm/date/utils/locale.d.ts +2 -0
- package/esm/date/utils/navigation.d.ts +2 -0
- package/esm/date/utils/parse-date.d.ts +3 -0
- package/esm/form/ConfirmationPanel.d.ts +22 -0
- package/esm/form/Fieldset/Fieldset.d.ts +42 -0
- package/esm/form/Fieldset/index.d.ts +1 -0
- package/esm/form/Fieldset/useFieldset.d.ts +14 -0
- package/esm/form/Select.d.ts +26 -0
- package/esm/form/Switch.d.ts +27 -0
- package/esm/form/TextField.d.ts +31 -0
- package/esm/form/Textarea.d.ts +48 -0
- package/esm/form/checkbox/Checkbox.d.ts +36 -0
- package/esm/form/checkbox/CheckboxGroup.d.ts +28 -0
- package/esm/form/checkbox/index.d.ts +2 -0
- package/esm/form/checkbox/useCheckbox.d.ts +21 -0
- package/esm/form/error-summary/ErrorSummary.d.ts +27 -0
- package/esm/form/error-summary/ErrorSummaryItem.d.ts +11 -0
- package/esm/form/error-summary/index.d.ts +2 -0
- package/esm/form/index.d.ts +10 -0
- package/esm/form/radio/Radio.d.ts +18 -0
- package/esm/form/radio/RadioGroup.d.ts +38 -0
- package/esm/form/radio/index.d.ts +2 -0
- package/esm/form/radio/useRadio.d.ts +23 -0
- package/esm/form/search/Search.d.ts +57 -0
- package/esm/form/search/SearchButton.d.ts +11 -0
- package/esm/form/search/index.d.ts +1 -0
- package/esm/form/useFormField.d.ts +44 -0
- package/esm/grid/Cell.d.ts +26 -0
- package/esm/grid/ContentContainer.d.ts +9 -0
- package/esm/grid/Grid.d.ts +9 -0
- package/esm/grid/index.d.ts +3 -0
- package/esm/guide-panel/Guide.d.ts +14 -0
- package/esm/guide-panel/GuidePanel.d.ts +18 -0
- package/esm/guide-panel/Illustration.d.ts +8 -0
- package/esm/guide-panel/index.d.ts +3 -0
- package/esm/help-text/HelpText.d.ts +17 -0
- package/esm/help-text/index.d.ts +2 -0
- package/esm/index.d.ts +27 -0
- package/esm/link/Link.d.ts +10 -0
- package/esm/link/index.d.ts +2 -0
- package/esm/link-panel/LinkPanel.d.ts +22 -0
- package/esm/link-panel/LinkPanelDescription.d.ts +7 -0
- package/esm/link-panel/LinkPanelTitle.d.ts +8 -0
- package/esm/link-panel/index.d.ts +2 -0
- package/esm/loader/Loader.d.ts +27 -0
- package/esm/loader/index.d.ts +2 -0
- package/esm/modal/Modal.d.ts +63 -0
- package/esm/modal/ModalContent.d.ts +10 -0
- package/esm/modal/index.d.ts +2 -0
- package/esm/pagination/Pagination.d.ts +53 -0
- package/esm/pagination/PaginationItem.d.ts +22 -0
- package/esm/pagination/index.d.ts +1 -0
- package/esm/panel/Panel.d.ts +16 -0
- package/esm/panel/index.d.ts +2 -0
- package/esm/popover/Popover.d.ts +47 -0
- package/esm/popover/PopoverContent.d.ts +10 -0
- package/esm/popover/index.d.ts +2 -0
- package/esm/provider/Provider.d.ts +20 -0
- package/esm/provider/index.d.ts +1 -0
- package/esm/read-more/ReadMore.d.ts +28 -0
- package/esm/read-more/index.d.ts +2 -0
- package/esm/stepper/Step.d.ts +28 -0
- package/esm/stepper/Stepper.d.ts +41 -0
- package/esm/stepper/index.d.ts +1 -0
- package/esm/table/Body.d.ts +7 -0
- package/esm/table/ColumnHeader.d.ts +17 -0
- package/esm/table/DataCell.d.ts +12 -0
- package/esm/table/ExpandableRow.d.ts +41 -0
- package/esm/table/Header.d.ts +7 -0
- package/esm/table/HeaderCell.d.ts +13 -0
- package/esm/table/Row.d.ts +17 -0
- package/esm/table/Table.d.ts +49 -0
- package/esm/table/index.d.ts +8 -0
- package/esm/tabs/Tab.d.ts +19 -0
- package/esm/tabs/TabList.d.ts +10 -0
- package/esm/tabs/TabPanel.d.ts +14 -0
- package/esm/tabs/Tabs.d.ts +52 -0
- package/esm/tabs/index.d.ts +4 -0
- package/esm/tag/Tag.d.ts +14 -0
- package/esm/tag/index.d.ts +1 -0
- package/esm/toggle-group/ToggleGroup.d.ts +38 -0
- package/esm/toggle-group/ToggleItem.d.ts +14 -0
- package/esm/toggle-group/index.d.ts +2 -0
- package/esm/tooltip/Tooltip.d.ts +53 -0
- package/esm/tooltip/index.d.ts +1 -0
- package/esm/typography/BodyLong.d.ts +19 -0
- package/esm/typography/BodyShort.d.ts +19 -0
- package/esm/typography/Detail.d.ts +22 -0
- package/esm/typography/ErrorMessage.d.ts +19 -0
- package/esm/typography/Heading.d.ts +24 -0
- package/esm/typography/Ingress.d.ts +14 -0
- package/esm/typography/Label.d.ts +19 -0
- package/esm/typography/index.d.ts +7 -0
- package/esm/util/AnimateHeight.d.ts +10 -0
- package/esm/util/OverridableComponent.d.ts +7 -0
- package/esm/util/TextareaAutoSize.d.ts +14 -0
- package/esm/util/debounce.d.ts +4 -0
- package/esm/util/index.d.ts +13 -0
- package/esm/util/mergeRefs.d.ts +2 -0
- package/esm/util/useId.d.ts +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DateRange } from "react-day-picker";
|
|
3
|
+
import { DateInputProps } from "../DateInput";
|
|
4
|
+
import { DatePickerProps } from "../datepicker/DatePicker";
|
|
5
|
+
import { DateValidationT, UseDatepickerOptions } from "./useDatepicker";
|
|
6
|
+
export type RangeValidationT = {
|
|
7
|
+
from: DateValidationT;
|
|
8
|
+
to: DateValidationT & {
|
|
9
|
+
isBeforeFrom?: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
interface UseRangeDatepickerOptions extends Omit<UseDatepickerOptions, "defaultSelected" | "onDateChange" | "onValidate"> {
|
|
13
|
+
/**
|
|
14
|
+
* The initially selected DateRange
|
|
15
|
+
*/
|
|
16
|
+
defaultSelected?: DateRange;
|
|
17
|
+
/**
|
|
18
|
+
* Callback for changed state
|
|
19
|
+
*/
|
|
20
|
+
onRangeChange?: (val?: DateRange) => void;
|
|
21
|
+
/**
|
|
22
|
+
* validation-callback
|
|
23
|
+
*/
|
|
24
|
+
onValidate?: (val: RangeValidationT) => void;
|
|
25
|
+
}
|
|
26
|
+
interface UseRangeDatepickerValue {
|
|
27
|
+
/**
|
|
28
|
+
* Use: <DatePicker {...datepickerProps}/>
|
|
29
|
+
*/
|
|
30
|
+
datepickerProps: DatePickerProps;
|
|
31
|
+
/**
|
|
32
|
+
* Use: <DatePicker.Input label="from" {...fromInputProps}/>
|
|
33
|
+
*/
|
|
34
|
+
fromInputProps: Pick<DateInputProps, "onChange" | "onFocus" | "onBlur" | "value"> & {
|
|
35
|
+
ref: React.RefObject<HTMLInputElement>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Use: <DatePicker.Input label="to" {...toInputProps}/>
|
|
39
|
+
*/
|
|
40
|
+
toInputProps: Pick<DateInputProps, "onChange" | "onFocus" | "onBlur" | "value"> & {
|
|
41
|
+
ref: React.RefObject<HTMLInputElement>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Resets all states (callback)
|
|
45
|
+
*/
|
|
46
|
+
reset: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Currently selected DateRange
|
|
49
|
+
* Up to user to validate values
|
|
50
|
+
*/
|
|
51
|
+
selectedRange?: DateRange;
|
|
52
|
+
/**
|
|
53
|
+
* Manually override currently selected day
|
|
54
|
+
*/
|
|
55
|
+
setSelected: (date?: DateRange) => void;
|
|
56
|
+
}
|
|
57
|
+
export declare const useRangeDatepicker: (opt?: UseRangeDatepickerOptions) => UseRangeDatepickerValue;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Matcher } from "../utils";
|
|
3
|
+
export type SharedMonthContextType = {
|
|
4
|
+
hasDropdown: boolean;
|
|
5
|
+
year: Date;
|
|
6
|
+
toYear: (date: Date) => void;
|
|
7
|
+
disabled: Matcher[];
|
|
8
|
+
selected?: Date;
|
|
9
|
+
onSelect: (v?: Date) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const SharedMonthContext: React.Context<SharedMonthContextType>;
|
|
12
|
+
export declare const useSharedMonthContext: () => SharedMonthContextType;
|
|
13
|
+
export declare const SharedMonthProvider: ({ children, dropdownCaption, disabled, selected, onSelect, year: _year, onYearChange, }: {
|
|
14
|
+
children: any;
|
|
15
|
+
dropdownCaption: any;
|
|
16
|
+
disabled: any;
|
|
17
|
+
selected: any;
|
|
18
|
+
onSelect: any;
|
|
19
|
+
year: any;
|
|
20
|
+
onYearChange: any;
|
|
21
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DateInputProps } from "./DateInput";
|
|
2
|
+
export { DatePickerProps, default as UNSAFE_DatePicker, } from "./datepicker/DatePicker";
|
|
3
|
+
export { DatePickerStandaloneProps } from "./datepicker/DatePickerStandalone";
|
|
4
|
+
export { MonthPickerStandaloneProps } from "./monthpicker/MonthPickerStandalone";
|
|
5
|
+
export { UNSAFE_useDatepicker, UNSAFE_useMonthpicker, UNSAFE_useRangeDatepicker, RangeValidationT, DateValidationT, MonthValidationT, } from "./hooks";
|
|
6
|
+
export { default as UNSAFE_MonthPicker, MonthPickerProps, } from "./monthpicker/MonthPicker";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface MonthType {
|
|
3
|
+
month: Date;
|
|
4
|
+
months: Date[];
|
|
5
|
+
focus: Date | undefined;
|
|
6
|
+
setFocus: Function;
|
|
7
|
+
tabRoot?: Date;
|
|
8
|
+
setTabRoot: Function;
|
|
9
|
+
}
|
|
10
|
+
export declare const MonthButton: ({ month, months, focus, setFocus, tabRoot, setTabRoot, }: MonthType) => JSX.Element;
|
|
11
|
+
export default MonthButton;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DateInputType } from "../DateInput";
|
|
3
|
+
import { Matcher } from "../utils";
|
|
4
|
+
import { MonthPickerStandaloneType } from "./MonthPickerStandalone";
|
|
5
|
+
export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Element monthpicker anchors to. Use <MonthPicker.Input /> for built-in toggle,
|
|
8
|
+
* or make your own with the open/onClose props
|
|
9
|
+
*/
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Classname for datepicker in popover
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Classname for wrapper
|
|
17
|
+
*/
|
|
18
|
+
wrapperClassName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The earliest month to start navigation.
|
|
21
|
+
*/
|
|
22
|
+
fromDate?: Date;
|
|
23
|
+
/**
|
|
24
|
+
* The latest day to end navigation.
|
|
25
|
+
*/
|
|
26
|
+
toDate?: Date;
|
|
27
|
+
/**
|
|
28
|
+
* Changes monthpicker locale
|
|
29
|
+
* @default "nb" (norsk bokmål)
|
|
30
|
+
*/
|
|
31
|
+
locale?: "nb" | "nn" | "en";
|
|
32
|
+
/**
|
|
33
|
+
* Display dropdown for choosing year. Needs `fromDate` + `toDate` to work.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
dropdownCaption?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Apply the disabled modifier to the matching months. Uses a subset of React Day Picker Matcher type. https://react-day-picker.js.org/api/types/Matcher
|
|
39
|
+
*/
|
|
40
|
+
disabled?: Matcher[];
|
|
41
|
+
/**
|
|
42
|
+
* Controlled selected-month
|
|
43
|
+
*/
|
|
44
|
+
selected?: Date;
|
|
45
|
+
/**
|
|
46
|
+
* Default selected month.
|
|
47
|
+
*/
|
|
48
|
+
defaultSelected?: Date;
|
|
49
|
+
/**
|
|
50
|
+
* Open state for user-controlled state. Component controlled by default
|
|
51
|
+
*/
|
|
52
|
+
open?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* onClose callback for user-controlled state
|
|
55
|
+
*/
|
|
56
|
+
onClose?: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* onOpenToggle callback for user-controlled-state. Only called if `<MonthPicker.Input />` is used
|
|
59
|
+
*/
|
|
60
|
+
onOpenToggle?: () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Callback for user-controlled state
|
|
63
|
+
*/
|
|
64
|
+
onMonthSelect?: Function;
|
|
65
|
+
/**
|
|
66
|
+
* Used to set visible year programmatically. Component controlled by default
|
|
67
|
+
*/
|
|
68
|
+
year?: Date;
|
|
69
|
+
/**
|
|
70
|
+
* Event fired when the user navigates between years.
|
|
71
|
+
*/
|
|
72
|
+
onYearChange?: (y?: Date) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Avoid using if possible!
|
|
75
|
+
* Changes what CSS position property to use
|
|
76
|
+
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
77
|
+
* @default "absolute"
|
|
78
|
+
*/
|
|
79
|
+
strategy?: "absolute" | "fixed";
|
|
80
|
+
}
|
|
81
|
+
interface MonthPickerComponent extends React.ForwardRefExoticComponent<MonthPickerProps> {
|
|
82
|
+
/**
|
|
83
|
+
* Variant without popover
|
|
84
|
+
*/
|
|
85
|
+
Standalone: MonthPickerStandaloneType;
|
|
86
|
+
/**
|
|
87
|
+
* Built-in Inputfield
|
|
88
|
+
*/
|
|
89
|
+
Input: DateInputType;
|
|
90
|
+
}
|
|
91
|
+
export declare const MonthPicker: MonthPickerComponent;
|
|
92
|
+
export default MonthPicker;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MonthPickerProps } from "./MonthPicker";
|
|
3
|
+
export interface MonthPickerStandaloneProps extends Omit<MonthPickerProps, "open" | "onClose" | "onOpenToggle" | "wrapperClassName" | "strategy"> {
|
|
4
|
+
/**
|
|
5
|
+
* Monthpicker classname
|
|
6
|
+
*/
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export type MonthPickerStandaloneType = React.ForwardRefExoticComponent<MonthPickerStandaloneProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export declare const MonthPickerStandalone: React.ForwardRefExoticComponent<MonthPickerStandaloneProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export default MonthPickerStandalone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const disableDate: (disabledSelection: Date | Array<any>, date: Date) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatDateForInput: (date: Date, locale: Locale, type: "date" | "month", inputFormat?: string) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { formatDateForInput } from "./format-date";
|
|
2
|
+
export { getMonths, getYears } from "./get-dates";
|
|
3
|
+
export { labelMonthDropdown, labelYearDropdown, labels, labelNextYear, labelPrevYear, } from "./labels";
|
|
4
|
+
export { INPUT_DATE_STRING_FORMAT_DATE, INPUT_DATE_STRING_FORMAT_MONTH, parseDate, } from "./parse-date";
|
|
5
|
+
export { getLocaleFromString } from "./locale";
|
|
6
|
+
export { disableDate } from "./dates-disabled";
|
|
7
|
+
export { dateIsInCurrentMonth, isValidDate, hasNextYear } from "./check-dates";
|
|
8
|
+
export { getInitialYear } from "./get-initial-year";
|
|
9
|
+
export { isMatch, isDateInRange, Matcher } from "./is-match";
|
|
10
|
+
export { nextEnabled } from "./navigation";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DateAfter, DateBefore, DateRange } from "react-day-picker";
|
|
2
|
+
export type Matcher = ((date: Date) => boolean) | Date | Date[] | DateRange | DateBefore | DateAfter;
|
|
3
|
+
export declare function isMatch(day: Date, matchers: Matcher[]): boolean;
|
|
4
|
+
export declare function isDateInRange(date: Date, range: DateRange): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Labels } from "react-day-picker";
|
|
2
|
+
export declare const labelYearDropdown: (locale: Locale) => "År" | "Year";
|
|
3
|
+
export declare const labelMonthDropdown: (locale: Locale) => "Måned" | "Månad" | "Month";
|
|
4
|
+
export declare const labelNextYear: (localeCode: string | undefined) => "Gå til neste måned" | "Gå til neste år" | "Go to next year";
|
|
5
|
+
export declare const labelPrevYear: (localeCode: string | undefined) => string;
|
|
6
|
+
export declare const labels: Partial<Labels>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CheckboxProps } from "..";
|
|
3
|
+
export interface ConfirmationPanelProps extends Omit<CheckboxProps, "children" | "indeterminate" | "hideLabel" | "error"> {
|
|
4
|
+
/**
|
|
5
|
+
* Additional information on panel
|
|
6
|
+
*/
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Checkbox label
|
|
10
|
+
*/
|
|
11
|
+
label: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Error message for element
|
|
14
|
+
*/
|
|
15
|
+
error?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Override internal errorId
|
|
18
|
+
*/
|
|
19
|
+
errorId?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const ConfirmationPanel: React.ForwardRefExoticComponent<ConfirmationPanelProps & React.RefAttributes<HTMLInputElement>>;
|
|
22
|
+
export default ConfirmationPanel;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { FieldsetHTMLAttributes } from "react";
|
|
2
|
+
import { FormFieldProps } from "../useFormField";
|
|
3
|
+
export type FieldsetContextProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Error message applied to element,
|
|
6
|
+
*/
|
|
7
|
+
error?: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Overrides internal errorId
|
|
10
|
+
*/
|
|
11
|
+
errorId: string;
|
|
12
|
+
/**
|
|
13
|
+
* Changes paddings, margins and font-sizes
|
|
14
|
+
*/
|
|
15
|
+
size: "medium" | "small";
|
|
16
|
+
/**
|
|
17
|
+
* Sets fieldset and all form-children to disabled
|
|
18
|
+
*/
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare const FieldsetContext: React.Context<FieldsetContextProps | null>;
|
|
22
|
+
export interface FieldsetProps extends FormFieldProps, FieldsetHTMLAttributes<HTMLFieldSetElement> {
|
|
23
|
+
/**
|
|
24
|
+
* FormFields in Fieldset
|
|
25
|
+
*/
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Fieldset legend
|
|
29
|
+
*/
|
|
30
|
+
legend: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* If enabled shows the legend and description for screenreaders only
|
|
33
|
+
*/
|
|
34
|
+
hideLegend?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Toggles error propagation to child-elements
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
errorPropagation?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare const Fieldset: React.ForwardRefExoticComponent<FieldsetProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
42
|
+
export default Fieldset;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Fieldset, FieldsetProps, FieldsetContext, } from "./Fieldset";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles props for Fieldset in context with parent Fieldset.
|
|
3
|
+
*/
|
|
4
|
+
export declare const useFieldset: (props: any) => {
|
|
5
|
+
inputProps: {
|
|
6
|
+
"aria-invalid": boolean;
|
|
7
|
+
"aria-describedby": string | undefined;
|
|
8
|
+
};
|
|
9
|
+
showErrorMsg: boolean;
|
|
10
|
+
hasError: boolean;
|
|
11
|
+
errorId: string;
|
|
12
|
+
inputDescriptionId: string;
|
|
13
|
+
size: "medium" | "small";
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { SelectHTMLAttributes } from "react";
|
|
2
|
+
import { FormFieldProps } from "./useFormField";
|
|
3
|
+
export interface SelectProps extends FormFieldProps, Omit<SelectHTMLAttributes<HTMLSelectElement>, "size"> {
|
|
4
|
+
/**
|
|
5
|
+
* Collection of <option />-elements
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Exposes the HTML size attribute
|
|
10
|
+
*/
|
|
11
|
+
htmlSize?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Label for select
|
|
14
|
+
*/
|
|
15
|
+
label: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* If enabled shows the label and description for screenreaders only
|
|
18
|
+
*/
|
|
19
|
+
hideLabel?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Sets inline-style on select wrapper
|
|
22
|
+
*/
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
}
|
|
25
|
+
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
|
|
26
|
+
export default Select;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { FormFieldProps } from "./useFormField";
|
|
3
|
+
export interface SwitchProps extends Omit<FormFieldProps, "error" | "errorId">, Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
4
|
+
/**
|
|
5
|
+
* Switch-label
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* If enabled shows the label and description for screenreaders only
|
|
10
|
+
*/
|
|
11
|
+
hideLabel?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Toggles loading state with loader-component on switch
|
|
14
|
+
*/
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Positions switch on left/right side of label
|
|
18
|
+
* @default "left"
|
|
19
|
+
*/
|
|
20
|
+
position?: "left" | "right";
|
|
21
|
+
/**
|
|
22
|
+
* Adds a description to extend labling of Switch
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
|
|
27
|
+
export default Switch;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { FormFieldProps } from "./useFormField";
|
|
3
|
+
export interface TextFieldProps extends FormFieldProps, Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
4
|
+
/**
|
|
5
|
+
* Controlled value
|
|
6
|
+
*/
|
|
7
|
+
value?: string | number;
|
|
8
|
+
/**
|
|
9
|
+
* Defaults input-value without needing controlled-state
|
|
10
|
+
*/
|
|
11
|
+
defaultValue?: string | number;
|
|
12
|
+
/**
|
|
13
|
+
* Exposes the HTML size attribute
|
|
14
|
+
*/
|
|
15
|
+
htmlSize?: number;
|
|
16
|
+
/**
|
|
17
|
+
* If enabled shows the label and description for screenreaders only
|
|
18
|
+
*/
|
|
19
|
+
hideLabel?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* TextField label
|
|
22
|
+
*/
|
|
23
|
+
label: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Type of form control. Picking the correct type helps user fill inn their required information
|
|
26
|
+
* @default "text"
|
|
27
|
+
*/
|
|
28
|
+
type?: "email" | "number" | "password" | "tel" | "text" | "url";
|
|
29
|
+
}
|
|
30
|
+
export declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
31
|
+
export default TextField;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FormFieldProps } from "./useFormField";
|
|
3
|
+
/**
|
|
4
|
+
* TODO: Mulighet for lokalisering av sr-only/counter text
|
|
5
|
+
*/
|
|
6
|
+
export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
7
|
+
/**
|
|
8
|
+
* Allowed character-count for content
|
|
9
|
+
* @note This is just a visual validator, you need to set actual character-limits if needed
|
|
10
|
+
*/
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Controlled value
|
|
14
|
+
*/
|
|
15
|
+
value?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Defaults input-value without needing controlled-state
|
|
18
|
+
*/
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Maximum number of character rows to display.
|
|
22
|
+
* @bug Internal scrolling with `maxLength` scrolls over maxLength-text
|
|
23
|
+
*/
|
|
24
|
+
maxRows?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Minimum number of character-rows to display when empty.
|
|
27
|
+
*/
|
|
28
|
+
minRows?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Textarea label
|
|
31
|
+
*/
|
|
32
|
+
label: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* If enabled shows the label and description for screenreaders only
|
|
35
|
+
*/
|
|
36
|
+
hideLabel?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Enables resizing of field
|
|
39
|
+
*/
|
|
40
|
+
resize?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
43
|
+
export declare const Counter: ({ maxLength, currentLength, size }: {
|
|
44
|
+
maxLength: any;
|
|
45
|
+
currentLength: any;
|
|
46
|
+
size: any;
|
|
47
|
+
}) => JSX.Element;
|
|
48
|
+
export default Textarea;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { FormFieldProps } from "../useFormField";
|
|
3
|
+
export interface CheckboxProps extends FormFieldProps, Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "value"> {
|
|
4
|
+
/**
|
|
5
|
+
* Adds error indication on checkbox
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
error?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Id for error resulting in checkbox having error
|
|
11
|
+
*/
|
|
12
|
+
errorId?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Checkbox label
|
|
15
|
+
*/
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Hides label and makes it viewable for screen-readers only.
|
|
19
|
+
*/
|
|
20
|
+
hideLabel?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The value of the HTML element.
|
|
23
|
+
*/
|
|
24
|
+
value?: any;
|
|
25
|
+
/**
|
|
26
|
+
* Specify whether the Checkbox is in an indeterminate state
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
indeterminate?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Adds a description to extend labling of Checkbox
|
|
32
|
+
*/
|
|
33
|
+
description?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
36
|
+
export default Checkbox;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FieldsetProps } from "..";
|
|
3
|
+
export interface CheckboxGroupState {
|
|
4
|
+
readonly defaultValue?: readonly any[];
|
|
5
|
+
readonly value?: readonly any[];
|
|
6
|
+
toggleValue(value: any): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const CheckboxGroupContext: React.Context<CheckboxGroupState | null>;
|
|
9
|
+
export interface CheckboxGroupProps extends Omit<FieldsetProps, "onChange" | "errorPropagation" | "defaultValue"> {
|
|
10
|
+
/**
|
|
11
|
+
* Collection of <Checkbox/>
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Controlled state for checkboxes.
|
|
16
|
+
*/
|
|
17
|
+
value?: any[];
|
|
18
|
+
/**
|
|
19
|
+
* Default checked checkboxes on render
|
|
20
|
+
*/
|
|
21
|
+
defaultValue?: any[];
|
|
22
|
+
/**
|
|
23
|
+
* Returns current checked checkboxes in group
|
|
24
|
+
*/
|
|
25
|
+
onChange?: (value: any[]) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const CheckboxGroup: React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
28
|
+
export default CheckboxGroup;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CheckboxProps } from "../..";
|
|
2
|
+
/**
|
|
3
|
+
* Handles props for Checkboxes in context with Fieldset and CheckboxGroup
|
|
4
|
+
*/
|
|
5
|
+
declare const useCheckbox: ({ children, ...props }: CheckboxProps) => {
|
|
6
|
+
inputProps: {
|
|
7
|
+
checked: boolean | undefined;
|
|
8
|
+
defaultChecked: boolean | undefined;
|
|
9
|
+
onChange: (e: any) => void;
|
|
10
|
+
id: string;
|
|
11
|
+
"aria-invalid": boolean;
|
|
12
|
+
"aria-describedby": string | undefined;
|
|
13
|
+
disabled: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
showErrorMsg: boolean;
|
|
16
|
+
hasError: boolean;
|
|
17
|
+
errorId: string;
|
|
18
|
+
inputDescriptionId: string;
|
|
19
|
+
size: "medium" | "small";
|
|
20
|
+
};
|
|
21
|
+
export default useCheckbox;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from "react";
|
|
2
|
+
import { ErrorSummaryItemType } from "./ErrorSummaryItem";
|
|
3
|
+
export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Collectipn of ErrorSummary.Item
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Changes padding and font-sizes
|
|
10
|
+
* @default "medium"
|
|
11
|
+
*/
|
|
12
|
+
size?: "medium" | "small";
|
|
13
|
+
/**
|
|
14
|
+
* Heading above links
|
|
15
|
+
*/
|
|
16
|
+
heading?: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Allows setting a different HTML h-tag
|
|
19
|
+
* @default "h2"
|
|
20
|
+
*/
|
|
21
|
+
headingTag?: React.ElementType<any>;
|
|
22
|
+
}
|
|
23
|
+
interface ErrorSummaryComponent extends React.ForwardRefExoticComponent<ErrorSummaryProps & React.RefAttributes<HTMLDivElement>> {
|
|
24
|
+
Item: ErrorSummaryItemType;
|
|
25
|
+
}
|
|
26
|
+
export declare const ErrorSummary: ErrorSummaryComponent;
|
|
27
|
+
export default ErrorSummary;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OverridableComponent } from "../..";
|
|
3
|
+
export interface ErrorSummaryItemProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Link text
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export type ErrorSummaryItemType = OverridableComponent<ErrorSummaryItemProps, HTMLAnchorElement>;
|
|
10
|
+
export declare const ErrorSummaryItem: ErrorSummaryItemType;
|
|
11
|
+
export default ErrorSummaryItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, } from "./checkbox";
|
|
2
|
+
export { ConfirmationPanelProps, default as ConfirmationPanel, } from "./ConfirmationPanel";
|
|
3
|
+
export { ErrorSummary, ErrorSummaryProps } from "./error-summary";
|
|
4
|
+
export { Fieldset, FieldsetContext, FieldsetProps } from "./Fieldset";
|
|
5
|
+
export { Radio, RadioGroup, RadioGroupProps, RadioProps } from "./radio";
|
|
6
|
+
export { Search, SearchClearEvent, SearchProps } from "./search";
|
|
7
|
+
export { default as Select, SelectProps } from "./Select";
|
|
8
|
+
export { default as Switch, SwitchProps } from "./Switch";
|
|
9
|
+
export { Counter, default as Textarea, TextareaProps } from "./Textarea";
|
|
10
|
+
export { default as TextField, TextFieldProps } from "./TextField";
|