@navikt/ds-react 4.12.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_docs.json +101 -127
- package/cjs/date/datepicker/DatePicker.js +1 -1
- package/cjs/date/hooks/useEscape.js +6 -1
- package/cjs/modal/Modal.js +85 -46
- package/cjs/modal/{ModalContent.js → ModalBody.js} +3 -3
- package/cjs/modal/ModalContext.js +8 -0
- package/cjs/modal/ModalFooter.js +46 -0
- package/cjs/modal/ModalHeader.js +56 -0
- package/cjs/modal/ModalUtils.js +40 -0
- package/cjs/modal/dialog-polyfill.js +833 -0
- package/cjs/popover/Popover.js +5 -2
- package/cjs/table/DataCell.js +1 -3
- package/cjs/table/ExpandableRow.js +2 -1
- package/cjs/table/HeaderCell.js +1 -4
- package/cjs/table/Table.js +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +2 -2
- package/esm/date/datepicker/DatePicker.js +1 -1
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/hooks/useEscape.d.ts +2 -1
- package/esm/date/hooks/useEscape.js +6 -1
- package/esm/date/hooks/useEscape.js.map +1 -1
- package/esm/modal/Modal.d.ts +76 -51
- package/esm/modal/Modal.js +87 -48
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalBody.d.ts +6 -0
- package/esm/modal/{ModalContent.js → ModalBody.js} +4 -4
- package/esm/modal/ModalBody.js.map +1 -0
- package/esm/modal/ModalContext.d.ts +6 -0
- package/esm/modal/ModalContext.js +3 -0
- package/esm/modal/ModalContext.js.map +1 -0
- package/esm/modal/ModalFooter.d.ts +6 -0
- package/esm/modal/ModalFooter.js +19 -0
- package/esm/modal/ModalFooter.js.map +1 -0
- package/esm/modal/ModalHeader.d.ts +11 -0
- package/esm/modal/ModalHeader.js +29 -0
- package/esm/modal/ModalHeader.js.map +1 -0
- package/esm/modal/ModalUtils.d.ts +4 -0
- package/esm/modal/ModalUtils.js +33 -0
- package/esm/modal/ModalUtils.js.map +1 -0
- package/esm/modal/dialog-polyfill.d.ts +5 -0
- package/esm/modal/dialog-polyfill.js +832 -0
- package/esm/modal/dialog-polyfill.js.map +1 -0
- package/esm/modal/index.d.ts +3 -1
- package/esm/popover/Popover.js +6 -3
- package/esm/popover/Popover.js.map +1 -1
- package/esm/provider/Provider.d.ts +1 -6
- package/esm/provider/Provider.js.map +1 -1
- package/esm/table/DataCell.js +2 -4
- package/esm/table/DataCell.js.map +1 -1
- package/esm/table/ExpandableRow.js +2 -1
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/HeaderCell.js +1 -4
- package/esm/table/HeaderCell.js.map +1 -1
- package/esm/table/Table.d.ts +2 -3
- package/esm/table/Table.js +1 -1
- package/esm/table/Table.js.map +1 -1
- package/package.json +3 -5
- package/src/date/datepicker/DatePicker.tsx +3 -3
- package/src/date/hooks/useEscape.tsx +8 -3
- package/src/modal/Modal.tsx +171 -121
- package/src/modal/ModalBody.tsx +14 -0
- package/src/modal/ModalContext.ts +6 -0
- package/src/modal/ModalFooter.tsx +14 -0
- package/src/modal/ModalHeader.tsx +42 -0
- package/src/modal/ModalUtils.ts +37 -0
- package/src/modal/dialog-polyfill.ts +980 -0
- package/src/modal/index.ts +3 -1
- package/src/modal/modal.stories.tsx +142 -59
- package/src/popover/Popover.tsx +6 -2
- package/src/provider/Provider.tsx +1 -6
- package/src/table/DataCell.tsx +1 -5
- package/src/table/ExpandableRow.tsx +2 -1
- package/src/table/HeaderCell.tsx +1 -5
- package/src/table/Table.tsx +3 -4
- package/src/table/stories/table-expandable.stories.tsx +37 -1
- package/src/table/stories/table.stories.tsx +4 -1
- package/esm/modal/ModalContent.d.ts +0 -10
- package/esm/modal/ModalContent.js.map +0 -1
- package/src/modal/ModalContent.tsx +0 -26
package/src/modal/index.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { default as Modal, type ModalProps } from "./Modal";
|
|
2
|
-
export { type
|
|
2
|
+
export { type ModalHeaderProps } from "./ModalHeader";
|
|
3
|
+
export { type ModalBodyProps } from "./ModalBody";
|
|
4
|
+
export { type ModalFooterProps } from "./ModalFooter";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
import { FileIcon } from "@navikt/aksel-icons";
|
|
3
3
|
import { BodyLong, Button, Heading } from "..";
|
|
4
4
|
import Modal from "./Modal";
|
|
5
5
|
|
|
@@ -7,78 +7,161 @@ export default {
|
|
|
7
7
|
title: "ds-react/Modal",
|
|
8
8
|
component: Modal,
|
|
9
9
|
parameters: {
|
|
10
|
-
chromatic: {
|
|
10
|
+
chromatic: { pauseAnimationAtEnd: true },
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export const WithUseRef = () => {
|
|
15
|
+
const ref = useRef<HTMLDialogElement>(null);
|
|
16
|
+
const ref2 = useRef<HTMLDialogElement>(null);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<Button onClick={() => ref.current?.showModal()}>Open Modal</Button>
|
|
21
|
+
<Modal
|
|
22
|
+
open={ref.current ? undefined : true /* initially open */}
|
|
23
|
+
ref={ref}
|
|
24
|
+
header={{
|
|
25
|
+
label: "Optional label",
|
|
26
|
+
icon: <FileIcon aria-hidden />,
|
|
27
|
+
heading: "Title",
|
|
28
|
+
size: "small",
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<Modal.Body>
|
|
32
|
+
<BodyLong spacing>
|
|
33
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
34
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
|
|
35
|
+
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
|
36
|
+
aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
37
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
38
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
39
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
40
|
+
</BodyLong>
|
|
21
41
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
</
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
},
|
|
42
|
+
{/* Nested modal */}
|
|
43
|
+
<Modal
|
|
44
|
+
ref={ref2}
|
|
45
|
+
onBeforeClose={() =>
|
|
46
|
+
window.confirm("Are you sure you want to close the modal?")
|
|
47
|
+
}
|
|
48
|
+
aria-labelledby="heading123"
|
|
49
|
+
>
|
|
50
|
+
<Modal.Header>
|
|
51
|
+
<Heading size="medium" level="2" id="heading123">
|
|
52
|
+
Custom header
|
|
53
|
+
</Heading>
|
|
54
|
+
</Modal.Header>
|
|
55
|
+
<Modal.Body>
|
|
56
|
+
Nesting modals is not recommended, but works in most cases.
|
|
57
|
+
</Modal.Body>
|
|
58
|
+
<Modal.Footer>
|
|
59
|
+
<Button onClick={() => ref2.current?.close()}>
|
|
60
|
+
Close w/o confirm
|
|
61
|
+
</Button>
|
|
62
|
+
</Modal.Footer>
|
|
63
|
+
</Modal>
|
|
46
64
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
<BodyLong>
|
|
66
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
67
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
|
|
68
|
+
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
|
69
|
+
aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
70
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
71
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
72
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
73
|
+
</BodyLong>
|
|
74
|
+
</Modal.Body>
|
|
75
|
+
<Modal.Footer>
|
|
76
|
+
<Button>Primary</Button>
|
|
77
|
+
<Button variant="secondary" onClick={() => ref2.current?.showModal()}>
|
|
78
|
+
Secondary
|
|
79
|
+
</Button>
|
|
80
|
+
<Button variant="tertiary">Tertiary</Button>
|
|
81
|
+
</Modal.Footer>
|
|
82
|
+
</Modal>
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
51
85
|
};
|
|
86
|
+
WithUseRef.storyName = "With useRef";
|
|
52
87
|
|
|
53
|
-
export const
|
|
88
|
+
export const WithUseState = () => {
|
|
54
89
|
const [open, setOpen] = useState(true);
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
Modal.setAppElement?.("#root");
|
|
58
|
-
}, []);
|
|
59
|
-
|
|
60
|
-
const parentEl = document.getElementById("custom-container");
|
|
90
|
+
const [open2, setOpen2] = useState(false);
|
|
61
91
|
|
|
62
92
|
return (
|
|
63
|
-
|
|
64
|
-
<div
|
|
65
|
-
|
|
93
|
+
<div style={{ minHeight: "1000px", display: "flex", alignItems: "center" }}>
|
|
94
|
+
<div style={{ display: "flex", gap: "1em" }}>
|
|
95
|
+
<Button variant="secondary">Button</Button>
|
|
96
|
+
<Button onClick={() => setOpen(true)}>Open Modal</Button>
|
|
97
|
+
<Button variant="secondary">Button</Button>
|
|
98
|
+
</div>
|
|
66
99
|
<Modal
|
|
100
|
+
header={{ heading: "Simple header" }}
|
|
67
101
|
open={open}
|
|
68
102
|
onClose={() => setOpen(false)}
|
|
69
|
-
|
|
70
|
-
parentSelector={parentEl ? () => parentEl : undefined}
|
|
103
|
+
width={400}
|
|
71
104
|
>
|
|
72
|
-
<Modal.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
105
|
+
<Modal.Body>
|
|
106
|
+
This modal has width set to 400.
|
|
107
|
+
{/* Nested modal */}
|
|
108
|
+
<Modal
|
|
109
|
+
open={open2}
|
|
110
|
+
onClose={(e) => {
|
|
111
|
+
e.stopPropagation(); // onClose wil propagate to parent modal if not stopped
|
|
112
|
+
setOpen2(false);
|
|
113
|
+
}}
|
|
114
|
+
aria-label="Nested modal"
|
|
115
|
+
width={800}
|
|
116
|
+
>
|
|
117
|
+
<Modal.Body>
|
|
118
|
+
<BodyLong spacing>
|
|
119
|
+
Nesting modals is not recommended, but works in most cases. This
|
|
120
|
+
one does not have header or footer, but is bigger than the
|
|
121
|
+
parent modal.
|
|
122
|
+
</BodyLong>
|
|
123
|
+
<BodyLong spacing>Width is set to 800.</BodyLong>
|
|
124
|
+
<Button onClick={() => setOpen2(false)}>Close</Button>
|
|
125
|
+
</Modal.Body>
|
|
126
|
+
</Modal>
|
|
127
|
+
</Modal.Body>
|
|
128
|
+
<Modal.Footer>
|
|
129
|
+
<Button onClick={() => setOpen2(true)}>Primary</Button>
|
|
130
|
+
<Button variant="secondary" onClick={() => setOpen(false)}>
|
|
131
|
+
Cancel
|
|
132
|
+
</Button>
|
|
133
|
+
</Modal.Footer>
|
|
81
134
|
</Modal>
|
|
82
|
-
|
|
135
|
+
</div>
|
|
83
136
|
);
|
|
84
137
|
};
|
|
138
|
+
WithUseState.storyName = "With useState";
|
|
139
|
+
|
|
140
|
+
export const EmptyHeader = () => (
|
|
141
|
+
<div style={{ minWidth: "800px", minHeight: "600px" } /* For Chromatic */}>
|
|
142
|
+
<Modal open>
|
|
143
|
+
<Modal.Header />
|
|
144
|
+
<Modal.Body>
|
|
145
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
|
146
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
|
|
147
|
+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
|
148
|
+
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
|
|
149
|
+
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
|
150
|
+
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
|
|
151
|
+
mollit anim id est laborum.
|
|
152
|
+
</Modal.Body>
|
|
153
|
+
</Modal>
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
export const Small = () => (
|
|
158
|
+
<Modal open width="small" header={{ heading: "Simple header" }}>
|
|
159
|
+
<Modal.Body>Lorem ipsum dolor sit amet.</Modal.Body>
|
|
160
|
+
</Modal>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
export const Medium = () => (
|
|
164
|
+
<Modal open width="medium" header={{ heading: "Simple header" }}>
|
|
165
|
+
<Modal.Body>Lorem ipsum dolor sit amet.</Modal.Body>
|
|
166
|
+
</Modal>
|
|
167
|
+
);
|
package/src/popover/Popover.tsx
CHANGED
|
@@ -16,10 +16,12 @@ import React, {
|
|
|
16
16
|
useCallback,
|
|
17
17
|
useMemo,
|
|
18
18
|
useRef,
|
|
19
|
+
useContext,
|
|
19
20
|
} from "react";
|
|
20
21
|
import { mergeRefs } from "..";
|
|
21
22
|
import { useClientLayoutEffect, useEventListener } from "../util";
|
|
22
23
|
import PopoverContent, { PopoverContentType } from "./PopoverContent";
|
|
24
|
+
import { ModalContext } from "../modal/ModalContext";
|
|
23
25
|
|
|
24
26
|
export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
|
|
25
27
|
/**
|
|
@@ -117,13 +119,15 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
|
117
119
|
onClose,
|
|
118
120
|
placement = "top",
|
|
119
121
|
offset,
|
|
120
|
-
strategy: userStrategy
|
|
122
|
+
strategy: userStrategy,
|
|
121
123
|
bubbleEscape = false,
|
|
122
124
|
...rest
|
|
123
125
|
},
|
|
124
126
|
ref
|
|
125
127
|
) => {
|
|
126
128
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
129
|
+
const isInModal = useContext(ModalContext) !== null;
|
|
130
|
+
const chosenStrategy = userStrategy ?? (isInModal ? "fixed" : "absolute");
|
|
127
131
|
|
|
128
132
|
const {
|
|
129
133
|
x,
|
|
@@ -135,7 +139,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
|
135
139
|
placement: flPlacement,
|
|
136
140
|
middlewareData: { arrow: { x: arrowX, y: arrowY } = {} },
|
|
137
141
|
} = useFloating({
|
|
138
|
-
strategy:
|
|
142
|
+
strategy: chosenStrategy,
|
|
139
143
|
placement,
|
|
140
144
|
open: open,
|
|
141
145
|
onOpenChange: onClose,
|
|
@@ -2,13 +2,9 @@ import React, { createContext, useContext } from "react";
|
|
|
2
2
|
|
|
3
3
|
export interface ProviderContextType {
|
|
4
4
|
/**
|
|
5
|
-
* Global root-element to attach portals to (
|
|
5
|
+
* Global root-element to attach portals to (Tooltip)
|
|
6
6
|
*/
|
|
7
7
|
rootElement?: HTMLElement;
|
|
8
|
-
/**
|
|
9
|
-
* Global config for appElement (Modal)
|
|
10
|
-
*/
|
|
11
|
-
appElement?: HTMLElement;
|
|
12
8
|
}
|
|
13
9
|
|
|
14
10
|
export const ProviderContext = createContext<ProviderContextType | undefined>(
|
|
@@ -18,7 +14,6 @@ export const ProviderContext = createContext<ProviderContextType | undefined>(
|
|
|
18
14
|
export interface ProviderProps {
|
|
19
15
|
children?: React.ReactNode;
|
|
20
16
|
rootElement?: HTMLElement;
|
|
21
|
-
appElement?: HTMLElement;
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
export const useProvider = () => useContext(ProviderContext);
|
package/src/table/DataCell.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
import cl from "clsx";
|
|
3
3
|
import { BodyShort } from "..";
|
|
4
|
-
import { TableContext } from "./Table";
|
|
5
4
|
|
|
6
5
|
export interface DataCellProps
|
|
7
6
|
extends React.TdHTMLAttributes<HTMLTableCellElement> {
|
|
@@ -19,8 +18,6 @@ export interface DataCellType
|
|
|
19
18
|
|
|
20
19
|
export const DataCell: DataCellType = forwardRef(
|
|
21
20
|
({ className, children = "", align, ...rest }, ref) => {
|
|
22
|
-
const context = useContext(TableContext);
|
|
23
|
-
|
|
24
21
|
return (
|
|
25
22
|
<BodyShort
|
|
26
23
|
as="td"
|
|
@@ -28,7 +25,6 @@ export const DataCell: DataCellType = forwardRef(
|
|
|
28
25
|
className={cl("navds-table__data-cell", className, {
|
|
29
26
|
[`navds-table__data-cell--align-${align}`]: align,
|
|
30
27
|
})}
|
|
31
|
-
size={context?.size}
|
|
32
28
|
{...rest}
|
|
33
29
|
>
|
|
34
30
|
{children}
|
|
@@ -96,6 +96,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
|
|
|
96
96
|
"navds-table__expandable-row--open": isOpen,
|
|
97
97
|
"navds-table__expandable-row--expansion-disabled":
|
|
98
98
|
expansionDisabled,
|
|
99
|
+
"navds-table__expandable-row--clickable": expandOnRowClick,
|
|
99
100
|
})}
|
|
100
101
|
onClick={(e) => {
|
|
101
102
|
!expansionDisabled && expandOnRowClick && onRowClick(e);
|
|
@@ -110,8 +111,8 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
|
|
|
110
111
|
>
|
|
111
112
|
{!expansionDisabled && (
|
|
112
113
|
<button
|
|
113
|
-
type="button"
|
|
114
114
|
className="navds-table__toggle-expand-button"
|
|
115
|
+
type="button"
|
|
115
116
|
aria-controls={id}
|
|
116
117
|
aria-expanded={isOpen}
|
|
117
118
|
onClick={expansionHandler}
|
package/src/table/HeaderCell.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { forwardRef, useContext } from "react";
|
|
2
1
|
import cl from "clsx";
|
|
3
|
-
import {
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
4
3
|
|
|
5
4
|
export interface HeaderCellProps
|
|
6
5
|
extends React.ThHTMLAttributes<HTMLTableCellElement> {
|
|
@@ -19,14 +18,11 @@ export interface HeaderCellType
|
|
|
19
18
|
|
|
20
19
|
export const HeaderCell: HeaderCellType = forwardRef(
|
|
21
20
|
({ className, children, align, ...rest }, ref) => {
|
|
22
|
-
const context = useContext(TableContext);
|
|
23
|
-
|
|
24
21
|
return (
|
|
25
22
|
<th
|
|
26
23
|
ref={ref}
|
|
27
24
|
className={cl("navds-table__header-cell", "navds-label", className, {
|
|
28
25
|
[`navds-table__header-cell--align-${align}`]: align,
|
|
29
|
-
"navds-label--small": context?.size === "small",
|
|
30
26
|
})}
|
|
31
27
|
{...rest}
|
|
32
28
|
>
|
package/src/table/Table.tsx
CHANGED
|
@@ -16,10 +16,10 @@ export interface SortState {
|
|
|
16
16
|
export interface TableProps
|
|
17
17
|
extends React.TableHTMLAttributes<HTMLTableElement> {
|
|
18
18
|
/**
|
|
19
|
-
* Changes padding
|
|
19
|
+
* Changes padding around Cells
|
|
20
20
|
* @default "medium"
|
|
21
21
|
*/
|
|
22
|
-
size?: "medium" | "small";
|
|
22
|
+
size?: "large" | "medium" | "small";
|
|
23
23
|
/**
|
|
24
24
|
* Zebra striped table
|
|
25
25
|
* @default false
|
|
@@ -49,7 +49,6 @@ export interface TableType
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface TableContextProps {
|
|
52
|
-
size: "medium" | "small";
|
|
53
52
|
onSortChange?: (sortKey: string) => void;
|
|
54
53
|
sort?: SortState;
|
|
55
54
|
}
|
|
@@ -100,7 +99,7 @@ export const Table = forwardRef(
|
|
|
100
99
|
},
|
|
101
100
|
ref
|
|
102
101
|
) => (
|
|
103
|
-
<TableContext.Provider value={{
|
|
102
|
+
<TableContext.Provider value={{ onSortChange, sort }}>
|
|
104
103
|
<table
|
|
105
104
|
{...rest}
|
|
106
105
|
ref={ref}
|
|
@@ -36,8 +36,44 @@ export const Expandable = () => {
|
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export const ExpandableLarge = () => {
|
|
40
|
+
const [open, setOpen] = useState(false);
|
|
41
|
+
return (
|
|
42
|
+
<Table size="large">
|
|
43
|
+
<Table.Header>
|
|
44
|
+
<Table.Row>
|
|
45
|
+
<Table.HeaderCell />
|
|
46
|
+
{columns.map(({ key, name }) => (
|
|
47
|
+
<Table.HeaderCell key={key}>{name}</Table.HeaderCell>
|
|
48
|
+
))}
|
|
49
|
+
</Table.Row>
|
|
50
|
+
</Table.Header>
|
|
51
|
+
<Table.Body>
|
|
52
|
+
{data.slice(0, 1).map((data) => (
|
|
53
|
+
<Table.ExpandableRow content={data.content} key={data.name}>
|
|
54
|
+
{columns.map(({ key }) => (
|
|
55
|
+
<Table.DataCell key={key}>{data[key]}</Table.DataCell>
|
|
56
|
+
))}
|
|
57
|
+
</Table.ExpandableRow>
|
|
58
|
+
))}
|
|
59
|
+
{data.slice(1, 2).map((data) => (
|
|
60
|
+
<Table.ExpandableRow
|
|
61
|
+
content={data.content}
|
|
62
|
+
key={data.name}
|
|
63
|
+
open={open}
|
|
64
|
+
onOpenChange={(open) => setOpen(open)}
|
|
65
|
+
>
|
|
66
|
+
{columns.map(({ key }) => (
|
|
67
|
+
<Table.DataCell key={key}>{data[key]}</Table.DataCell>
|
|
68
|
+
))}
|
|
69
|
+
</Table.ExpandableRow>
|
|
70
|
+
))}
|
|
71
|
+
</Table.Body>
|
|
72
|
+
</Table>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
39
76
|
export const ExpandableSmall = () => {
|
|
40
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
41
77
|
const [open, setOpen] = useState(false);
|
|
42
78
|
return (
|
|
43
79
|
<Table size="small">
|
|
@@ -77,7 +77,10 @@ export const NoShadeOnHover = () => <TableComponent shadeOnHover={false} />;
|
|
|
77
77
|
export const ZebraNoShadeOnHover = () => (
|
|
78
78
|
<TableComponent zebraStripes shadeOnHover={false} />
|
|
79
79
|
);
|
|
80
|
-
export const
|
|
80
|
+
export const SizeLarge = () => <TableComponent size="large" />;
|
|
81
|
+
export const SizeMedium = () => <TableComponent size="medium" />;
|
|
82
|
+
export const SizeSmall = () => <TableComponent size="small" />;
|
|
83
|
+
|
|
81
84
|
export const Buttons = () => <TableComponent size="small" button />;
|
|
82
85
|
|
|
83
86
|
export const WithDivs = () => {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface ModalContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
/**
|
|
4
|
-
* Modal.Content content
|
|
5
|
-
*/
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export type ModalContentType = React.ForwardRefExoticComponent<ModalContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
-
declare const ModalContent: ModalContentType;
|
|
10
|
-
export default ModalContent;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContent.js","sourceRoot":"","sources":["../../src/modal/ModalContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AActB,MAAM,YAAY,GAAqB,UAAU,CAC/C,CAAC,EAAsB,EAAE,GAAG,EAAE,EAAE;QAA/B,EAAE,SAAS,OAAW,EAAN,IAAI,cAApB,aAAsB,CAAF;IAAY,OAAA,CAC/B,6CACM,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,sBAAsB,EAAE,SAAS,CAAC,IAChD,CACH,CAAA;CAAA,CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import cl from "clsx";
|
|
3
|
-
|
|
4
|
-
export interface ModalContentProps
|
|
5
|
-
extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
-
/**
|
|
7
|
-
* Modal.Content content
|
|
8
|
-
*/
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type ModalContentType = React.ForwardRefExoticComponent<
|
|
13
|
-
ModalContentProps & React.RefAttributes<HTMLDivElement>
|
|
14
|
-
>;
|
|
15
|
-
|
|
16
|
-
const ModalContent: ModalContentType = forwardRef(
|
|
17
|
-
({ className, ...rest }, ref) => (
|
|
18
|
-
<div
|
|
19
|
-
{...rest}
|
|
20
|
-
ref={ref}
|
|
21
|
-
className={cl("navds-modal__content", className)}
|
|
22
|
-
/>
|
|
23
|
-
)
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export default ModalContent;
|