@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,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AccordionItemType } from "./AccordionItem";
|
|
3
|
+
import { AccordionContentType } from "./AccordionContent";
|
|
4
|
+
import { AccordionHeaderType } from "./AccordionHeader";
|
|
5
|
+
interface AccordionComponent extends React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<HTMLDivElement>> {
|
|
6
|
+
Item: AccordionItemType;
|
|
7
|
+
Header: AccordionHeaderType;
|
|
8
|
+
Content: AccordionContentType;
|
|
9
|
+
}
|
|
10
|
+
export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
/**
|
|
12
|
+
* Instances of Accordion.Item
|
|
13
|
+
*/
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare const Accordion: AccordionComponent;
|
|
17
|
+
export default Accordion;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface AccordionContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Content inside Accordion.Content
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export type AccordionContentType = React.ForwardRefExoticComponent<AccordionContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
declare const AccordionContent: AccordionContentType;
|
|
10
|
+
export default AccordionContent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface AccordionHeaderProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Text inside Accordion.Header
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export type AccordionHeaderType = React.ForwardRefExoticComponent<AccordionHeaderProps & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
declare const AccordionHeader: AccordionHeaderType;
|
|
10
|
+
export default AccordionHeader;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Content in Accordion.Item
|
|
5
|
+
* Should include one Accordion.Header and one Accordion.Content
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Controlled open-state
|
|
10
|
+
* Using this removes automatic control of open-state
|
|
11
|
+
*/
|
|
12
|
+
open?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Defaults the accordion to open if not controlled
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
defaultOpen?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type AccordionItemType = React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export interface AccordionItemContextProps {
|
|
21
|
+
open: boolean;
|
|
22
|
+
toggleOpen: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const AccordionItemContext: React.Context<AccordionItemContextProps | null>;
|
|
25
|
+
declare const AccordionItem: AccordionItemType;
|
|
26
|
+
export default AccordionItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AccordionProps, default as Accordion } from "./Accordion";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Alert content
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Changes colors and icon usage when changed
|
|
9
|
+
*/
|
|
10
|
+
variant: "error" | "warning" | "info" | "success";
|
|
11
|
+
/**
|
|
12
|
+
* Changes padding and font-sizes
|
|
13
|
+
* @default medium
|
|
14
|
+
*/
|
|
15
|
+
size?: "medium" | "small";
|
|
16
|
+
/**
|
|
17
|
+
* Removes border-radius
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
fullWidth?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Removes background from Alert
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
inline?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface AlertContextProps {
|
|
28
|
+
size: "medium" | "small";
|
|
29
|
+
}
|
|
30
|
+
export declare const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
export default Alert;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OverridableComponent } from "../";
|
|
3
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Button content
|
|
6
|
+
*/
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Changes design and interaction-visuals
|
|
10
|
+
* @default "primary"
|
|
11
|
+
*/
|
|
12
|
+
variant?: "primary" | "secondary" | "tertiary" | "danger";
|
|
13
|
+
/**
|
|
14
|
+
* Changes padding, height and font-size
|
|
15
|
+
* @default medium
|
|
16
|
+
*/
|
|
17
|
+
size?: "medium" | "small" | "xsmall";
|
|
18
|
+
/**
|
|
19
|
+
* Prevent the user from interacting with the button: it cannot be pressed or focused.
|
|
20
|
+
* @note Avoid using if possible for accessibility purposes
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Replaces button content with a Loader component, keeps width
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Button Icon
|
|
30
|
+
*/
|
|
31
|
+
icon?: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Icon position in Button
|
|
34
|
+
* @default "left"
|
|
35
|
+
*/
|
|
36
|
+
iconPosition?: "left" | "right";
|
|
37
|
+
}
|
|
38
|
+
export declare const Button: OverridableComponent<ButtonProps, HTMLButtonElement>;
|
|
39
|
+
export default Button;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from "react";
|
|
2
|
+
export interface BubbleProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Bubble text
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* name/sender on bubble
|
|
9
|
+
*/
|
|
10
|
+
name?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Timestamp for sent message
|
|
13
|
+
*/
|
|
14
|
+
timestamp?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Background color on bubble
|
|
17
|
+
*/
|
|
18
|
+
backgroundColor?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Overrides hoizontal position of toptext
|
|
21
|
+
*/
|
|
22
|
+
toptextPosition?: "left" | "right";
|
|
23
|
+
}
|
|
24
|
+
export type BubbleType = React.ForwardRefExoticComponent<BubbleProps & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
declare const Bubble: BubbleType;
|
|
26
|
+
export default Bubble;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from "react";
|
|
2
|
+
import { BubbleType } from "./Bubble";
|
|
3
|
+
export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Children of type <Chat.Bubble />
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Chat-message name
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Timestamp for sent message
|
|
14
|
+
*/
|
|
15
|
+
timestamp?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Avatar for messenger. Regular text for initials works to
|
|
18
|
+
*/
|
|
19
|
+
avatar: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Background color on bubbles
|
|
22
|
+
*/
|
|
23
|
+
backgroundColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Background color for avatar
|
|
26
|
+
*/
|
|
27
|
+
avatarBgColor?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Positions avatar and Bubbles
|
|
30
|
+
* @default "left"
|
|
31
|
+
*/
|
|
32
|
+
position?: "left" | "right";
|
|
33
|
+
/**
|
|
34
|
+
* Hoizontal position of toptext
|
|
35
|
+
* @default Same as chat
|
|
36
|
+
*/
|
|
37
|
+
toptextPosition?: "left" | "right";
|
|
38
|
+
}
|
|
39
|
+
interface ChatComponent extends React.ForwardRefExoticComponent<ChatProps & React.RefAttributes<HTMLDivElement>> {
|
|
40
|
+
Bubble: BubbleType;
|
|
41
|
+
}
|
|
42
|
+
export declare const Chat: ChatComponent;
|
|
43
|
+
export default Chat;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Chat, ChatProps } from "./Chat";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from "react";
|
|
2
|
+
import { ToggleChipsType } from "./Toggle";
|
|
3
|
+
import { RemovableChipsType } from "./Removable";
|
|
4
|
+
export interface ChipsProps extends HTMLAttributes<HTMLUListElement> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Changes padding and font-sizes
|
|
8
|
+
* @default "medium"
|
|
9
|
+
*/
|
|
10
|
+
size?: "medium" | "small";
|
|
11
|
+
}
|
|
12
|
+
interface ChipsComponent extends React.ForwardRefExoticComponent<ChipsProps & React.RefAttributes<HTMLUListElement>> {
|
|
13
|
+
Toggle: ToggleChipsType;
|
|
14
|
+
Removable: RemovableChipsType;
|
|
15
|
+
}
|
|
16
|
+
export declare const Chips: ChipsComponent;
|
|
17
|
+
export default Chips;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OverridableComponent } from "..";
|
|
3
|
+
export interface RemovableChipsProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
children: string;
|
|
5
|
+
/**
|
|
6
|
+
* Chip-variants
|
|
7
|
+
* @default "action"
|
|
8
|
+
*/
|
|
9
|
+
variant?: "action" | "neutral";
|
|
10
|
+
/**
|
|
11
|
+
* Replaces label read for screen-readers
|
|
12
|
+
* @default "slett filter"
|
|
13
|
+
*/
|
|
14
|
+
removeLabel?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Click callback
|
|
17
|
+
*/
|
|
18
|
+
onDelete?: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface RemovableChipsType extends OverridableComponent<RemovableChipsProps, HTMLButtonElement> {
|
|
21
|
+
}
|
|
22
|
+
export declare const RemovableChips: OverridableComponent<RemovableChipsProps, HTMLButtonElement>;
|
|
23
|
+
export default RemovableChips;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OverridableComponent } from "..";
|
|
3
|
+
export interface ToggleChipsProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
children: string;
|
|
5
|
+
/**
|
|
6
|
+
* Toggles aria-pressed and visual-changes
|
|
7
|
+
*/
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ToggleChipsType extends OverridableComponent<ToggleChipsProps, HTMLButtonElement> {
|
|
11
|
+
}
|
|
12
|
+
export declare const ToggleChips: ToggleChipsType;
|
|
13
|
+
export default ToggleChips;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Chips, ChipsProps } from "./Chips";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { FormFieldProps } from "../form/useFormField";
|
|
3
|
+
export interface DateInputProps extends FormFieldProps, Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
4
|
+
/**
|
|
5
|
+
* Input label
|
|
6
|
+
*/
|
|
7
|
+
label: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Shows label and description for screenreaders-only
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
hideLabel?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Changes padding and font-sizes
|
|
15
|
+
* @default medium
|
|
16
|
+
*/
|
|
17
|
+
size?: "medium" | "small";
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
variant?: "datepicker" | "monthpicker";
|
|
22
|
+
}
|
|
23
|
+
export type DateInputType = React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
24
|
+
export declare const DatePickerInput: DateInputType;
|
|
25
|
+
export declare const MonthPickerInput: DateInputType;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DateRange, DayPickerBase, Matcher } from "react-day-picker";
|
|
3
|
+
import { DateInputType } from "../DateInput";
|
|
4
|
+
import { DatePickerStandaloneType } from "./DatePickerStandalone";
|
|
5
|
+
export type ConditionalModeProps = {
|
|
6
|
+
mode?: "single";
|
|
7
|
+
onSelect?: (val?: Date) => void;
|
|
8
|
+
selected?: Date;
|
|
9
|
+
defaultSelected?: Date;
|
|
10
|
+
} | {
|
|
11
|
+
mode?: "multiple";
|
|
12
|
+
onSelect?: (val?: Date[]) => void;
|
|
13
|
+
selected?: Date[];
|
|
14
|
+
defaultSelected?: Date[];
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
} | {
|
|
18
|
+
mode?: "range";
|
|
19
|
+
onSelect?: (val?: DateRange) => void;
|
|
20
|
+
selected?: DateRange;
|
|
21
|
+
defaultSelected?: DateRange;
|
|
22
|
+
min?: number;
|
|
23
|
+
max?: number;
|
|
24
|
+
};
|
|
25
|
+
export interface DatePickerDefaultProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect">, Pick<DayPickerBase, "month" | "onMonthChange" | "today" | "onDayClick"> {
|
|
26
|
+
/**
|
|
27
|
+
* Element datepicker anchors to. Use <DatePicker.Input /> for built-in toggle, or make your own with the open/onClose props
|
|
28
|
+
*/
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Classname for datepicker in popover
|
|
32
|
+
*/
|
|
33
|
+
className?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Classname for wrapper
|
|
36
|
+
*/
|
|
37
|
+
wrapperClassName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Changes datepicker locale
|
|
40
|
+
* @default "nb" (norsk bokmål)
|
|
41
|
+
*/
|
|
42
|
+
locale?: "nb" | "nn" | "en";
|
|
43
|
+
/**
|
|
44
|
+
* The earliest day to start navigation.
|
|
45
|
+
*/
|
|
46
|
+
fromDate?: Date;
|
|
47
|
+
/**
|
|
48
|
+
* The latests day to end navigation.
|
|
49
|
+
*/
|
|
50
|
+
toDate?: Date;
|
|
51
|
+
/**
|
|
52
|
+
* Display dropdown for choosing the month and the year. Needs `fromDate` + `toDate` to work.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
dropdownCaption?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Apply the disabled modifier to the matching days.
|
|
58
|
+
* https://react-day-picker.js.org/api/types/Matcher
|
|
59
|
+
*/
|
|
60
|
+
disabled?: Matcher[];
|
|
61
|
+
/**
|
|
62
|
+
* Disable saturday and sunday.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
disableWeekends?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Shows week numbers in left-column. Use with caution, takes up valuable screenspace for small screens.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
showWeekNumber?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Open state for user-controlled state. Component controlled by default
|
|
73
|
+
*/
|
|
74
|
+
open?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* onClose callback for user-controlled state
|
|
77
|
+
*/
|
|
78
|
+
onClose?: () => void;
|
|
79
|
+
/**
|
|
80
|
+
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used
|
|
81
|
+
*/
|
|
82
|
+
onOpenToggle?: () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Avoid using if possible!
|
|
85
|
+
* Changes what CSS position property to use
|
|
86
|
+
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
87
|
+
* @default "absolute"
|
|
88
|
+
*/
|
|
89
|
+
strategy?: "absolute" | "fixed";
|
|
90
|
+
}
|
|
91
|
+
export type DatePickerProps = DatePickerDefaultProps & ConditionalModeProps;
|
|
92
|
+
interface DatePickerComponent extends React.ForwardRefExoticComponent<DatePickerProps> {
|
|
93
|
+
Standalone: DatePickerStandaloneType;
|
|
94
|
+
Input: DateInputType;
|
|
95
|
+
}
|
|
96
|
+
export declare const DatePicker: DatePickerComponent;
|
|
97
|
+
export default DatePicker;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ConditionalModeProps, DatePickerDefaultProps } from "./DatePicker";
|
|
3
|
+
interface DatePickerStandaloneDefaultProps extends Omit<DatePickerDefaultProps, "open" | "onClose" | "onOpenToggle" | "wrapperClassName" | "strategy"> {
|
|
4
|
+
/**
|
|
5
|
+
* Datepicker classname
|
|
6
|
+
*/
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export type DatePickerStandaloneProps = DatePickerStandaloneDefaultProps & ConditionalModeProps;
|
|
10
|
+
export type DatePickerStandaloneType = React.ForwardRefExoticComponent<DatePickerStandaloneProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export declare const DatePickerStandalone: DatePickerStandaloneType;
|
|
12
|
+
export default DatePickerStandalone;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { useDatepicker as UNSAFE_useDatepicker } from "./useDatepicker";
|
|
2
|
+
export type { DateValidationT } from "./useDatepicker";
|
|
3
|
+
export { useRangeDatepicker as UNSAFE_useRangeDatepicker } from "./useRangeDatepicker";
|
|
4
|
+
export type { RangeValidationT } from "./useRangeDatepicker";
|
|
5
|
+
export { useMonthpicker as UNSAFE_useMonthpicker } from "./useMonthPicker";
|
|
6
|
+
export type { MonthValidationT } from "./useMonthPicker";
|
|
7
|
+
export { useDateInputContext, DateContext } from "./useDateInputContext";
|
|
8
|
+
export { useSharedMonthContext, SharedMonthProvider, } from "./useSharedMonthContext";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface DateContextContextProps {
|
|
3
|
+
/**
|
|
4
|
+
* Open state for popover
|
|
5
|
+
*/
|
|
6
|
+
open: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Callback for opOpen toggle
|
|
9
|
+
*/
|
|
10
|
+
onOpen: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Aria-connected ID
|
|
13
|
+
*/
|
|
14
|
+
ariaId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const DateContext: import("react").Context<DateContextContextProps>;
|
|
17
|
+
export declare const useDateInputContext: () => DateContextContextProps;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DateInputProps } from "../DateInput";
|
|
3
|
+
import { DatePickerProps } from "../datepicker/DatePicker";
|
|
4
|
+
export interface UseDatepickerOptions extends Pick<DatePickerProps, "locale" | "fromDate" | "toDate" | "today" | "toDate" | "fromDate" | "toDate" | "disabled" | "disableWeekends"> {
|
|
5
|
+
/**
|
|
6
|
+
* The initially selected Date
|
|
7
|
+
*/
|
|
8
|
+
defaultSelected?: Date;
|
|
9
|
+
/**
|
|
10
|
+
* Default shown month
|
|
11
|
+
*/
|
|
12
|
+
defaultMonth?: Date;
|
|
13
|
+
/**
|
|
14
|
+
* Make selection of Date required
|
|
15
|
+
*/
|
|
16
|
+
required?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Callback for changed state
|
|
19
|
+
*/
|
|
20
|
+
onDateChange?: (val?: Date) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Input-format
|
|
23
|
+
* @default "dd.MM.yyyy"
|
|
24
|
+
*/
|
|
25
|
+
inputFormat?: string;
|
|
26
|
+
/**
|
|
27
|
+
* validation-callback
|
|
28
|
+
*/
|
|
29
|
+
onValidate?: (val: DateValidationT) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Allows input of with 'yy' year format.
|
|
32
|
+
* @default true
|
|
33
|
+
* @Note Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
34
|
+
* In 2023 this equals to 1943 - 2042
|
|
35
|
+
*/
|
|
36
|
+
allowTwoDigitYear?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface UseDatepickerValue {
|
|
39
|
+
/**
|
|
40
|
+
* Use: <DatePicker {...datepickerProps}/>
|
|
41
|
+
*/
|
|
42
|
+
datepickerProps: DatePickerProps;
|
|
43
|
+
/**
|
|
44
|
+
* Use: <DatePicker.Input {...inputProps}/>
|
|
45
|
+
*/
|
|
46
|
+
inputProps: Pick<DateInputProps, "onChange" | "onFocus" | "onBlur" | "value"> & {
|
|
47
|
+
ref: React.RefObject<HTMLInputElement>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Resets all states (callback)
|
|
51
|
+
*/
|
|
52
|
+
reset: () => void;
|
|
53
|
+
/**
|
|
54
|
+
* Currently selected date
|
|
55
|
+
* Up to user to validate date
|
|
56
|
+
*/
|
|
57
|
+
selectedDay?: Date;
|
|
58
|
+
/**
|
|
59
|
+
* Manually override currently selected day
|
|
60
|
+
*/
|
|
61
|
+
setSelected: (date?: Date) => void;
|
|
62
|
+
}
|
|
63
|
+
export type DateValidationT = {
|
|
64
|
+
isDisabled: boolean;
|
|
65
|
+
isWeekend: boolean;
|
|
66
|
+
isEmpty: boolean;
|
|
67
|
+
isInvalid: boolean;
|
|
68
|
+
isValidDate: boolean;
|
|
69
|
+
isBefore: boolean;
|
|
70
|
+
isAfter: boolean;
|
|
71
|
+
};
|
|
72
|
+
export declare const useDatepicker: (opt?: UseDatepickerOptions) => UseDatepickerValue;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DateInputProps } from "../DateInput";
|
|
3
|
+
import { MonthPickerProps } from "../monthpicker/MonthPicker";
|
|
4
|
+
export interface UseMonthPickerOptions extends Pick<MonthPickerProps, "locale" | "fromDate" | "toDate" | "disabled" | "defaultSelected"> {
|
|
5
|
+
/**
|
|
6
|
+
* Make Date-selection required
|
|
7
|
+
*/
|
|
8
|
+
required?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Callback for month-change
|
|
11
|
+
*/
|
|
12
|
+
onMonthChange?: (date?: Date) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Input-format
|
|
15
|
+
* @default "MMMM yyyy"
|
|
16
|
+
*/
|
|
17
|
+
inputFormat?: string;
|
|
18
|
+
/**
|
|
19
|
+
* validation-callback
|
|
20
|
+
*/
|
|
21
|
+
onValidate?: (val: MonthValidationT) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Default shown year
|
|
24
|
+
*/
|
|
25
|
+
defaultYear?: Date;
|
|
26
|
+
/**
|
|
27
|
+
* Allows input of with 'yy' year format.
|
|
28
|
+
* @default true
|
|
29
|
+
* @Note Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
30
|
+
* In 2023 this equals to 1943 - 2042
|
|
31
|
+
*/
|
|
32
|
+
allowTwoDigitYear?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface UseMonthPickerValue {
|
|
35
|
+
/**
|
|
36
|
+
* Use: <MonthPicker {...monthpickerProps} />
|
|
37
|
+
*/
|
|
38
|
+
monthpickerProps: MonthPickerProps;
|
|
39
|
+
/**
|
|
40
|
+
* Use: <MonthPicker.Input {...inputProps} />
|
|
41
|
+
*/
|
|
42
|
+
inputProps: Pick<DateInputProps, "onChange" | "onFocus" | "value"> & {
|
|
43
|
+
ref: React.RefObject<HTMLInputElement>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Currently selected Date
|
|
47
|
+
* Up to user to validate value and extract month
|
|
48
|
+
*/
|
|
49
|
+
selectedMonth?: Date;
|
|
50
|
+
/**
|
|
51
|
+
* Manually set selected month if needed
|
|
52
|
+
*/
|
|
53
|
+
setSelected: (date?: Date) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Resets all states
|
|
56
|
+
*/
|
|
57
|
+
reset: () => void;
|
|
58
|
+
}
|
|
59
|
+
export type MonthValidationT = {
|
|
60
|
+
isDisabled: boolean;
|
|
61
|
+
isEmpty: boolean;
|
|
62
|
+
isInvalid: boolean;
|
|
63
|
+
isValidMonth: boolean;
|
|
64
|
+
isBefore: boolean;
|
|
65
|
+
isAfter: boolean;
|
|
66
|
+
};
|
|
67
|
+
export declare const useMonthpicker: (opt?: UseMonthPickerOptions) => UseMonthPickerValue;
|
|
68
|
+
export {};
|