@digdir/designsystemet-react 1.0.0-next.34 → 1.0.0-next.35
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/dist/cjs/components/Accordion/AccordionContent.js +1 -2
- package/dist/cjs/components/Accordion/AccordionHeading.js +4 -6
- package/dist/cjs/components/Accordion/AccordionItem.js +16 -52
- package/dist/cjs/components/Alert/Alert.js +1 -2
- package/dist/cjs/components/Avatar/Avatar.js +1 -7
- package/dist/cjs/components/Badge/Badge.js +1 -7
- package/dist/cjs/components/Breadcrumbs/Breadcrumbs.js +1 -2
- package/dist/cjs/components/Button/Button.js +4 -3
- package/dist/cjs/components/Card/Card.js +24 -6
- package/dist/cjs/components/Card/{CardMedia.js → CardBlock.js} +3 -4
- package/dist/cjs/components/Card/index.js +6 -17
- package/dist/cjs/components/Chip/Chips.js +50 -0
- package/dist/cjs/components/Chip/index.js +12 -11
- package/dist/cjs/components/Dropdown/DropdownHeading.js +2 -5
- package/dist/cjs/components/ErrorSummary/ErrorSummaryHeading.js +2 -2
- package/dist/cjs/components/{Typography/Heading → Heading}/Heading.js +2 -3
- package/dist/cjs/components/{Typography/Label → Label}/Label.js +2 -3
- package/dist/cjs/components/List/Lists.js +1 -2
- package/dist/cjs/components/Modal/Modal.js +45 -0
- package/dist/cjs/components/Modal/ModalBlock.js +14 -0
- package/dist/cjs/components/Modal/ModalContext.js +17 -0
- package/dist/cjs/components/Modal/ModalTrigger.js +4 -5
- package/dist/cjs/components/Modal/index.js +12 -22
- package/dist/cjs/components/Pagination/Pagination.js +9 -14
- package/dist/cjs/components/Pagination/PaginationButton.js +4 -4
- package/dist/cjs/components/Pagination/PaginationItem.js +1 -4
- package/dist/cjs/components/Pagination/PaginationList.js +2 -5
- package/dist/cjs/components/Pagination/index.js +5 -19
- package/dist/cjs/components/Pagination/usePagination.js +46 -51
- package/dist/cjs/components/{Typography/Paragraph → Paragraph}/Paragraph.js +2 -8
- package/dist/cjs/components/Popover/Popover.js +3 -4
- package/dist/cjs/components/SkipLink/SkipLink.js +4 -4
- package/dist/cjs/components/Table/Table.js +1 -2
- package/dist/cjs/components/Tabs/TabsPanel.js +1 -2
- package/dist/cjs/components/Tabs/TabsTab.js +1 -2
- package/dist/cjs/components/Tag/Tag.js +1 -2
- package/dist/cjs/components/Tooltip/Tooltip.js +5 -6
- package/dist/cjs/components/{Typography/ValidationMessage → ValidationMessage}/ValidationMessage.js +2 -2
- package/dist/cjs/components/form/CharacterCounter.js +1 -1
- package/dist/cjs/components/form/Checkbox/Checkbox.js +2 -2
- package/dist/cjs/components/form/Combobox/Combobox.js +1 -2
- package/dist/cjs/components/form/Combobox/Custom.js +1 -1
- package/dist/cjs/components/form/Combobox/Empty.js +1 -1
- package/dist/cjs/components/form/Combobox/Option/Option.js +1 -1
- package/dist/cjs/components/form/Combobox/internal/ComboboxChips.js +2 -2
- package/dist/cjs/components/form/Combobox/internal/ComboboxError.js +1 -1
- package/dist/cjs/components/form/Combobox/internal/ComboboxInput.js +2 -2
- package/dist/cjs/components/form/Combobox/internal/ComboboxLabel.js +2 -2
- package/dist/cjs/components/form/Fieldset/Fieldset.js +3 -3
- package/dist/cjs/components/form/Radio/Radio.js +2 -2
- package/dist/cjs/components/form/Search/Search.js +2 -2
- package/dist/cjs/components/form/Select/Select.js +3 -3
- package/dist/cjs/components/form/Switch/Switch.js +3 -3
- package/dist/cjs/components/form/Textarea/Textarea.js +3 -3
- package/dist/cjs/components/form/Textfield/Textfield.js +3 -3
- package/dist/cjs/components/loaders/Skeleton/Skeleton.js +4 -2
- package/dist/cjs/index.js +17 -39
- package/dist/esm/components/Accordion/AccordionContent.js +1 -2
- package/dist/esm/components/Accordion/AccordionHeading.js +4 -6
- package/dist/esm/components/Accordion/AccordionItem.js +17 -53
- package/dist/esm/components/Alert/Alert.js +1 -2
- package/dist/esm/components/Avatar/Avatar.js +1 -7
- package/dist/esm/components/Badge/Badge.js +1 -7
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +1 -2
- package/dist/esm/components/Button/Button.js +5 -4
- package/dist/esm/components/Card/Card.js +25 -7
- package/dist/esm/components/Card/{CardMedia.js → CardBlock.js} +3 -4
- package/dist/esm/components/Card/index.js +6 -14
- package/dist/esm/components/Chip/Chips.js +45 -0
- package/dist/esm/components/Chip/index.js +9 -9
- package/dist/esm/components/Dropdown/DropdownHeading.js +3 -6
- package/dist/esm/components/ErrorSummary/ErrorSummaryHeading.js +2 -2
- package/dist/esm/components/{Typography/Heading → Heading}/Heading.js +2 -3
- package/dist/esm/components/Label/Label.js +18 -0
- package/dist/esm/components/List/Lists.js +1 -2
- package/dist/esm/components/Modal/Modal.js +43 -0
- package/dist/esm/components/Modal/ModalBlock.js +12 -0
- package/dist/esm/components/Modal/ModalContext.js +14 -0
- package/dist/esm/components/Modal/ModalTrigger.js +4 -5
- package/dist/esm/components/Modal/index.js +11 -18
- package/dist/esm/components/Pagination/Pagination.js +11 -17
- package/dist/esm/components/Pagination/PaginationButton.js +3 -3
- package/dist/esm/components/Pagination/PaginationItem.js +2 -5
- package/dist/esm/components/Pagination/PaginationList.js +3 -6
- package/dist/esm/components/Pagination/index.js +6 -16
- package/dist/esm/components/Pagination/usePagination.js +47 -52
- package/dist/esm/components/Paragraph/Paragraph.js +18 -0
- package/dist/esm/components/Popover/Popover.js +3 -4
- package/dist/esm/components/SkipLink/SkipLink.js +4 -4
- package/dist/esm/components/Table/Table.js +1 -2
- package/dist/esm/components/Tabs/TabsPanel.js +1 -2
- package/dist/esm/components/Tabs/TabsTab.js +1 -2
- package/dist/esm/components/Tag/Tag.js +1 -2
- package/dist/esm/components/Tooltip/Tooltip.js +5 -6
- package/dist/esm/components/{Typography/ValidationMessage → ValidationMessage}/ValidationMessage.js +2 -2
- package/dist/esm/components/form/CharacterCounter.js +1 -1
- package/dist/esm/components/form/Checkbox/Checkbox.js +2 -2
- package/dist/esm/components/form/Combobox/Combobox.js +2 -3
- package/dist/esm/components/form/Combobox/Custom.js +1 -1
- package/dist/esm/components/form/Combobox/Empty.js +1 -1
- package/dist/esm/components/form/Combobox/Option/Option.js +1 -1
- package/dist/esm/components/form/Combobox/internal/ComboboxChips.js +2 -2
- package/dist/esm/components/form/Combobox/internal/ComboboxError.js +1 -1
- package/dist/esm/components/form/Combobox/internal/ComboboxInput.js +2 -2
- package/dist/esm/components/form/Combobox/internal/ComboboxLabel.js +2 -2
- package/dist/esm/components/form/Fieldset/Fieldset.js +3 -3
- package/dist/esm/components/form/Radio/Radio.js +2 -2
- package/dist/esm/components/form/Search/Search.js +2 -2
- package/dist/esm/components/form/Select/Select.js +3 -3
- package/dist/esm/components/form/Switch/Switch.js +3 -3
- package/dist/esm/components/form/Textarea/Textarea.js +3 -3
- package/dist/esm/components/form/Textfield/Textfield.js +3 -3
- package/dist/esm/components/loaders/Skeleton/Skeleton.js +4 -2
- package/dist/esm/index.js +8 -20
- package/dist/types/components/Accordion/AccordionContent.d.ts.map +1 -1
- package/dist/types/components/Accordion/AccordionHeading.d.ts +2 -2
- package/dist/types/components/Accordion/AccordionHeading.d.ts.map +1 -1
- package/dist/types/components/Accordion/AccordionItem.d.ts +8 -8
- package/dist/types/components/Accordion/AccordionItem.d.ts.map +1 -1
- package/dist/types/components/Alert/Alert.d.ts.map +1 -1
- package/dist/types/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/Badge/Badge.d.ts.map +1 -1
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/types/components/Button/Button.d.ts.map +1 -1
- package/dist/types/components/Card/Card.d.ts +5 -15
- package/dist/types/components/Card/Card.d.ts.map +1 -1
- package/dist/types/components/Card/{CardMedia.d.ts → CardBlock.d.ts} +3 -3
- package/dist/types/components/Card/{CardMedia.d.ts.map → CardBlock.d.ts.map} +1 -1
- package/dist/types/components/Card/index.d.ts +12 -16
- package/dist/types/components/Card/index.d.ts.map +1 -1
- package/dist/types/components/Chip/Chips.d.ts +45 -0
- package/dist/types/components/Chip/Chips.d.ts.map +1 -0
- package/dist/types/components/Chip/index.d.ts +20 -21
- package/dist/types/components/Chip/index.d.ts.map +1 -1
- package/dist/types/components/Dropdown/DropdownHeading.d.ts.map +1 -1
- package/dist/types/components/ErrorSummary/ErrorSummaryHeading.d.ts +1 -2
- package/dist/types/components/ErrorSummary/ErrorSummaryHeading.d.ts.map +1 -1
- package/dist/types/components/ErrorSummary/index.d.ts +0 -1
- package/dist/types/components/ErrorSummary/index.d.ts.map +1 -1
- package/dist/types/components/{Typography/Heading → Heading}/Heading.d.ts +0 -4
- package/dist/types/components/Heading/Heading.d.ts.map +1 -0
- package/dist/types/components/Heading/index.d.ts.map +1 -0
- package/dist/types/components/{Typography/Label → Label}/Label.d.ts +0 -4
- package/dist/types/components/Label/Label.d.ts.map +1 -0
- package/dist/types/components/Label/index.d.ts.map +1 -0
- package/dist/types/components/List/Lists.d.ts.map +1 -1
- package/dist/types/components/Modal/Modal.d.ts +38 -0
- package/dist/types/components/Modal/Modal.d.ts.map +1 -0
- package/dist/types/components/{Card/CardFooter.d.ts → Modal/ModalBlock.d.ts} +3 -3
- package/dist/types/components/Modal/ModalBlock.d.ts.map +1 -0
- package/dist/types/components/Modal/ModalContext.d.ts +10 -0
- package/dist/types/components/Modal/ModalContext.d.ts.map +1 -0
- package/dist/types/components/Modal/ModalTrigger.d.ts.map +1 -1
- package/dist/types/components/Modal/index.d.ts +31 -20
- package/dist/types/components/Modal/index.d.ts.map +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +23 -36
- package/dist/types/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/types/components/Pagination/PaginationButton.d.ts +4 -3
- package/dist/types/components/Pagination/PaginationButton.d.ts.map +1 -1
- package/dist/types/components/Pagination/PaginationItem.d.ts.map +1 -1
- package/dist/types/components/Pagination/PaginationList.d.ts +1 -1
- package/dist/types/components/Pagination/PaginationList.d.ts.map +1 -1
- package/dist/types/components/Pagination/index.d.ts +16 -17
- package/dist/types/components/Pagination/index.d.ts.map +1 -1
- package/dist/types/components/Pagination/usePagination.d.ts +41 -17
- package/dist/types/components/Pagination/usePagination.d.ts.map +1 -1
- package/dist/types/components/{Typography/Paragraph → Paragraph}/Paragraph.d.ts +2 -6
- package/dist/types/components/Paragraph/Paragraph.d.ts.map +1 -0
- package/dist/types/components/Paragraph/index.d.ts.map +1 -0
- package/dist/types/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/components/SkipLink/SkipLink.d.ts +7 -5
- package/dist/types/components/SkipLink/SkipLink.d.ts.map +1 -1
- package/dist/types/components/Table/Table.d.ts.map +1 -1
- package/dist/types/components/Tabs/TabsPanel.d.ts.map +1 -1
- package/dist/types/components/Tabs/TabsTab.d.ts.map +1 -1
- package/dist/types/components/Tag/Tag.d.ts +2 -5
- package/dist/types/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/components/{Typography/ValidationMessage → ValidationMessage}/ValidationMessage.d.ts +0 -4
- package/dist/types/components/ValidationMessage/ValidationMessage.d.ts.map +1 -0
- package/dist/types/components/ValidationMessage/index.d.ts.map +1 -0
- package/dist/types/components/form/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/Combobox.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/internal/ComboboxLabel.d.ts.map +1 -1
- package/dist/types/components/form/Fieldset/Fieldset.d.ts.map +1 -1
- package/dist/types/components/form/Radio/Radio.d.ts.map +1 -1
- package/dist/types/components/form/Search/Search.d.ts.map +1 -1
- package/dist/types/components/form/Select/Select.d.ts.map +1 -1
- package/dist/types/components/form/Switch/Switch.d.ts.map +1 -1
- package/dist/types/components/form/Textarea/Textarea.d.ts.map +1 -1
- package/dist/types/components/form/Textfield/Textfield.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +4 -1
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/components/loaders/Skeleton/Skeleton.d.ts +8 -17
- package/dist/types/components/loaders/Skeleton/Skeleton.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/cjs/components/Card/CardContent.js +0 -16
- package/dist/cjs/components/Card/CardFooter.js +0 -16
- package/dist/cjs/components/Card/CardHeader.js +0 -16
- package/dist/cjs/components/Chip/Group/Group.js +0 -15
- package/dist/cjs/components/Chip/Removable/Removable.js +0 -17
- package/dist/cjs/components/Chip/Toggle/Toggle.js +0 -18
- package/dist/cjs/components/Modal/ModaContent.js +0 -15
- package/dist/cjs/components/Modal/ModalDialog.js +0 -73
- package/dist/cjs/components/Modal/ModalFooter.js +0 -15
- package/dist/cjs/components/Modal/ModalHeader.js +0 -20
- package/dist/cjs/components/Modal/ModalRoot.js +0 -31
- package/dist/cjs/components/Modal/useModalState.js +0 -30
- package/dist/cjs/components/Modal/useScrollLock.js +0 -29
- package/dist/cjs/components/Pagination/PaginationEllipsis.js +0 -15
- package/dist/cjs/components/Pagination/PaginationNextPrev.js +0 -16
- package/dist/cjs/components/Pagination/PaginationRoot.js +0 -18
- package/dist/cjs/components/Typography/Ingress/Ingress.js +0 -21
- package/dist/esm/components/Card/CardContent.js +0 -14
- package/dist/esm/components/Card/CardFooter.js +0 -14
- package/dist/esm/components/Card/CardHeader.js +0 -14
- package/dist/esm/components/Chip/Group/Group.js +0 -12
- package/dist/esm/components/Chip/Removable/Removable.js +0 -15
- package/dist/esm/components/Chip/Toggle/Toggle.js +0 -16
- package/dist/esm/components/Modal/ModaContent.js +0 -13
- package/dist/esm/components/Modal/ModalDialog.js +0 -71
- package/dist/esm/components/Modal/ModalFooter.js +0 -13
- package/dist/esm/components/Modal/ModalHeader.js +0 -18
- package/dist/esm/components/Modal/ModalRoot.js +0 -28
- package/dist/esm/components/Modal/useModalState.js +0 -28
- package/dist/esm/components/Modal/useScrollLock.js +0 -27
- package/dist/esm/components/Pagination/PaginationEllipsis.js +0 -13
- package/dist/esm/components/Pagination/PaginationNextPrev.js +0 -13
- package/dist/esm/components/Pagination/PaginationRoot.js +0 -15
- package/dist/esm/components/Typography/Ingress/Ingress.js +0 -19
- package/dist/esm/components/Typography/Label/Label.js +0 -19
- package/dist/esm/components/Typography/Paragraph/Paragraph.js +0 -24
- package/dist/types/components/Card/CardContent.d.ts +0 -16
- package/dist/types/components/Card/CardContent.d.ts.map +0 -1
- package/dist/types/components/Card/CardFooter.d.ts.map +0 -1
- package/dist/types/components/Card/CardHeader.d.ts +0 -16
- package/dist/types/components/Card/CardHeader.d.ts.map +0 -1
- package/dist/types/components/Chip/Group/Group.d.ts +0 -20
- package/dist/types/components/Chip/Group/Group.d.ts.map +0 -1
- package/dist/types/components/Chip/Removable/Removable.d.ts +0 -17
- package/dist/types/components/Chip/Removable/Removable.d.ts.map +0 -1
- package/dist/types/components/Chip/Toggle/Toggle.d.ts +0 -33
- package/dist/types/components/Chip/Toggle/Toggle.d.ts.map +0 -1
- package/dist/types/components/Modal/ModaContent.d.ts +0 -16
- package/dist/types/components/Modal/ModaContent.d.ts.map +0 -1
- package/dist/types/components/Modal/ModalDialog.d.ts +0 -38
- package/dist/types/components/Modal/ModalDialog.d.ts.map +0 -1
- package/dist/types/components/Modal/ModalFooter.d.ts +0 -16
- package/dist/types/components/Modal/ModalFooter.d.ts.map +0 -1
- package/dist/types/components/Modal/ModalHeader.d.ts +0 -44
- package/dist/types/components/Modal/ModalHeader.d.ts.map +0 -1
- package/dist/types/components/Modal/ModalRoot.d.ts +0 -17
- package/dist/types/components/Modal/ModalRoot.d.ts.map +0 -1
- package/dist/types/components/Modal/useModalState.d.ts +0 -2
- package/dist/types/components/Modal/useModalState.d.ts.map +0 -1
- package/dist/types/components/Modal/useScrollLock.d.ts +0 -2
- package/dist/types/components/Modal/useScrollLock.d.ts.map +0 -1
- package/dist/types/components/Pagination/PaginationEllipsis.d.ts +0 -4
- package/dist/types/components/Pagination/PaginationEllipsis.d.ts.map +0 -1
- package/dist/types/components/Pagination/PaginationNextPrev.d.ts +0 -10
- package/dist/types/components/Pagination/PaginationNextPrev.d.ts.map +0 -1
- package/dist/types/components/Pagination/PaginationRoot.d.ts +0 -53
- package/dist/types/components/Pagination/PaginationRoot.d.ts.map +0 -1
- package/dist/types/components/Typography/Heading/Heading.d.ts.map +0 -1
- package/dist/types/components/Typography/Heading/index.d.ts.map +0 -1
- package/dist/types/components/Typography/Ingress/Ingress.d.ts +0 -34
- package/dist/types/components/Typography/Ingress/Ingress.d.ts.map +0 -1
- package/dist/types/components/Typography/Ingress/index.d.ts +0 -2
- package/dist/types/components/Typography/Ingress/index.d.ts.map +0 -1
- package/dist/types/components/Typography/Label/Label.d.ts.map +0 -1
- package/dist/types/components/Typography/Label/index.d.ts.map +0 -1
- package/dist/types/components/Typography/Paragraph/Paragraph.d.ts.map +0 -1
- package/dist/types/components/Typography/Paragraph/index.d.ts.map +0 -1
- package/dist/types/components/Typography/ValidationMessage/ValidationMessage.d.ts.map +0 -1
- package/dist/types/components/Typography/ValidationMessage/index.d.ts.map +0 -1
- package/dist/types/components/Typography/index.d.ts +0 -6
- package/dist/types/components/Typography/index.d.ts.map +0 -1
- package/dist/types/utilities/AnimateHeight/AnimateHeight.d.ts +0 -9
- package/dist/types/utilities/AnimateHeight/AnimateHeight.d.ts.map +0 -1
- package/dist/types/utilities/AnimateHeight/index.d.ts +0 -3
- package/dist/types/utilities/AnimateHeight/index.d.ts.map +0 -1
- /package/dist/types/components/{Typography/Heading → Heading}/index.d.ts +0 -0
- /package/dist/types/components/{Typography/Label → Label}/index.d.ts +0 -0
- /package/dist/types/components/{Typography/Paragraph → Paragraph}/index.d.ts +0 -0
- /package/dist/types/components/{Typography/ValidationMessage → ValidationMessage}/index.d.ts +0 -0
|
@@ -10,10 +10,9 @@ import { forwardRef } from 'react';
|
|
|
10
10
|
* @example
|
|
11
11
|
* <Heading size='lg' level={2}>Heading</Heading>
|
|
12
12
|
*/
|
|
13
|
-
const Heading = forwardRef(({ size = 'xl', level = 2,
|
|
13
|
+
const Heading = forwardRef(function Heading({ size = 'xl', level = 2, className, asChild, ...rest }, ref) {
|
|
14
14
|
const Component = asChild ? Slot : `h${level}`;
|
|
15
|
-
return (jsx(Component, {
|
|
15
|
+
return (jsx(Component, { className: cl(`ds-heading`, className), "data-size": size, ref: ref, ...rest }));
|
|
16
16
|
});
|
|
17
|
-
Heading.displayName = 'Heading';
|
|
18
17
|
|
|
19
18
|
export { Heading };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import cl from 'clsx/lite';
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Use `Label` for labels.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Label size='lg'>Label</Label>
|
|
12
|
+
*/
|
|
13
|
+
const Label = forwardRef(function Label({ className, size = 'md', weight = 'medium', asChild, ...rest }, ref) {
|
|
14
|
+
const Component = asChild ? Slot : 'label';
|
|
15
|
+
return (jsx(Component, { ref: ref, className: cl(`ds-label--${size}`, weight && `ds-font-weight--${weight}`, className), ...rest }));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { Label };
|
|
@@ -3,11 +3,10 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
4
|
import cl from 'clsx/lite';
|
|
5
5
|
import { forwardRef } from 'react';
|
|
6
|
-
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
7
6
|
|
|
8
7
|
const render = (tagName, { asChild, className, size = 'md', ...rest }, ref) => {
|
|
9
8
|
const Component = asChild ? Slot : tagName;
|
|
10
|
-
return (jsx(
|
|
9
|
+
return (jsx(Component, { className: cl(`ds-list`, className), "data-size": size, ref: ref, ...rest }));
|
|
11
10
|
};
|
|
12
11
|
const ListUnordered = forwardRef(function ListUnordered(props, ref) {
|
|
13
12
|
return render('ul', props, ref);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMergeRefs } from '@floating-ui/react';
|
|
4
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
5
|
+
import cl from 'clsx/lite';
|
|
6
|
+
import { forwardRef, useContext, useRef, useEffect } from 'react';
|
|
7
|
+
import { Context } from './ModalContext.js';
|
|
8
|
+
import { Button } from '../Button/Button.js';
|
|
9
|
+
|
|
10
|
+
const Modal = forwardRef(function Modal({ asChild, children, className, closeButton = 'Lukk dialogvindu', onClose, open, backdropClose = false, ...rest }, ref) {
|
|
11
|
+
const contextRef = useContext(Context);
|
|
12
|
+
const modalRef = useRef(null); // This local ref is used to make sure the modal works without a ModalContext
|
|
13
|
+
const Component = asChild ? Slot : 'dialog';
|
|
14
|
+
const mergedRefs = useMergeRefs([contextRef, ref, modalRef]);
|
|
15
|
+
useEffect(() => modalRef.current?.[open ? 'showModal' : 'close'](), [open]); // Toggle open based on prop
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const modal = modalRef.current;
|
|
18
|
+
const handleBackdropClick = ({ clientY: y, clientX: x, target, }) => {
|
|
19
|
+
if (window.getSelection()?.toString())
|
|
20
|
+
return; // Fix bug where if you select text spanning two divs it thinks you clicked outside
|
|
21
|
+
if (modal && target === modal && backdropClose) {
|
|
22
|
+
const { top, left, right, bottom } = modal.getBoundingClientRect();
|
|
23
|
+
const isInDialog = top <= y && y <= bottom && left <= x && x <= right;
|
|
24
|
+
if (!isInDialog)
|
|
25
|
+
modal?.close(); // Both <dialog> and ::backdrop is considered same event.target
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const handleAutoFocus = () => {
|
|
29
|
+
const autofocus = modal?.querySelector('[autofocus]');
|
|
30
|
+
if (document.activeElement !== autofocus)
|
|
31
|
+
autofocus?.focus();
|
|
32
|
+
};
|
|
33
|
+
modal?.addEventListener('animationend', handleAutoFocus);
|
|
34
|
+
modal?.addEventListener('click', handleBackdropClick);
|
|
35
|
+
return () => {
|
|
36
|
+
modal?.removeEventListener('animationend', handleAutoFocus);
|
|
37
|
+
modal?.removeEventListener('click', handleBackdropClick);
|
|
38
|
+
};
|
|
39
|
+
}, [backdropClose]);
|
|
40
|
+
return (jsxs(Component, { className: cl('ds-modal', className), ref: mergedRefs, ...rest, children: [closeButton !== false && (jsx("form", { method: 'dialog', children: jsx(Button, { "aria-label": closeButton, autoFocus: true, color: 'neutral', icon: true, name: 'close', size: 'md', type: 'submit', variant: 'tertiary' }) })), children] }));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { Modal };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import cl from 'clsx/lite';
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
|
|
7
|
+
const ModalBlock = forwardRef(function ModalBlock({ asChild, className, ...rest }, ref) {
|
|
8
|
+
const Component = asChild ? Slot : 'div';
|
|
9
|
+
return (jsx(Component, { className: cl('ds-modal__block', className), ref: ref, ...rest }));
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export { ModalBlock };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { createContext, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
const Context = createContext({
|
|
6
|
+
current: null,
|
|
7
|
+
});
|
|
8
|
+
const ModalContext = ({ children }) => {
|
|
9
|
+
const contextRef = useRef(null);
|
|
10
|
+
return jsx(Context.Provider, { value: contextRef, children: children });
|
|
11
|
+
};
|
|
12
|
+
ModalContext.displayName = 'ModalContext';
|
|
13
|
+
|
|
14
|
+
export { Context, ModalContext };
|
|
@@ -3,13 +3,12 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
4
|
import { forwardRef, useContext } from 'react';
|
|
5
5
|
import { Button } from '../Button/Button.js';
|
|
6
|
-
import {
|
|
6
|
+
import { Context } from './ModalContext.js';
|
|
7
7
|
|
|
8
|
-
const ModalTrigger = forwardRef(({ asChild, ...rest }, ref)
|
|
9
|
-
const
|
|
8
|
+
const ModalTrigger = forwardRef(function ModalTrigger({ asChild, ...rest }, ref) {
|
|
9
|
+
const contextRef = useContext(Context);
|
|
10
10
|
const Component = asChild ? Slot : Button;
|
|
11
|
-
return (jsx(Component, {
|
|
11
|
+
return (jsx(Component, { "aria-haspopup": 'dialog', onClick: () => contextRef?.current?.showModal(), ref: ref, ...rest }));
|
|
12
12
|
});
|
|
13
|
-
ModalTrigger.displayName = 'ModalTrigger';
|
|
14
13
|
|
|
15
14
|
export { ModalTrigger };
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ModalHeader } from './ModalHeader.js';
|
|
6
|
-
import { ModalRoot } from './ModalRoot.js';
|
|
2
|
+
import { Modal as Modal$1 } from './Modal.js';
|
|
3
|
+
import { ModalBlock } from './ModalBlock.js';
|
|
4
|
+
import { ModalContext } from './ModalContext.js';
|
|
7
5
|
import { ModalTrigger } from './ModalTrigger.js';
|
|
8
6
|
|
|
9
|
-
const Modal = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Modal.
|
|
15
|
-
Modal.
|
|
16
|
-
Modal.Root.displayName = 'Modal.Root';
|
|
17
|
-
Modal.Dialog.displayName = 'Modal.Dialog';
|
|
18
|
-
Modal.Footer.displayName = 'Modal.Footer';
|
|
19
|
-
Modal.Header.displayName = 'Modal.Header';
|
|
20
|
-
Modal.Content.displayName = 'Modal.Content';
|
|
7
|
+
const Modal = Object.assign(Modal$1, {
|
|
8
|
+
Block: ModalBlock,
|
|
9
|
+
Context: ModalContext,
|
|
10
|
+
Trigger: ModalTrigger,
|
|
11
|
+
});
|
|
12
|
+
Modal.Block.displayName = 'Modal.Block';
|
|
13
|
+
Modal.Context.displayName = 'Modal.Context';
|
|
21
14
|
Modal.Trigger.displayName = 'Modal.Trigger';
|
|
22
15
|
|
|
23
|
-
export { Modal,
|
|
16
|
+
export { Modal, ModalBlock, ModalContext, ModalTrigger };
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { PaginationItem } from './PaginationItem.js';
|
|
7
|
-
import { PaginationList } from './PaginationList.js';
|
|
8
|
-
import { PaginationPrevious, PaginationNext } from './PaginationNextPrev.js';
|
|
9
|
-
import { PaginationRoot } from './PaginationRoot.js';
|
|
10
|
-
import { usePagination } from './usePagination.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import cl from 'clsx/lite';
|
|
5
|
+
import { createContext, forwardRef } from 'react';
|
|
11
6
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
return (jsx(PaginationRoot, { "aria-label": 'Pagination', compact: compact, ref: ref, size: size, ...rest, children: jsxs(PaginationList, { children: [jsx(PaginationItem, { children: jsx(PaginationPrevious, { "aria-label": previousLabel, disabled: !showPreviousPage, onClick: () => onChange(currentPage - 1), children: !hideLabels && previousLabel }) }), pages.map((page, i) => (jsx(PaginationItem, { children: page === 'ellipsis' ? (jsx(PaginationEllipsis, {})) : (jsx(PaginationButton, { "aria-current": currentPage === page, "aria-label": itemLabel(page), isActive: currentPage === page, onClick: () => onChange(page), children: page })) }, `${page}${i}`))), jsx(PaginationItem, { children: jsx(PaginationNext, { "aria-label": nextLabel, disabled: !showNextPage, onClick: () => onChange(currentPage + 1), children: !hideLabels && nextLabel }) })] }) }));
|
|
7
|
+
const PaginationContext = createContext({
|
|
8
|
+
size: 'md',
|
|
9
|
+
});
|
|
10
|
+
const Pagination = forwardRef(function Pagination({ 'aria-label': ariaLabel = 'Sidenavigering', asChild, className, size = 'md', ...rest }, ref) {
|
|
11
|
+
const Component = asChild ? Slot : 'nav';
|
|
12
|
+
return (jsx(PaginationContext.Provider, { value: { size }, children: jsx(Component, { "aria-label": ariaLabel, className: cl('ds-pagination', className), ref: ref, ...rest }) }));
|
|
19
13
|
});
|
|
20
14
|
|
|
21
|
-
export { Pagination };
|
|
15
|
+
export { Pagination, PaginationContext };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef, useContext } from 'react';
|
|
4
4
|
import { Button } from '../Button/Button.js';
|
|
5
|
-
import { PaginationContext } from './
|
|
5
|
+
import { PaginationContext } from './Pagination.js';
|
|
6
6
|
|
|
7
|
-
const PaginationButton = forwardRef(function PaginationButton(
|
|
7
|
+
const PaginationButton = forwardRef(function PaginationButton(rest, ref) {
|
|
8
8
|
const { size } = useContext(PaginationContext);
|
|
9
|
-
return
|
|
9
|
+
return jsx(Button, { ref: ref, size: size, ...rest });
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export { PaginationButton };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
-
import
|
|
5
|
-
import { forwardRef, useContext } from 'react';
|
|
6
|
-
import { PaginationContext } from './PaginationRoot.js';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
7
5
|
|
|
8
6
|
const PaginationItem = forwardRef(function PaginationItem({ asChild, className, ...rest }, ref) {
|
|
9
7
|
const Component = asChild ? Slot : 'li';
|
|
10
|
-
|
|
11
|
-
return (jsx(Component, { ref: ref, className: cl('ds-pagination__item', `ds-pagination--${size}`, compact && 'ds-pagination--compact', className), ...rest }));
|
|
8
|
+
return jsx(Component, { ref: ref, ...rest });
|
|
12
9
|
});
|
|
13
10
|
|
|
14
11
|
export { PaginationItem };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
-
import
|
|
5
|
-
import { forwardRef, useContext } from 'react';
|
|
6
|
-
import { PaginationContext } from './PaginationRoot.js';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
7
5
|
|
|
8
|
-
const PaginationList = forwardRef(function PaginationList({ asChild,
|
|
9
|
-
const { size } = useContext(PaginationContext);
|
|
6
|
+
const PaginationList = forwardRef(function PaginationList({ asChild, ...rest }, ref) {
|
|
10
7
|
const Component = asChild ? Slot : 'ul';
|
|
11
|
-
return
|
|
8
|
+
return jsx(Component, { ref: ref, ...rest });
|
|
12
9
|
});
|
|
13
10
|
|
|
14
11
|
export { PaginationList };
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Pagination as Pagination$1 } from './Pagination.js';
|
|
3
3
|
import { PaginationButton } from './PaginationButton.js';
|
|
4
|
-
import { PaginationEllipsis } from './PaginationEllipsis.js';
|
|
5
4
|
import { PaginationItem } from './PaginationItem.js';
|
|
6
5
|
import { PaginationList } from './PaginationList.js';
|
|
7
|
-
import { PaginationPrevious, PaginationNext } from './PaginationNextPrev.js';
|
|
8
|
-
import { PaginationRoot } from './PaginationRoot.js';
|
|
9
6
|
|
|
10
|
-
const Pagination = Pagination$1
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Pagination.Ellipsis = PaginationEllipsis;
|
|
16
|
-
Pagination.Previous = PaginationPrevious;
|
|
17
|
-
Pagination.Next = PaginationNext;
|
|
18
|
-
Pagination.Root.displayName = 'Pagination.Root';
|
|
7
|
+
const Pagination = Object.assign(Pagination$1, {
|
|
8
|
+
List: PaginationList,
|
|
9
|
+
Item: PaginationItem,
|
|
10
|
+
Button: PaginationButton,
|
|
11
|
+
});
|
|
19
12
|
Pagination.List.displayName = 'Pagination.List';
|
|
20
13
|
Pagination.Item.displayName = 'Pagination.Item';
|
|
21
14
|
Pagination.Button.displayName = 'Pagination.Button';
|
|
22
|
-
Pagination.Ellipsis.displayName = 'Pagination.Ellipsis';
|
|
23
|
-
Pagination.Previous.displayName = 'Pagination.Previous';
|
|
24
|
-
Pagination.Next.displayName = 'Pagination.Next';
|
|
25
15
|
|
|
26
|
-
export { Pagination, PaginationButton,
|
|
16
|
+
export { Pagination, PaginationButton, PaginationItem, PaginationList };
|
|
@@ -1,63 +1,58 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
3
|
|
|
4
|
-
const getSteps = (
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const siblingsStart = Math.max(Math.min(currentPage - siblingCount, totalPages - boundaryCount - siblingCount * 2 - 1), boundaryCount + 2);
|
|
15
|
-
const siblingsEnd = siblingsStart + siblingCount * 2;
|
|
16
|
-
return [
|
|
17
|
-
...startPages,
|
|
18
|
-
siblingsStart - (startPages[startPages.length - 1] ?? 0) === 2
|
|
19
|
-
? siblingsStart - 1
|
|
20
|
-
: 'ellipsis',
|
|
21
|
-
...range(siblingsStart, siblingsEnd),
|
|
22
|
-
(endPages[0] ?? totalPages + 1) - siblingsEnd === 2
|
|
23
|
-
? siblingsEnd + 1
|
|
24
|
-
: 'ellipsis',
|
|
25
|
-
...endPages,
|
|
26
|
-
];
|
|
4
|
+
const getSteps = (now, max, show) => {
|
|
5
|
+
const offset = (show - 1) / 2;
|
|
6
|
+
const start = Math.min(Math.max(now - Math.floor(offset), 1), max - show + 1);
|
|
7
|
+
const end = Math.min(Math.max(now + Math.ceil(offset), show), max);
|
|
8
|
+
const pages = Array.from({ length: end + 1 - start }, (_, i) => i + start);
|
|
9
|
+
if (show > 4 && start > 1)
|
|
10
|
+
pages.splice(0, 2, 1, 0);
|
|
11
|
+
if (show > 3 && end < max)
|
|
12
|
+
pages.splice(-2, 2, 0, max);
|
|
13
|
+
return pages;
|
|
27
14
|
};
|
|
28
15
|
/** Hook to help manage pagination state */
|
|
29
|
-
const usePagination = ({
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setCurrentPage(currentPage + 1 <= totalPages ? currentPage + 1 : totalPages);
|
|
39
|
-
};
|
|
40
|
-
const previousPage = () => {
|
|
41
|
-
setCurrentPage(currentPage - 1 > 0 ? currentPage - 1 : 1);
|
|
16
|
+
const usePagination = ({ currentPage = 1, setCurrentPage, onChange, totalPages, showPages = 7, }) => useMemo(() => {
|
|
17
|
+
const hasNext = currentPage < totalPages;
|
|
18
|
+
const hasPrev = currentPage !== 1;
|
|
19
|
+
const handleClick = (page) => (event) => {
|
|
20
|
+
if (page < 1 || page > totalPages)
|
|
21
|
+
return event.preventDefault(); // Prevent out of bounds navigation
|
|
22
|
+
onChange?.(event, page);
|
|
23
|
+
if (!event.defaultPrevented)
|
|
24
|
+
setCurrentPage?.(page); // Allow stopping change by calling event.preventDefault() in onChange
|
|
42
25
|
};
|
|
43
26
|
return {
|
|
44
27
|
/** Number of steps */
|
|
45
|
-
pages,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
|
|
28
|
+
pages: getSteps(currentPage, totalPages, showPages).map((page, index) => ({
|
|
29
|
+
page: page || '',
|
|
30
|
+
itemKey: page ? `page-${page}` : `ellipsis-${index}`, // React key utility
|
|
31
|
+
buttonProps: {
|
|
32
|
+
'aria-current': page === currentPage ? 'page' : undefined,
|
|
33
|
+
'aria-hidden': !page || undefined, // Hide ellipsis from screen reader
|
|
34
|
+
onClick: handleClick(page),
|
|
35
|
+
tabIndex: page ? undefined : -1, // Hide ellipsis keyboard
|
|
36
|
+
variant: page === currentPage ? 'primary' : 'tertiary',
|
|
37
|
+
},
|
|
38
|
+
})),
|
|
39
|
+
/** Properties to spread on Pagination.Button used for previous naviagation */
|
|
40
|
+
prevButtonProps: {
|
|
41
|
+
'aria-disabled': !hasPrev, // Using aria-disabled to support all HTML elements because of potential asChild
|
|
42
|
+
onClick: handleClick(currentPage - 1),
|
|
43
|
+
variant: 'tertiary',
|
|
44
|
+
},
|
|
45
|
+
/** Properties to spread on Pagination.Button used for next naviagation */
|
|
46
|
+
nextButtonProps: {
|
|
47
|
+
'aria-disabled': !hasNext, // Using aria-disabled to support all HTML elements because of potential asChild
|
|
48
|
+
onClick: handleClick(currentPage + 1),
|
|
49
|
+
variant: 'tertiary',
|
|
50
|
+
},
|
|
58
51
|
/** Indication if previous page action should be shown or not */
|
|
59
|
-
|
|
52
|
+
hasPrev,
|
|
53
|
+
/** Indication if next page action should be shown or not */
|
|
54
|
+
hasNext,
|
|
60
55
|
};
|
|
61
|
-
};
|
|
56
|
+
}, [currentPage, totalPages, showPages]);
|
|
62
57
|
|
|
63
58
|
export { usePagination };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import cl from 'clsx/lite';
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Use `Paragraph` to display text with paragraph text styles.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Paragraph size='lg'>Paragraph</Paragraph>
|
|
12
|
+
*/
|
|
13
|
+
const Paragraph = forwardRef(function Paragraph({ className, size = 'md', asChild, variant = 'default', ...rest }, ref) {
|
|
14
|
+
const Component = asChild ? Slot : 'p';
|
|
15
|
+
return (jsx(Component, { ref: ref, className: cl(`ds-paragraph`, className), "data-size": size, "data-variant": variant, ...rest }));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { Paragraph };
|
|
@@ -6,7 +6,6 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
6
6
|
import cl from 'clsx/lite';
|
|
7
7
|
import { forwardRef, useRef, useContext, useState, useEffect } from 'react';
|
|
8
8
|
import { Context } from './PopoverContext.js';
|
|
9
|
-
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
10
9
|
|
|
11
10
|
const ARROW_HEIGHT = 7;
|
|
12
11
|
const ARROW_GAP = 4;
|
|
@@ -74,9 +73,9 @@ const Popover = forwardRef(function Popover({ id, className, onClose, onOpen, op
|
|
|
74
73
|
if (id)
|
|
75
74
|
setPopoverId?.(id);
|
|
76
75
|
}, [id]);
|
|
77
|
-
return (jsx(
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
return (jsx(Component, { className: cl('ds-popover', className), "data-size": size, "data-variant": variant, id: id || popoverId,
|
|
77
|
+
// @ts-ignore @types/react-dom does not understand popover yet
|
|
78
|
+
popover: 'manual', ref: mergedRefs, ...rest }));
|
|
80
79
|
});
|
|
81
80
|
const arrowPseudoElement = {
|
|
82
81
|
name: 'ArrowPseudoElement',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import cl from 'clsx/lite';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
4
5
|
|
|
5
|
-
const SkipLink = ({
|
|
6
|
-
return (jsx("a", {
|
|
7
|
-
};
|
|
8
|
-
SkipLink.displayName = 'SkipLink';
|
|
6
|
+
const SkipLink = forwardRef(function SkipLink({ children, className, ...rest }, ref) {
|
|
7
|
+
return (jsx("a", { className: cl('ds-skiplink', className), ...rest, ref: ref, children: children }));
|
|
8
|
+
});
|
|
9
9
|
|
|
10
10
|
export { SkipLink };
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import cl from 'clsx/lite';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
|
-
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
6
5
|
|
|
7
6
|
const Table = forwardRef(function Table({ zebra = false, stickyHeader = false, border = false, hover = false, size = 'md', className, children, ...rest }, ref) {
|
|
8
|
-
return (jsx(
|
|
7
|
+
return (jsx("table", { className: cl('ds-table', className), "data-border": border || undefined, "data-hover": hover || undefined, "data-size": size, "data-sticky-header": stickyHeader || undefined, "data-zebra": zebra || undefined, ref: ref, ...rest, children: children }));
|
|
9
8
|
});
|
|
10
9
|
|
|
11
10
|
export { Table };
|
|
@@ -3,7 +3,6 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
3
3
|
import cl from 'clsx/lite';
|
|
4
4
|
import { forwardRef, useContext } from 'react';
|
|
5
5
|
import { Context } from './Tabs.js';
|
|
6
|
-
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* A single content item in a Tabs component.
|
|
@@ -15,7 +14,7 @@ import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
|
15
14
|
const TabsPanel = forwardRef(function TabsPanel({ children, value, className, ...rest }, ref) {
|
|
16
15
|
const { value: tabsValue, size } = useContext(Context);
|
|
17
16
|
const active = value === tabsValue;
|
|
18
|
-
return (jsx(Fragment, { children: active && (jsx(
|
|
17
|
+
return (jsx(Fragment, { children: active && (jsx("div", { className: cl('ds-tabs__panel', className), ref: ref, ...rest, children: children })) }));
|
|
19
18
|
});
|
|
20
19
|
|
|
21
20
|
export { TabsPanel };
|
|
@@ -4,7 +4,6 @@ import cl from 'clsx/lite';
|
|
|
4
4
|
import { forwardRef, useContext, useId } from 'react';
|
|
5
5
|
import { RovingFocusItem } from '../../utilities/RovingFocus/RovingFocusItem.js';
|
|
6
6
|
import { Context } from './Tabs.js';
|
|
7
|
-
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* A single item in a Tabs component.
|
|
@@ -14,7 +13,7 @@ import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
|
14
13
|
const TabsTab = forwardRef(function TabsTab({ className, value, ...rest }, ref) {
|
|
15
14
|
const tabs = useContext(Context);
|
|
16
15
|
const buttonId = `tab-${useId()}`;
|
|
17
|
-
return (jsx(RovingFocusItem, { value: value, ...rest, asChild: true, children: jsx(
|
|
16
|
+
return (jsx(RovingFocusItem, { value: value, ...rest, asChild: true, children: jsx("button", { ...rest, "aria-selected": tabs.value === value, className: cl('ds-tabs__tab', className), id: buttonId, onClick: () => tabs.onChange?.(value), ref: ref, role: 'tab', type: 'button' }) }));
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
export { TabsTab };
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import cl from 'clsx/lite';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
|
-
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Use `Tag` to display a small piece of information.
|
|
@@ -10,7 +9,7 @@ import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
|
10
9
|
* <Tag color='success'>Success</Tag>
|
|
11
10
|
*/
|
|
12
11
|
const Tag = forwardRef(function Tag({ size = 'md', color = 'neutral', className, ...rest }, ref) {
|
|
13
|
-
return (jsx(
|
|
12
|
+
return (jsx("span", { className: cl('ds-tag', className), "data-color": color, "data-size": size, ref: ref, ...rest }));
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
export { Tag };
|
|
@@ -3,7 +3,6 @@ import { jsxs, Fragment as Fragment$1, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useFloating, autoUpdate, offset, flip, shift, arrow, useTransitionStyles, useInteractions, useHover, useFocus, useDismiss, useRole, useMergeRefs, FloatingArrow, FloatingPortal } from '@floating-ui/react';
|
|
4
4
|
import cl from 'clsx/lite';
|
|
5
5
|
import { forwardRef, useState, useRef, Fragment, cloneElement } from 'react';
|
|
6
|
-
import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
|
|
7
6
|
|
|
8
7
|
const ARROW_HEIGHT = 7;
|
|
9
8
|
const ARROW_GAP = 4;
|
|
@@ -61,11 +60,11 @@ const Tooltip = forwardRef(({ children, content, placement = 'top', delay = 150,
|
|
|
61
60
|
}
|
|
62
61
|
return (jsxs(Fragment$1, { children: [cloneElement(children, getReferenceProps({
|
|
63
62
|
ref: childMergedRef,
|
|
64
|
-
})), internalOpen && (jsx(Container, { children:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
})), internalOpen && (jsx(Container, { children: jsxs("div", { ref: refs.setFloating, style: { ...floatingStyles, ...animationStyles, ...style }, role: 'tooltip', ...getFloatingProps({
|
|
64
|
+
className: cl('ds-tooltip', className),
|
|
65
|
+
ref: mergedRef,
|
|
66
|
+
...rest,
|
|
67
|
+
}), children: [content, jsx(FloatingArrow, { ref: arrowRef, context: context, className: 'ds-tooltip__arrow', height: ARROW_HEIGHT })] }) }))] }));
|
|
69
68
|
});
|
|
70
69
|
Tooltip.displayName = 'Tooltip';
|
|
71
70
|
|
package/dist/esm/components/{Typography/ValidationMessage → ValidationMessage}/ValidationMessage.js
RENAMED
|
@@ -5,9 +5,9 @@ import cl from 'clsx/lite';
|
|
|
5
5
|
import { forwardRef } from 'react';
|
|
6
6
|
|
|
7
7
|
/** Use `ValidationMessage` to display validation text */
|
|
8
|
-
const ValidationMessage = forwardRef(function ValidationMessage({ size = 'md', className,
|
|
8
|
+
const ValidationMessage = forwardRef(function ValidationMessage({ size = 'md', className, asChild, error = true, ...rest }, ref) {
|
|
9
9
|
const Component = asChild ? Slot : 'div';
|
|
10
|
-
return (jsx(Component, {
|
|
10
|
+
return (jsx(Component, { className: cl(`ds-validation-message--${size}`, className), "data-error": error || undefined, ref: ref, ...rest }));
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
export { ValidationMessage };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { ValidationMessage } from '../
|
|
3
|
+
import { ValidationMessage } from '../ValidationMessage/ValidationMessage.js';
|
|
4
4
|
|
|
5
5
|
const defaultLabel = (count) => count > -1 ? `${count} tegn igjen` : `${Math.abs(count)} tegn for mye`;
|
|
6
6
|
const defaultSrLabel = (maxCount) => `Tekstfelt med plass til ${maxCount} tegn`;
|
|
@@ -4,9 +4,9 @@ import { useMergeRefs } from '@floating-ui/react';
|
|
|
4
4
|
import cl from 'clsx/lite';
|
|
5
5
|
import { forwardRef } from 'react';
|
|
6
6
|
import { useCheckbox } from './useCheckbox.js';
|
|
7
|
-
import { Paragraph } from '../../
|
|
7
|
+
import { Paragraph } from '../../Paragraph/Paragraph.js';
|
|
8
8
|
import { omit } from '../../../utilities/omit/omit.js';
|
|
9
|
-
import { Label } from '../../
|
|
9
|
+
import { Label } from '../../Label/Label.js';
|
|
10
10
|
|
|
11
11
|
const Checkbox = forwardRef((props, ref) => {
|
|
12
12
|
const { children, description, className, style, ...rest } = props;
|