@navikt/ds-react 5.7.2 → 5.7.3
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 +4 -4
- package/cjs/date/datepicker/DatePicker.js +6 -6
- package/cjs/date/datepicker/DatePickerStandalone.js +4 -4
- package/cjs/date/hooks/useDatepicker.js +5 -4
- package/cjs/date/hooks/useMonthPicker.js +4 -3
- package/cjs/date/hooks/useRangeDatepicker.js +1 -1
- package/cjs/date/monthpicker/MonthCaption.js +7 -7
- package/cjs/date/utils/navigation.js +6 -6
- package/cjs/form/Select.js +1 -1
- package/cjs/form/TextField.js +1 -1
- package/cjs/form/Textarea.js +1 -1
- package/cjs/form/combobox/Input/Input.js +1 -1
- package/cjs/form/combobox/Input/inputContext.js +4 -4
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +3 -3
- package/cjs/form/search/Search.js +1 -1
- package/cjs/help-text/HelpText.js +1 -1
- package/cjs/help-text/HelpTextIcon.js +1 -1
- package/cjs/table/ExpandableRow.js +2 -2
- package/cjs/tabs/TabList.js +3 -3
- package/cjs/timeline/Timeline.js +6 -6
- package/cjs/timeline/hooks/useTimelineRows.js +1 -2
- package/cjs/util/omit.js +1 -1
- package/esm/date/datepicker/DatePicker.js +6 -6
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.js +4 -4
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/hooks/useDatepicker.js +5 -4
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.js +4 -3
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.js +3 -3
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/monthpicker/MonthCaption.js +7 -7
- package/esm/date/monthpicker/MonthCaption.js.map +1 -1
- package/esm/date/utils/navigation.js +6 -6
- package/esm/date/utils/navigation.js.map +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/TextField.js +1 -1
- package/esm/form/TextField.js.map +1 -1
- package/esm/form/Textarea.js +1 -1
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/Input/inputContext.js +4 -4
- package/esm/form/combobox/Input/inputContext.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +3 -3
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/help-text/HelpText.js +1 -1
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/help-text/HelpTextIcon.js +1 -1
- package/esm/help-text/HelpTextIcon.js.map +1 -1
- package/esm/layout/utilities/css.d.ts +1 -1
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/table/ExpandableRow.js +2 -2
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/tabs/TabList.js +3 -3
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/timeline/Timeline.d.ts +2 -2
- package/esm/timeline/Timeline.js +6 -6
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/timeline/hooks/useTimelineRows.js +1 -2
- package/esm/timeline/hooks/useTimelineRows.js.map +1 -1
- package/esm/util/omit.js +1 -1
- package/esm/util/omit.js.map +1 -1
- package/package.json +3 -3
- package/src/chips/chips.stories.tsx +13 -15
- package/src/date/datepicker/DatePicker.tsx +6 -6
- package/src/date/datepicker/DatePickerStandalone.tsx +4 -4
- package/src/date/hooks/useDatepicker.tsx +5 -4
- package/src/date/hooks/useMonthPicker.tsx +4 -3
- package/src/date/hooks/useRangeDatepicker.tsx +3 -3
- package/src/date/monthpicker/MonthCaption.tsx +9 -9
- package/src/date/utils/__tests__/get-month-weeks.test.ts +10 -7
- package/src/date/utils/navigation.ts +6 -6
- package/src/form/Select.tsx +1 -1
- package/src/form/TextField.tsx +1 -1
- package/src/form/Textarea.tsx +1 -1
- package/src/form/combobox/Input/Input.tsx +1 -1
- package/src/form/combobox/Input/inputContext.tsx +4 -4
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +5 -5
- package/src/form/search/Search.tsx +1 -1
- package/src/form/stories/textarea.stories.tsx +21 -37
- package/src/help-text/HelpText.tsx +1 -0
- package/src/help-text/HelpTextIcon.tsx +1 -1
- package/src/layout/utilities/css.ts +1 -0
- package/src/table/ExpandableRow.tsx +2 -2
- package/src/table/stories/table-async.stories.tsx +4 -4
- package/src/table/stories/table-expandable.stories.tsx +26 -26
- package/src/table/stories/table.stories.tsx +4 -4
- package/src/tabs/TabList.tsx +4 -4
- package/src/timeline/Timeline.tsx +8 -8
- package/src/timeline/hooks/useTimelineRows.ts +1 -2
- package/src/util/omit.ts +2 -2
|
@@ -1,52 +1,36 @@
|
|
|
1
|
-
import { Meta } from "@storybook/react";
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Textarea } from "../index";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Textarea> = {
|
|
5
6
|
title: "ds-react/Textarea",
|
|
6
7
|
component: Textarea,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
control: {
|
|
10
|
-
type: "radio",
|
|
11
|
-
options: ["medium", "small"],
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
description: {
|
|
15
|
-
type: "string",
|
|
16
|
-
},
|
|
17
|
-
error: {
|
|
18
|
-
type: "string",
|
|
19
|
-
},
|
|
20
|
-
hideLabel: {
|
|
21
|
-
type: "boolean",
|
|
22
|
-
},
|
|
23
|
-
disabled: {
|
|
24
|
-
type: "boolean",
|
|
25
|
-
},
|
|
26
|
-
maxRows: {
|
|
27
|
-
type: "number",
|
|
28
|
-
},
|
|
29
|
-
minRows: {
|
|
30
|
-
type: "number",
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
} as Meta;
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
34
10
|
|
|
35
|
-
export const Default = {
|
|
11
|
+
export const Default: StoryObj<typeof Textarea> = {
|
|
36
12
|
render: (props) => {
|
|
37
|
-
return
|
|
38
|
-
<Textarea
|
|
39
|
-
{...props}
|
|
40
|
-
maxLength={props?.maxLength ?? 100}
|
|
41
|
-
label="Ipsum enim quis culpa"
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
13
|
+
return <Textarea {...props} />;
|
|
44
14
|
},
|
|
45
15
|
|
|
46
16
|
args: {
|
|
47
17
|
maxLength: 100,
|
|
18
|
+
label: "Ipsum enim quis culpa",
|
|
48
19
|
resize: false,
|
|
49
20
|
},
|
|
21
|
+
|
|
22
|
+
argTypes: {
|
|
23
|
+
size: {
|
|
24
|
+
control: { type: "radio" },
|
|
25
|
+
options: ["medium", "small"],
|
|
26
|
+
},
|
|
27
|
+
description: { type: "string" },
|
|
28
|
+
error: { type: "string" },
|
|
29
|
+
hideLabel: { type: "boolean" },
|
|
30
|
+
disabled: { type: "boolean" },
|
|
31
|
+
maxRows: { type: "number" },
|
|
32
|
+
minRows: { type: "number" },
|
|
33
|
+
},
|
|
50
34
|
};
|
|
51
35
|
|
|
52
36
|
export const Small = () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { ChevronDownIcon } from "@navikt/aksel-icons";
|
|
1
2
|
import cl from "clsx";
|
|
2
3
|
import React, { forwardRef, useState } from "react";
|
|
3
4
|
import { useId } from "../util";
|
|
4
5
|
import AnimateHeight from "../util/AnimateHeight";
|
|
5
6
|
import DataCell from "./DataCell";
|
|
6
7
|
import Row, { RowProps } from "./Row";
|
|
7
|
-
import { ChevronDownIcon } from "@navikt/aksel-icons";
|
|
8
8
|
|
|
9
9
|
export interface ExpandableRowProps extends Omit<RowProps, "content"> {
|
|
10
10
|
/**
|
|
@@ -76,7 +76,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
|
|
|
76
76
|
const expansionHandler = (e) => {
|
|
77
77
|
onOpenChange?.(!isOpen);
|
|
78
78
|
if (open === undefined) {
|
|
79
|
-
setInternalOpen((
|
|
79
|
+
setInternalOpen((oldOpen) => !oldOpen);
|
|
80
80
|
}
|
|
81
81
|
e.stopPropagation();
|
|
82
82
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import useSWR from "swr";
|
|
3
|
-
import people from "./people.json";
|
|
4
|
-
import { Table } from "../index";
|
|
5
3
|
import { Loader, Pagination, SortState } from "../..";
|
|
4
|
+
import { Table } from "../index";
|
|
5
|
+
import peopleJson from "./people.json";
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
title: "ds-react/Table",
|
|
@@ -44,8 +44,8 @@ const updateData = async (url: string) => {
|
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
return {
|
|
47
|
-
count:
|
|
48
|
-
results:
|
|
47
|
+
count: peopleJson.length,
|
|
48
|
+
results: peopleJson
|
|
49
49
|
.slice()
|
|
50
50
|
.sort((a, b) => {
|
|
51
51
|
if (sort) {
|
|
@@ -19,15 +19,15 @@ export const Expandable = () => {
|
|
|
19
19
|
</Table.Row>
|
|
20
20
|
</Table.Header>
|
|
21
21
|
<Table.Body>
|
|
22
|
-
{data.map((
|
|
22
|
+
{data.map((row) => (
|
|
23
23
|
<Table.ExpandableRow
|
|
24
|
-
expansionDisabled={
|
|
25
|
-
content={
|
|
26
|
-
key={
|
|
24
|
+
expansionDisabled={row.animal === "Sel"}
|
|
25
|
+
content={row.content}
|
|
26
|
+
key={row.name}
|
|
27
27
|
togglePlacement="right"
|
|
28
28
|
>
|
|
29
29
|
{columns.map(({ key }) => (
|
|
30
|
-
<Table.DataCell key={key}>{
|
|
30
|
+
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
31
31
|
))}
|
|
32
32
|
</Table.ExpandableRow>
|
|
33
33
|
))}
|
|
@@ -49,22 +49,22 @@ export const ExpandableLarge = () => {
|
|
|
49
49
|
</Table.Row>
|
|
50
50
|
</Table.Header>
|
|
51
51
|
<Table.Body>
|
|
52
|
-
{data.slice(0, 1).map((
|
|
53
|
-
<Table.ExpandableRow content={
|
|
52
|
+
{data.slice(0, 1).map((row) => (
|
|
53
|
+
<Table.ExpandableRow content={row.content} key={row.name}>
|
|
54
54
|
{columns.map(({ key }) => (
|
|
55
|
-
<Table.DataCell key={key}>{
|
|
55
|
+
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
56
56
|
))}
|
|
57
57
|
</Table.ExpandableRow>
|
|
58
58
|
))}
|
|
59
|
-
{data.slice(1, 2).map((
|
|
59
|
+
{data.slice(1, 2).map((row) => (
|
|
60
60
|
<Table.ExpandableRow
|
|
61
|
-
content={
|
|
62
|
-
key={
|
|
61
|
+
content={row.content}
|
|
62
|
+
key={row.name}
|
|
63
63
|
open={open}
|
|
64
|
-
onOpenChange={
|
|
64
|
+
onOpenChange={setOpen}
|
|
65
65
|
>
|
|
66
66
|
{columns.map(({ key }) => (
|
|
67
|
-
<Table.DataCell key={key}>{
|
|
67
|
+
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
68
68
|
))}
|
|
69
69
|
</Table.ExpandableRow>
|
|
70
70
|
))}
|
|
@@ -86,22 +86,22 @@ export const ExpandableSmall = () => {
|
|
|
86
86
|
</Table.Row>
|
|
87
87
|
</Table.Header>
|
|
88
88
|
<Table.Body>
|
|
89
|
-
{data.slice(0, 1).map((
|
|
90
|
-
<Table.ExpandableRow content={
|
|
89
|
+
{data.slice(0, 1).map((row) => (
|
|
90
|
+
<Table.ExpandableRow content={row.content} key={row.name}>
|
|
91
91
|
{columns.map(({ key }) => (
|
|
92
|
-
<Table.DataCell key={key}>{
|
|
92
|
+
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
93
93
|
))}
|
|
94
94
|
</Table.ExpandableRow>
|
|
95
95
|
))}
|
|
96
|
-
{data.slice(1, 2).map((
|
|
96
|
+
{data.slice(1, 2).map((row) => (
|
|
97
97
|
<Table.ExpandableRow
|
|
98
|
-
content={
|
|
99
|
-
key={
|
|
98
|
+
content={row.content}
|
|
99
|
+
key={row.name}
|
|
100
100
|
open={open}
|
|
101
|
-
onOpenChange={
|
|
101
|
+
onOpenChange={setOpen}
|
|
102
102
|
>
|
|
103
103
|
{columns.map(({ key }) => (
|
|
104
|
-
<Table.DataCell key={key}>{
|
|
104
|
+
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
105
105
|
))}
|
|
106
106
|
</Table.ExpandableRow>
|
|
107
107
|
))}
|
|
@@ -247,16 +247,16 @@ export const ExpandableOpen = () => {
|
|
|
247
247
|
</Table.Row>
|
|
248
248
|
</Table.Header>
|
|
249
249
|
<Table.Body>
|
|
250
|
-
{data.map((
|
|
250
|
+
{data.map((row) => (
|
|
251
251
|
<Table.ExpandableRow
|
|
252
|
-
expansionDisabled={
|
|
253
|
-
content={
|
|
254
|
-
key={
|
|
252
|
+
expansionDisabled={row.animal === "Sel"}
|
|
253
|
+
content={row.content}
|
|
254
|
+
key={row.name}
|
|
255
255
|
togglePlacement="right"
|
|
256
256
|
defaultOpen
|
|
257
257
|
>
|
|
258
258
|
{columns.map(({ key }) => (
|
|
259
|
-
<Table.DataCell key={key}>{
|
|
259
|
+
<Table.DataCell key={key}>{row[key]}</Table.DataCell>
|
|
260
260
|
))}
|
|
261
261
|
</Table.ExpandableRow>
|
|
262
262
|
))}
|
|
@@ -161,10 +161,10 @@ const SelectionTable = ({ size = "medium" }: { size?: "small" | "medium" }) => {
|
|
|
161
161
|
return [
|
|
162
162
|
list,
|
|
163
163
|
(value) =>
|
|
164
|
-
setList((
|
|
165
|
-
|
|
166
|
-
?
|
|
167
|
-
: [...
|
|
164
|
+
setList((oldList) =>
|
|
165
|
+
oldList.includes(value)
|
|
166
|
+
? oldList.filter((id) => id !== value)
|
|
167
|
+
: [...oldList, value]
|
|
168
168
|
),
|
|
169
169
|
];
|
|
170
170
|
};
|
package/src/tabs/TabList.tsx
CHANGED
|
@@ -39,10 +39,10 @@ export const TabList = forwardRef<HTMLDivElement, TabListProps>(
|
|
|
39
39
|
const showStartScroll = scrollLeft > 1;
|
|
40
40
|
const showEndScroll = scrollLeft < scrollWidth - clientWidth - 1;
|
|
41
41
|
|
|
42
|
-
setDisplayScroll((
|
|
43
|
-
showStartScroll ===
|
|
44
|
-
showEndScroll ===
|
|
45
|
-
?
|
|
42
|
+
setDisplayScroll((oldDisplayScroll) =>
|
|
43
|
+
showStartScroll === oldDisplayScroll.start &&
|
|
44
|
+
showEndScroll === oldDisplayScroll.end
|
|
45
|
+
? oldDisplayScroll
|
|
46
46
|
: { start: showStartScroll, end: showEndScroll }
|
|
47
47
|
);
|
|
48
48
|
}),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { endOfDay, isSameDay, startOfDay } from "date-fns";
|
|
2
2
|
import React, { forwardRef, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { AxisLabels } from "./AxisLabels";
|
|
4
|
+
import Pin, { PinType } from "./Pin";
|
|
5
|
+
import TimelineRow, { TimelineRowType } from "./TimelineRow";
|
|
4
6
|
import { RowContext } from "./hooks/useRowContext";
|
|
5
7
|
import { TimelineContext } from "./hooks/useTimelineContext";
|
|
6
8
|
import {
|
|
@@ -9,11 +11,9 @@ import {
|
|
|
9
11
|
useTimelineRows,
|
|
10
12
|
} from "./hooks/useTimelineRows";
|
|
11
13
|
import Period, { PeriodType } from "./period";
|
|
12
|
-
import Pin, { PinType } from "./Pin";
|
|
13
|
-
import TimelineRow, { TimelineRowType } from "./TimelineRow";
|
|
14
14
|
import { parseRows } from "./utils/timeline";
|
|
15
|
-
import Zoom, { ZoomType } from "./zoom";
|
|
16
15
|
import { AxisLabelTemplates } from "./utils/types.external";
|
|
16
|
+
import Zoom, { ZoomType } from "./zoom";
|
|
17
17
|
|
|
18
18
|
export interface TimelineProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
19
19
|
children: React.ReactNode;
|
|
@@ -187,10 +187,10 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
const addFocusable = (
|
|
190
|
+
const addFocusable = (btnRef: HTMLButtonElement | null, id: number) => {
|
|
191
191
|
let items = firstFocusabled.current;
|
|
192
192
|
items = items.filter((x) => x.id !== id);
|
|
193
|
-
items.push({ ref, id });
|
|
193
|
+
items.push({ ref: btnRef, id });
|
|
194
194
|
firstFocusabled.current = items;
|
|
195
195
|
};
|
|
196
196
|
|
|
@@ -212,8 +212,8 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
|
|
|
212
212
|
<div className="navds-timeline">
|
|
213
213
|
<AxisLabels templates={axisLabelTemplates} />
|
|
214
214
|
|
|
215
|
-
{pins.map((
|
|
216
|
-
<
|
|
215
|
+
{pins.map((PinChild, i) => (
|
|
216
|
+
<PinChild key={`pin-${i}`} />
|
|
217
217
|
))}
|
|
218
218
|
|
|
219
219
|
{processedRows.map((row, i) => {
|
|
@@ -238,7 +238,7 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
|
|
|
238
238
|
);
|
|
239
239
|
})}
|
|
240
240
|
</div>
|
|
241
|
-
{zoomComponent
|
|
241
|
+
{zoomComponent}
|
|
242
242
|
</div>
|
|
243
243
|
</TimelineContext.Provider>
|
|
244
244
|
);
|
|
@@ -101,8 +101,7 @@ export const useTimelineRows = (
|
|
|
101
101
|
): InternalSimpleTimeline[] =>
|
|
102
102
|
useMemo(
|
|
103
103
|
() =>
|
|
104
|
-
rows.map((periods: InternalSimpleTimeline,
|
|
105
|
-
const rowIndex = i;
|
|
104
|
+
rows.map((periods: InternalSimpleTimeline, rowIndex: number) => {
|
|
106
105
|
const timelinePeriods = periods.periods
|
|
107
106
|
.sort((a: Period, b: Period) => a.start.valueOf() - b.start.valueOf())
|
|
108
107
|
.map((period: Period & { restProps?: any; ref?: any }, i) => ({
|
package/src/util/omit.ts
CHANGED