@navikt/ds-react 5.18.0 → 5.18.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/cjs/date/parts/DateWrapper.js +2 -2
- package/cjs/form/search/Search.js +1 -1
- package/cjs/modal/Modal.context.js +9 -0
- package/cjs/modal/Modal.js +3 -6
- package/cjs/modal/ModalHeader.js +2 -6
- package/cjs/panel/Panel.js +6 -16
- package/cjs/popover/Popover.js +2 -2
- package/cjs/tooltip/Tooltip.js +2 -2
- package/cjs/util/create-context.js +9 -5
- package/esm/date/parts/DateWrapper.js +3 -3
- package/esm/date/parts/DateWrapper.js.map +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/modal/Modal.context.d.ts +9 -0
- package/esm/modal/Modal.context.js +6 -0
- package/esm/modal/Modal.context.js.map +1 -0
- package/esm/modal/Modal.js +3 -6
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalHeader.js +3 -7
- package/esm/modal/ModalHeader.js.map +1 -1
- package/esm/panel/Panel.d.ts +9 -16
- package/esm/panel/Panel.js +6 -16
- package/esm/panel/Panel.js.map +1 -1
- package/esm/popover/Popover.js +2 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/tooltip/Tooltip.js +3 -3
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/util/create-context.d.ts +2 -5
- package/esm/util/create-context.js +10 -6
- package/esm/util/create-context.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/accordion.stories.tsx +121 -135
- package/src/alert/alert.stories.tsx +202 -113
- package/src/button/button.stories.tsx +88 -185
- package/src/chat/chat.stories.tsx +284 -206
- package/src/date/datepicker/datepicker.stories.tsx +6 -2
- package/src/date/monthpicker/monthpicker.stories.tsx +2 -1
- package/src/date/parts/DateWrapper.tsx +3 -3
- package/src/dropdown/dropdown.stories.tsx +1 -1
- package/src/form/error-summary/error-summary.stories.tsx +1 -1
- package/src/form/search/Search.tsx +3 -3
- package/src/form/stories/confirmation-panel.stories.tsx +1 -1
- package/src/help-text/help-text.stories.tsx +2 -1
- package/src/internal-header/header.stories.tsx +2 -1
- package/src/layout/bleed/Bleed.stories.tsx +2 -1
- package/src/layout/box/Box.stories.tsx +2 -1
- package/src/layout/sidemal-test/navno-sidemal.stories.tsx +5 -1
- package/src/link/stories/link.stories.tsx +20 -22
- package/src/link-panel/link-panel.stories.tsx +1 -1
- package/src/list/list.stories.tsx +2 -1
- package/src/loader/loader.stories.tsx +1 -1
- package/src/modal/Modal.context.ts +13 -0
- package/src/modal/Modal.tsx +6 -8
- package/src/modal/ModalHeader.tsx +3 -7
- package/src/modal/modal.stories.tsx +3 -1
- package/src/panel/Panel.tsx +9 -16
- package/src/popover/Popover.tsx +2 -2
- package/src/stepper/stepper.stories.tsx +1 -1
- package/src/table/stories/{table.stories.tsx → table-1.stories.tsx} +118 -92
- package/src/table/stories/{table-expandable.stories.tsx → table-2-expandable.stories.tsx} +10 -34
- package/src/table/stories/{table-async.stories.tsx → table-3-async.stories.tsx} +5 -3
- package/src/table/stories/tests/table.stories.tsx +4 -1
- package/src/tabs/Tabs.test.tsx +109 -0
- package/src/toggle-group/ToggleGroup.test.tsx +54 -0
- package/src/tooltip/Tooltip.tsx +3 -9
- package/src/tooltip/tooltip.stories.tsx +4 -1
- package/src/typography/stories/bodylong.stories.tsx +49 -3
- package/src/typography/stories/bodyshort.stories.tsx +50 -4
- package/src/typography/stories/detail.stories.tsx +32 -3
- package/src/typography/stories/error-message.stories.tsx +34 -3
- package/src/typography/stories/heading.stories.tsx +32 -3
- package/src/typography/stories/label.stories.tsx +38 -3
- package/src/util/create-context.tsx +26 -15
- package/cjs/modal/ModalContext.js +0 -8
- package/esm/modal/ModalContext.d.ts +0 -7
- package/esm/modal/ModalContext.js +0 -3
- package/esm/modal/ModalContext.js.map +0 -1
- package/src/modal/ModalContext.ts +0 -7
- package/src/panel/panel.stories.tsx +0 -63
- package/src/typography/stories/ingress.stories.tsx +0 -50
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Box
|
|
3
|
+
import { Box } from "../box";
|
|
4
|
+
import { HGrid } from "../grid";
|
|
5
|
+
import { Hide, Show } from "../responsive";
|
|
6
|
+
import { VStack } from "../stack";
|
|
4
7
|
import { Content } from "./Content";
|
|
5
8
|
import { FilterCard } from "./Filter";
|
|
6
9
|
import { Header } from "./Header";
|
|
@@ -13,6 +16,7 @@ const meta = {
|
|
|
13
16
|
title: "kitchen sink/navno-sidemal",
|
|
14
17
|
parameters: {
|
|
15
18
|
layout: "fullscreen",
|
|
19
|
+
chromatic: { disable: true },
|
|
16
20
|
},
|
|
17
21
|
} satisfies Meta;
|
|
18
22
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PlusCircleFillIcon } from "@navikt/aksel-icons";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Link,
|
|
8
|
-
} from "../..";
|
|
3
|
+
import { Alert } from "../../alert";
|
|
4
|
+
import { ConfirmationPanel } from "../../form";
|
|
5
|
+
import { BodyLong } from "../../typography";
|
|
6
|
+
import Link from "../Link";
|
|
9
7
|
import { RandomIcon } from "./RandomIcon";
|
|
10
8
|
|
|
11
9
|
export default {
|
|
@@ -139,37 +137,37 @@ const DemoLink = () => (
|
|
|
139
137
|
|
|
140
138
|
export const Icon = () => <DemoLink />;
|
|
141
139
|
|
|
142
|
-
export const
|
|
140
|
+
export const InAlert = () => {
|
|
143
141
|
return (
|
|
144
142
|
<div className="colgap">
|
|
145
|
-
<
|
|
143
|
+
<Alert variant="info">
|
|
146
144
|
<DemoLink />
|
|
147
|
-
</
|
|
148
|
-
<
|
|
145
|
+
</Alert>
|
|
146
|
+
<Alert variant="success">
|
|
149
147
|
<DemoLink />
|
|
150
|
-
</
|
|
151
|
-
<
|
|
148
|
+
</Alert>
|
|
149
|
+
<Alert variant="warning">
|
|
152
150
|
<DemoLink />
|
|
153
|
-
</
|
|
154
|
-
<
|
|
151
|
+
</Alert>
|
|
152
|
+
<Alert variant="error">
|
|
155
153
|
<DemoLink />
|
|
156
|
-
</
|
|
154
|
+
</Alert>
|
|
157
155
|
</div>
|
|
158
156
|
);
|
|
159
157
|
};
|
|
160
158
|
|
|
161
|
-
export const
|
|
159
|
+
export const InConfirmationPanel = () => {
|
|
162
160
|
return (
|
|
163
161
|
<div className="colgap">
|
|
164
|
-
<
|
|
162
|
+
<ConfirmationPanel label="demo">
|
|
165
163
|
<DemoLink />
|
|
166
|
-
</
|
|
167
|
-
<
|
|
164
|
+
</ConfirmationPanel>
|
|
165
|
+
<ConfirmationPanel checked label="demo">
|
|
168
166
|
<DemoLink />
|
|
169
|
-
</
|
|
170
|
-
<
|
|
167
|
+
</ConfirmationPanel>
|
|
168
|
+
<ConfirmationPanel error="demo" label="demo">
|
|
171
169
|
<DemoLink />
|
|
172
|
-
</
|
|
170
|
+
</ConfirmationPanel>
|
|
173
171
|
</div>
|
|
174
172
|
);
|
|
175
173
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createContext } from "../util/create-context";
|
|
3
|
+
|
|
4
|
+
interface ModalContextProps {
|
|
5
|
+
closeHandler?: React.MouseEventHandler<HTMLButtonElement>;
|
|
6
|
+
ref: React.RefObject<HTMLDialogElement>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const [ModalContextProvider, useModalContext] =
|
|
10
|
+
createContext<ModalContextProps>({
|
|
11
|
+
name: "ModalContext",
|
|
12
|
+
errorMessage: "<Modal.Header> must be used within a <Modal>",
|
|
13
|
+
});
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -8,8 +8,8 @@ import { Detail, Heading } from "../typography";
|
|
|
8
8
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
9
9
|
import { useId } from "../util/hooks";
|
|
10
10
|
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
11
|
+
import { ModalContextProvider, useModalContext } from "./Modal.context";
|
|
11
12
|
import ModalBody from "./ModalBody";
|
|
12
|
-
import { ModalContext } from "./ModalContext";
|
|
13
13
|
import ModalFooter from "./ModalFooter";
|
|
14
14
|
import ModalHeader from "./ModalHeader";
|
|
15
15
|
import { getCloseHandler, useBodyScrollLock } from "./ModalUtils";
|
|
@@ -98,7 +98,7 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
|
|
|
98
98
|
const portalNode = useFloatingPortalNode({ root: rootElement });
|
|
99
99
|
|
|
100
100
|
const dateContext = useContext(DateContext);
|
|
101
|
-
const modalContext =
|
|
101
|
+
const modalContext = useModalContext(false);
|
|
102
102
|
if (modalContext && !dateContext) {
|
|
103
103
|
console.error("Modals should not be nested");
|
|
104
104
|
}
|
|
@@ -185,11 +185,9 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
|
|
|
185
185
|
onClick={composeEventHandlers(onClick, handleModalClick)}
|
|
186
186
|
aria-labelledby={mergedAriaLabelledBy}
|
|
187
187
|
>
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
ref: modalRef,
|
|
192
|
-
}}
|
|
188
|
+
<ModalContextProvider
|
|
189
|
+
closeHandler={getCloseHandler(modalRef, header, onBeforeClose)}
|
|
190
|
+
ref={modalRef}
|
|
193
191
|
>
|
|
194
192
|
{header && (
|
|
195
193
|
<ModalHeader>
|
|
@@ -208,7 +206,7 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
|
|
|
208
206
|
)}
|
|
209
207
|
|
|
210
208
|
{children}
|
|
211
|
-
</
|
|
209
|
+
</ModalContextProvider>
|
|
212
210
|
</dialog>
|
|
213
211
|
);
|
|
214
212
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, { forwardRef
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
3
|
import { XMarkIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { Button } from "../button";
|
|
5
|
-
import {
|
|
5
|
+
import { useModalContext } from "./Modal.context";
|
|
6
6
|
|
|
7
7
|
export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
children?: React.ReactNode;
|
|
@@ -15,11 +15,7 @@ export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
15
15
|
|
|
16
16
|
const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>(
|
|
17
17
|
({ children, className, closeButton = true, ...rest }, ref) => {
|
|
18
|
-
const context =
|
|
19
|
-
if (context === null) {
|
|
20
|
-
console.error("<Modal.Header> has to be used within a <Modal>");
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
18
|
+
const context = useModalContext();
|
|
23
19
|
|
|
24
20
|
return (
|
|
25
21
|
<div {...rest} ref={ref} className={cl("navds-modal__header", className)}>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Meta, StoryFn } from "@storybook/react";
|
|
2
2
|
import React, { useRef, useState } from "react";
|
|
3
3
|
import { FileIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import {
|
|
4
|
+
import { Button } from "../button";
|
|
5
5
|
import { Checkbox, CheckboxGroup } from "../form/checkbox";
|
|
6
6
|
import { VStack } from "../layout/stack";
|
|
7
|
+
import { Tooltip } from "../tooltip";
|
|
8
|
+
import { BodyLong, Heading } from "../typography";
|
|
7
9
|
import Modal from "./Modal";
|
|
8
10
|
|
|
9
11
|
const meta: Meta<typeof Modal> = {
|
package/src/panel/Panel.tsx
CHANGED
|
@@ -2,6 +2,9 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import { OverridableComponent } from "../util/types";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use Box with padding and border instead
|
|
7
|
+
*/
|
|
5
8
|
export interface PanelProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
9
|
/**
|
|
7
10
|
* Panel content
|
|
@@ -17,23 +20,13 @@ export interface PanelProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
17
20
|
export type PanelType = OverridableComponent<PanelProps, HTMLElement>;
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```jsx
|
|
28
|
-
* <Panel border>
|
|
29
|
-
* <Heading spacing level="2" size="large">
|
|
30
|
-
* Søk om økonomisk sosialhjelp
|
|
31
|
-
* </Heading>
|
|
32
|
-
* <BodyLong>
|
|
33
|
-
* Du kan søke om det du trenger økonomisk støtte til.
|
|
34
|
-
* </BodyLong>
|
|
35
|
-
* </Panel>
|
|
23
|
+
* @deprecated
|
|
24
|
+
* Use Box with padding and border instead
|
|
25
|
+
* ```
|
|
26
|
+
* <Box padding="4" borderRadius="small" />
|
|
27
|
+
* <Box padding="4" borderWidth="1" borderRadius="small" />
|
|
36
28
|
* ```
|
|
29
|
+
* Component will be removed in a future major release
|
|
37
30
|
*/
|
|
38
31
|
export const Panel: PanelType = forwardRef(
|
|
39
32
|
(
|
package/src/popover/Popover.tsx
CHANGED
|
@@ -18,7 +18,7 @@ import React, {
|
|
|
18
18
|
useRef,
|
|
19
19
|
} from "react";
|
|
20
20
|
import { DateContext } from "../date/context";
|
|
21
|
-
import {
|
|
21
|
+
import { useModalContext } from "../modal/Modal.context";
|
|
22
22
|
import { useClientLayoutEffect, useEventListener } from "../util/hooks";
|
|
23
23
|
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
24
24
|
import PopoverContent, { PopoverContentType } from "./PopoverContent";
|
|
@@ -126,7 +126,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
|
126
126
|
ref,
|
|
127
127
|
) => {
|
|
128
128
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
129
|
-
const isInModal =
|
|
129
|
+
const isInModal = useModalContext(false) !== undefined;
|
|
130
130
|
const isInDatepicker = useContext(DateContext) !== null;
|
|
131
131
|
const chosenStrategy = userStrategy ?? (isInModal ? "fixed" : "absolute");
|
|
132
132
|
const chosenFlip = isInDatepicker ? false : _flip;
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { Table, TableProps } from "../";
|
|
3
|
-
import {
|
|
3
|
+
import { Button } from "../../button";
|
|
4
|
+
import { Checkbox } from "../../form";
|
|
5
|
+
import { VStack } from "../../layout/stack";
|
|
6
|
+
import {
|
|
7
|
+
Expandable,
|
|
8
|
+
ExpandableLarge,
|
|
9
|
+
ExpandableSmall,
|
|
10
|
+
} from "./table-2-expandable.stories";
|
|
4
11
|
|
|
5
12
|
export default {
|
|
6
13
|
title: "ds-react/Table",
|
|
7
14
|
component: Table,
|
|
15
|
+
parameters: {
|
|
16
|
+
chromatic: { disable: true },
|
|
17
|
+
},
|
|
8
18
|
};
|
|
9
19
|
|
|
10
20
|
interface Props extends TableProps {
|
|
11
21
|
button?: boolean;
|
|
12
22
|
shadeOnHover?: boolean;
|
|
13
23
|
}
|
|
24
|
+
|
|
14
25
|
const TableComponent = ({ button, shadeOnHover, ...rest }: Props) => (
|
|
15
26
|
<Table {...rest}>
|
|
16
27
|
<Table.Header>
|
|
@@ -89,75 +100,59 @@ export const Buttons = () => <TableComponent size="small" button />;
|
|
|
89
100
|
|
|
90
101
|
export const WithDivs = () => {
|
|
91
102
|
return (
|
|
92
|
-
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
103
|
+
<div className="navds-table" role="table">
|
|
104
|
+
<div className="navds-table__header" role="rowgroup">
|
|
105
|
+
<div className="navds-table__row" role="row">
|
|
106
|
+
<div className="navds-table__header-cell" role="columnheader">
|
|
107
|
+
Fornavn
|
|
108
|
+
</div>
|
|
109
|
+
<div className="navds-table__header-cell" role="columnheader">
|
|
110
|
+
Etternavn
|
|
111
|
+
</div>
|
|
112
|
+
<div className="navds-table__header-cell" role="columnheader">
|
|
113
|
+
Rolle
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div className="navds-table__body" role="rowgroup">
|
|
118
|
+
<div className="navds-table__row" role="row">
|
|
119
|
+
<div className="navds-table__data-cell" role="cell">
|
|
120
|
+
Jean-Luc
|
|
121
|
+
</div>
|
|
122
|
+
<div className="navds-table__data-cell" role="cell">
|
|
123
|
+
Picard
|
|
124
|
+
</div>
|
|
125
|
+
<div className="navds-table__data-cell" role="cell">
|
|
126
|
+
Kaptein
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
<div className="navds-table__row" role="row">
|
|
130
|
+
<div className="navds-table__data-cell" role="cell">
|
|
131
|
+
William
|
|
132
|
+
</div>
|
|
133
|
+
<div className="navds-table__data-cell" role="cell">
|
|
134
|
+
Riker
|
|
135
|
+
</div>
|
|
136
|
+
<div className="navds-table__data-cell" role="cell">
|
|
137
|
+
Kommandør
|
|
116
138
|
</div>
|
|
117
139
|
</div>
|
|
118
|
-
<div className="navds-
|
|
119
|
-
<div className="navds-
|
|
120
|
-
|
|
121
|
-
Jean-Luc
|
|
122
|
-
</div>
|
|
123
|
-
<div className="navds-table__data-cell" role="cell">
|
|
124
|
-
Picard
|
|
125
|
-
</div>
|
|
126
|
-
<div className="navds-table__data-cell" role="cell">
|
|
127
|
-
Kaptein
|
|
128
|
-
</div>
|
|
140
|
+
<div className="navds-table__row" role="row">
|
|
141
|
+
<div className="navds-table__data-cell" role="cell">
|
|
142
|
+
Geordi
|
|
129
143
|
</div>
|
|
130
|
-
<div className="navds-
|
|
131
|
-
|
|
132
|
-
William
|
|
133
|
-
</div>
|
|
134
|
-
<div className="navds-table__data-cell" role="cell">
|
|
135
|
-
Riker
|
|
136
|
-
</div>
|
|
137
|
-
<div className="navds-table__data-cell" role="cell">
|
|
138
|
-
Kommandør
|
|
139
|
-
</div>
|
|
144
|
+
<div className="navds-table__data-cell" role="cell">
|
|
145
|
+
La Forge
|
|
140
146
|
</div>
|
|
141
|
-
<div className="navds-
|
|
142
|
-
|
|
143
|
-
Geordi
|
|
144
|
-
</div>
|
|
145
|
-
<div className="navds-table__data-cell" role="cell">
|
|
146
|
-
La Forge
|
|
147
|
-
</div>
|
|
148
|
-
<div className="navds-table__data-cell" role="cell">
|
|
149
|
-
Sjefsingeniør
|
|
150
|
-
</div>
|
|
147
|
+
<div className="navds-table__data-cell" role="cell">
|
|
148
|
+
Sjefsingeniør
|
|
151
149
|
</div>
|
|
152
150
|
</div>
|
|
153
151
|
</div>
|
|
154
|
-
|
|
152
|
+
</div>
|
|
155
153
|
);
|
|
156
154
|
};
|
|
157
155
|
|
|
158
|
-
export const Selection = () => <SelectionTable />;
|
|
159
|
-
export const SelectionSmall = () => <SelectionTable size="small" />;
|
|
160
|
-
|
|
161
156
|
const SelectionTable = ({ size = "medium" }: { size?: "small" | "medium" }) => {
|
|
162
157
|
const useToggleList = (initialState) => {
|
|
163
158
|
const [list, setList] = useState(initialState);
|
|
@@ -182,7 +177,7 @@ const SelectionTable = ({ size = "medium" }: { size?: "small" | "medium" }) => {
|
|
|
182
177
|
<Table.DataCell>
|
|
183
178
|
<Checkbox
|
|
184
179
|
size={size}
|
|
185
|
-
|
|
180
|
+
indeterminate
|
|
186
181
|
onChange={() => toggleSelectedRow("all")}
|
|
187
182
|
>
|
|
188
183
|
Select all
|
|
@@ -212,12 +207,12 @@ const SelectionTable = ({ size = "medium" }: { size?: "small" | "medium" }) => {
|
|
|
212
207
|
<Table.DataCell>USA</Table.DataCell>
|
|
213
208
|
<Table.DataCell>38</Table.DataCell>
|
|
214
209
|
</Table.Row>
|
|
215
|
-
<Table.Row selected
|
|
210
|
+
<Table.Row selected>
|
|
216
211
|
<Table.DataCell>
|
|
217
212
|
<Checkbox
|
|
218
213
|
size={size}
|
|
219
214
|
hideLabel
|
|
220
|
-
checked
|
|
215
|
+
checked
|
|
221
216
|
onChange={() => toggleSelectedRow("2")}
|
|
222
217
|
aria-labelledby={`x_r2-${size}`}
|
|
223
218
|
>
|
|
@@ -231,36 +226,67 @@ const SelectionTable = ({ size = "medium" }: { size?: "small" | "medium" }) => {
|
|
|
231
226
|
<Table.DataCell>Denmark</Table.DataCell>
|
|
232
227
|
<Table.DataCell>11</Table.DataCell>
|
|
233
228
|
</Table.Row>
|
|
234
|
-
<Table.Row selected={selectedRows.includes("3")}>
|
|
235
|
-
<Table.DataCell>
|
|
236
|
-
<CheckboxGroup legend="velg flere felt" hideLegend>
|
|
237
|
-
<Checkbox
|
|
238
|
-
size={size}
|
|
239
|
-
hideLabel
|
|
240
|
-
checked={selectedRows.includes("3")}
|
|
241
|
-
onChange={() => toggleSelectedRow("3")}
|
|
242
|
-
aria-labelledby={`x_r3-${size}`}
|
|
243
|
-
>
|
|
244
|
-
{" "}
|
|
245
|
-
</Checkbox>
|
|
246
|
-
<Checkbox
|
|
247
|
-
size={size}
|
|
248
|
-
hideLabel
|
|
249
|
-
checked={selectedRows.includes("3")}
|
|
250
|
-
onChange={() => toggleSelectedRow("3")}
|
|
251
|
-
aria-labelledby={`x_r3-${size}`}
|
|
252
|
-
>
|
|
253
|
-
{" "}
|
|
254
|
-
</Checkbox>
|
|
255
|
-
</CheckboxGroup>
|
|
256
|
-
</Table.DataCell>
|
|
257
|
-
<Table.HeaderCell scope="row" colSpan={4}>
|
|
258
|
-
<span id={`x_r3-${size}`}>
|
|
259
|
-
Don't stack multiple checkboxes
|
|
260
|
-
</span>
|
|
261
|
-
</Table.HeaderCell>
|
|
262
|
-
</Table.Row>
|
|
263
229
|
</Table.Body>
|
|
264
230
|
</Table>
|
|
265
231
|
);
|
|
266
232
|
};
|
|
233
|
+
|
|
234
|
+
export const Selection = () => <SelectionTable />;
|
|
235
|
+
export const SelectionSmall = () => <SelectionTable size="small" />;
|
|
236
|
+
|
|
237
|
+
export const Chromatic = {
|
|
238
|
+
render: () => (
|
|
239
|
+
<VStack gap="8">
|
|
240
|
+
<div>
|
|
241
|
+
<h3>Default</h3>
|
|
242
|
+
<Default />
|
|
243
|
+
<h3>Zebra</h3>
|
|
244
|
+
<Zebra />
|
|
245
|
+
</div>
|
|
246
|
+
<div>
|
|
247
|
+
<h3>Large</h3>
|
|
248
|
+
<SizeLarge />
|
|
249
|
+
</div>
|
|
250
|
+
<div>
|
|
251
|
+
<h3>Medium</h3>
|
|
252
|
+
<SizeMedium />
|
|
253
|
+
</div>
|
|
254
|
+
<div>
|
|
255
|
+
<h3>Small</h3>
|
|
256
|
+
<SizeSmall />
|
|
257
|
+
</div>
|
|
258
|
+
<div>
|
|
259
|
+
<h3>With Buttons</h3>
|
|
260
|
+
<Buttons />
|
|
261
|
+
</div>
|
|
262
|
+
<div>
|
|
263
|
+
<h3>Custom with divs</h3>
|
|
264
|
+
<WithDivs />
|
|
265
|
+
</div>
|
|
266
|
+
<div>
|
|
267
|
+
<h3>Selection</h3>
|
|
268
|
+
<Selection />
|
|
269
|
+
</div>
|
|
270
|
+
<div>
|
|
271
|
+
<h3>Selection small</h3>
|
|
272
|
+
<SelectionSmall />
|
|
273
|
+
</div>
|
|
274
|
+
<h2>Expandable</h2>
|
|
275
|
+
<div>
|
|
276
|
+
<h3>Large</h3>
|
|
277
|
+
<ExpandableLarge />
|
|
278
|
+
</div>
|
|
279
|
+
<div>
|
|
280
|
+
<h3>Medium</h3>
|
|
281
|
+
<Expandable />
|
|
282
|
+
</div>
|
|
283
|
+
<div>
|
|
284
|
+
<h3>Small</h3>
|
|
285
|
+
<ExpandableSmall />
|
|
286
|
+
</div>
|
|
287
|
+
</VStack>
|
|
288
|
+
),
|
|
289
|
+
parameters: {
|
|
290
|
+
chromatic: { disable: false },
|
|
291
|
+
},
|
|
292
|
+
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Button } from "../../button";
|
|
3
|
+
import { Checkbox } from "../../form";
|
|
4
|
+
import { Link } from "../../link";
|
|
5
|
+
import Table from "../Table";
|
|
4
6
|
|
|
5
7
|
export default {
|
|
6
8
|
title: "ds-react/Table",
|
|
7
9
|
component: Table,
|
|
10
|
+
parameters: {
|
|
11
|
+
chromatic: { disable: true },
|
|
12
|
+
},
|
|
8
13
|
};
|
|
9
14
|
|
|
10
15
|
export const Expandable = () => {
|
|
@@ -25,6 +30,7 @@ export const Expandable = () => {
|
|
|
25
30
|
content={row.content}
|
|
26
31
|
key={row.name}
|
|
27
32
|
togglePlacement="right"
|
|
33
|
+
defaultOpen
|
|
28
34
|
>
|
|
29
35
|
{columns.map(({ key }) => (
|
|
30
36
|
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
@@ -50,7 +56,7 @@ export const ExpandableLarge = () => {
|
|
|
50
56
|
</Table.Header>
|
|
51
57
|
<Table.Body>
|
|
52
58
|
{data.slice(0, 1).map((row) => (
|
|
53
|
-
<Table.ExpandableRow content={row.content} key={row.name}>
|
|
59
|
+
<Table.ExpandableRow defaultOpen content={row.content} key={row.name}>
|
|
54
60
|
{columns.map(({ key }) => (
|
|
55
61
|
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
56
62
|
))}
|
|
@@ -87,7 +93,7 @@ export const ExpandableSmall = () => {
|
|
|
87
93
|
</Table.Header>
|
|
88
94
|
<Table.Body>
|
|
89
95
|
{data.slice(0, 1).map((row) => (
|
|
90
|
-
<Table.ExpandableRow content={row.content} key={row.name}>
|
|
96
|
+
<Table.ExpandableRow defaultOpen content={row.content} key={row.name}>
|
|
91
97
|
{columns.map(({ key }) => (
|
|
92
98
|
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
93
99
|
))}
|
|
@@ -235,36 +241,6 @@ const data = [
|
|
|
235
241
|
},
|
|
236
242
|
];
|
|
237
243
|
|
|
238
|
-
export const ExpandableOpen = () => {
|
|
239
|
-
return (
|
|
240
|
-
<Table zebraStripes>
|
|
241
|
-
<Table.Header>
|
|
242
|
-
<Table.Row>
|
|
243
|
-
{columns.map(({ key, name }) => (
|
|
244
|
-
<Table.HeaderCell key={key}>{name}</Table.HeaderCell>
|
|
245
|
-
))}
|
|
246
|
-
<Table.HeaderCell />
|
|
247
|
-
</Table.Row>
|
|
248
|
-
</Table.Header>
|
|
249
|
-
<Table.Body>
|
|
250
|
-
{data.map((row) => (
|
|
251
|
-
<Table.ExpandableRow
|
|
252
|
-
expansionDisabled={row.animal === "Sel"}
|
|
253
|
-
content={row.content}
|
|
254
|
-
key={row.name}
|
|
255
|
-
togglePlacement="right"
|
|
256
|
-
defaultOpen
|
|
257
|
-
>
|
|
258
|
-
{columns.map(({ key }) => (
|
|
259
|
-
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
260
|
-
))}
|
|
261
|
-
</Table.ExpandableRow>
|
|
262
|
-
))}
|
|
263
|
-
</Table.Body>
|
|
264
|
-
</Table>
|
|
265
|
-
);
|
|
266
|
-
};
|
|
267
|
-
|
|
268
244
|
export const ClickableRow = () => {
|
|
269
245
|
const [isRowOpen1, setIsRowOpen1] = useState(false);
|
|
270
246
|
const [isRowOpen2, setIsRowOpen2] = useState(false);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import useSWR from "swr";
|
|
3
|
-
import { Loader
|
|
4
|
-
import {
|
|
3
|
+
import { Loader } from "../../loader";
|
|
4
|
+
import { Pagination } from "../../pagination";
|
|
5
|
+
import Table from "../Table";
|
|
6
|
+
import { SortState } from "../types";
|
|
5
7
|
import peopleJson from "./people.json";
|
|
6
8
|
|
|
7
9
|
export default {
|
|
8
10
|
title: "ds-react/Table",
|
|
9
11
|
component: Table,
|
|
10
12
|
parameters: {
|
|
11
|
-
chromatic: {
|
|
13
|
+
chromatic: { disable: true },
|
|
12
14
|
},
|
|
13
15
|
};
|
|
14
16
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { expect, fn, userEvent, within } from "@storybook/test";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import
|
|
3
|
+
import Table from "../../Table";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
title: "ds-react/Table/Tests",
|
|
7
7
|
component: Table,
|
|
8
|
+
parameters: {
|
|
9
|
+
chromatic: { disable: true },
|
|
10
|
+
},
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
export const ClickableRowTest = {
|