@navikt/ds-react 3.4.1 → 4.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 +5615 -3780
- package/cjs/date/hooks/index.js +4 -4
- package/cjs/date/index.js +6 -6
- package/cjs/dropdown/Dropdown.js +57 -0
- package/cjs/dropdown/Menu/Divider.js +47 -0
- package/cjs/dropdown/Menu/GroupedList/Heading.js +47 -0
- package/cjs/dropdown/Menu/GroupedList/Item.js +54 -0
- package/cjs/dropdown/Menu/GroupedList/index.js +51 -0
- package/cjs/dropdown/Menu/GroupedList/package.json +6 -0
- package/cjs/dropdown/Menu/List/Item.js +54 -0
- package/cjs/dropdown/Menu/List/index.js +49 -0
- package/cjs/dropdown/Menu/List/package.json +6 -0
- package/cjs/dropdown/Menu/index.js +64 -0
- package/cjs/dropdown/Menu/package.json +6 -0
- package/cjs/dropdown/Toggle.js +66 -0
- package/cjs/dropdown/index.js +23 -0
- package/cjs/dropdown/package.json +6 -0
- package/cjs/form/radio/RadioGroup.js +10 -0
- package/cjs/index.js +3 -0
- package/cjs/internal-header/InternalHeader.js +55 -0
- package/cjs/internal-header/InternalHeaderButton.js +47 -0
- package/cjs/internal-header/InternalHeaderTitle.js +48 -0
- package/cjs/internal-header/InternalHeaderUser.js +51 -0
- package/cjs/internal-header/InternalHeaderUserButton.js +54 -0
- package/cjs/internal-header/index.js +8 -0
- package/cjs/internal-header/package.json +6 -0
- package/cjs/read-more/ReadMore.js +17 -0
- package/cjs/timeline/AxisLabels.js +90 -0
- package/cjs/timeline/Pin.js +106 -0
- package/cjs/timeline/Timeline.js +162 -0
- package/cjs/timeline/TimelineRow.js +86 -0
- package/cjs/timeline/hooks/usePeriodContext.js +16 -0
- package/cjs/timeline/hooks/useRowContext.js +18 -0
- package/cjs/timeline/hooks/useTimelineContext.js +23 -0
- package/cjs/timeline/hooks/useTimelineRows.js +79 -0
- package/cjs/timeline/index.js +8 -0
- package/cjs/timeline/package.json +6 -0
- package/cjs/timeline/period/ClickablePeriod.js +120 -0
- package/cjs/timeline/period/NonClickablePeriod.js +18 -0
- package/cjs/timeline/period/index.js +46 -0
- package/cjs/timeline/period/package.json +6 -0
- package/cjs/timeline/utils/calc.js +19 -0
- package/cjs/timeline/utils/filter.js +18 -0
- package/cjs/timeline/utils/index.js +7 -0
- package/cjs/timeline/utils/package.json +6 -0
- package/cjs/timeline/utils/period.js +40 -0
- package/cjs/timeline/utils/sort.js +10 -0
- package/cjs/timeline/utils/timeline.js +79 -0
- package/cjs/timeline/utils/types.external.js +2 -0
- package/cjs/timeline/utils/types.internal.js +2 -0
- package/cjs/timeline/zoom/ZoomButton.js +68 -0
- package/cjs/timeline/zoom/index.js +50 -0
- package/cjs/timeline/zoom/package.json +6 -0
- package/esm/date/hooks/index.d.ts +3 -3
- package/esm/date/hooks/index.js +3 -3
- package/esm/date/hooks/index.js.map +1 -1
- package/esm/date/index.d.ts +3 -3
- package/esm/date/index.js +3 -3
- package/esm/date/index.js.map +1 -1
- package/esm/dropdown/Dropdown.d.ts +37 -0
- package/esm/dropdown/Dropdown.js +29 -0
- package/esm/dropdown/Dropdown.js.map +1 -0
- package/esm/dropdown/Menu/Divider.d.ts +4 -0
- package/esm/dropdown/Menu/Divider.js +19 -0
- package/esm/dropdown/Menu/Divider.js.map +1 -0
- package/esm/dropdown/Menu/GroupedList/Heading.d.ts +10 -0
- package/esm/dropdown/Menu/GroupedList/Heading.js +19 -0
- package/esm/dropdown/Menu/GroupedList/Heading.js.map +1 -0
- package/esm/dropdown/Menu/GroupedList/Item.d.ts +11 -0
- package/esm/dropdown/Menu/GroupedList/Item.js +26 -0
- package/esm/dropdown/Menu/GroupedList/Item.js.map +1 -0
- package/esm/dropdown/Menu/GroupedList/index.d.ts +15 -0
- package/esm/dropdown/Menu/GroupedList/index.js +23 -0
- package/esm/dropdown/Menu/GroupedList/index.js.map +1 -0
- package/esm/dropdown/Menu/List/Item.d.ts +11 -0
- package/esm/dropdown/Menu/List/Item.js +26 -0
- package/esm/dropdown/Menu/List/Item.js.map +1 -0
- package/esm/dropdown/Menu/List/index.d.ts +13 -0
- package/esm/dropdown/Menu/List/index.js +21 -0
- package/esm/dropdown/Menu/List/index.js.map +1 -0
- package/esm/dropdown/Menu/index.d.ts +27 -0
- package/esm/dropdown/Menu/index.js +36 -0
- package/esm/dropdown/Menu/index.js.map +1 -0
- package/esm/dropdown/Toggle.d.ts +10 -0
- package/esm/dropdown/Toggle.js +38 -0
- package/esm/dropdown/Toggle.js.map +1 -0
- package/esm/dropdown/index.d.ts +2 -0
- package/esm/dropdown/index.js +3 -0
- package/esm/dropdown/index.js.map +1 -0
- package/esm/form/radio/RadioGroup.d.ts +10 -0
- package/esm/form/radio/RadioGroup.js +10 -0
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/index.d.ts +3 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -1
- package/esm/internal-header/InternalHeader.d.ts +16 -0
- package/esm/internal-header/InternalHeader.js +27 -0
- package/esm/internal-header/InternalHeader.js.map +1 -0
- package/esm/internal-header/InternalHeaderButton.d.ts +11 -0
- package/esm/internal-header/InternalHeaderButton.js +19 -0
- package/esm/internal-header/InternalHeaderButton.js.map +1 -0
- package/esm/internal-header/InternalHeaderTitle.d.ts +11 -0
- package/esm/internal-header/InternalHeaderTitle.js +20 -0
- package/esm/internal-header/InternalHeaderTitle.js.map +1 -0
- package/esm/internal-header/InternalHeaderUser.d.ts +14 -0
- package/esm/internal-header/InternalHeaderUser.js +23 -0
- package/esm/internal-header/InternalHeaderUser.js.map +1 -0
- package/esm/internal-header/InternalHeaderUserButton.d.ts +15 -0
- package/esm/internal-header/InternalHeaderUserButton.js +26 -0
- package/esm/internal-header/InternalHeaderUserButton.js.map +1 -0
- package/esm/internal-header/index.d.ts +5 -0
- package/esm/internal-header/index.js +2 -0
- package/esm/internal-header/index.js.map +1 -0
- package/esm/read-more/ReadMore.d.ts +17 -0
- package/esm/read-more/ReadMore.js +17 -0
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/timeline/AxisLabels.d.ts +6 -0
- package/esm/timeline/AxisLabels.js +81 -0
- package/esm/timeline/AxisLabels.js.map +1 -0
- package/esm/timeline/Pin.d.ts +17 -0
- package/esm/timeline/Pin.js +81 -0
- package/esm/timeline/Pin.js.map +1 -0
- package/esm/timeline/Timeline.d.ts +45 -0
- package/esm/timeline/Timeline.js +134 -0
- package/esm/timeline/Timeline.js.map +1 -0
- package/esm/timeline/TimelineRow.d.ts +22 -0
- package/esm/timeline/TimelineRow.js +58 -0
- package/esm/timeline/TimelineRow.js.map +1 -0
- package/esm/timeline/hooks/usePeriodContext.d.ts +9 -0
- package/esm/timeline/hooks/usePeriodContext.js +13 -0
- package/esm/timeline/hooks/usePeriodContext.js.map +1 -0
- package/esm/timeline/hooks/useRowContext.d.ts +11 -0
- package/esm/timeline/hooks/useRowContext.js +15 -0
- package/esm/timeline/hooks/useRowContext.js.map +1 -0
- package/esm/timeline/hooks/useTimelineContext.d.ts +15 -0
- package/esm/timeline/hooks/useTimelineContext.js +20 -0
- package/esm/timeline/hooks/useTimelineContext.js.map +1 -0
- package/esm/timeline/hooks/useTimelineRows.d.ts +4 -0
- package/esm/timeline/hooks/useTimelineRows.js +74 -0
- package/esm/timeline/hooks/useTimelineRows.js.map +1 -0
- package/esm/timeline/index.d.ts +6 -0
- package/esm/timeline/index.js +2 -0
- package/esm/timeline/index.js.map +1 -0
- package/esm/timeline/period/ClickablePeriod.d.ts +9 -0
- package/esm/timeline/period/ClickablePeriod.js +93 -0
- package/esm/timeline/period/ClickablePeriod.js.map +1 -0
- package/esm/timeline/period/NonClickablePeriod.d.ts +7 -0
- package/esm/timeline/period/NonClickablePeriod.js +14 -0
- package/esm/timeline/period/NonClickablePeriod.js.map +1 -0
- package/esm/timeline/period/index.d.ts +57 -0
- package/esm/timeline/period/index.js +18 -0
- package/esm/timeline/period/index.js.map +1 -0
- package/esm/timeline/utils/calc.d.ts +5 -0
- package/esm/timeline/utils/calc.js +15 -0
- package/esm/timeline/utils/calc.js.map +1 -0
- package/esm/timeline/utils/filter.d.ts +10 -0
- package/esm/timeline/utils/filter.js +11 -0
- package/esm/timeline/utils/filter.js.map +1 -0
- package/esm/timeline/utils/index.d.ts +1 -0
- package/esm/timeline/utils/index.js +2 -0
- package/esm/timeline/utils/index.js.map +1 -0
- package/esm/timeline/utils/period.d.ts +2 -0
- package/esm/timeline/utils/period.js +33 -0
- package/esm/timeline/utils/period.js.map +1 -0
- package/esm/timeline/utils/sort.d.ts +4 -0
- package/esm/timeline/utils/sort.js +5 -0
- package/esm/timeline/utils/sort.js.map +1 -0
- package/esm/timeline/utils/timeline.d.ts +12 -0
- package/esm/timeline/utils/timeline.js +73 -0
- package/esm/timeline/utils/timeline.js.map +1 -0
- package/esm/timeline/utils/types.external.d.ts +53 -0
- package/esm/timeline/utils/types.external.js +2 -0
- package/esm/timeline/utils/types.external.js.map +1 -0
- package/esm/timeline/utils/types.internal.d.ts +61 -0
- package/esm/timeline/utils/types.internal.js +2 -0
- package/esm/timeline/utils/types.internal.js.map +1 -0
- package/esm/timeline/zoom/ZoomButton.d.ts +19 -0
- package/esm/timeline/zoom/ZoomButton.js +43 -0
- package/esm/timeline/zoom/ZoomButton.js.map +1 -0
- package/esm/timeline/zoom/index.d.ts +11 -0
- package/esm/timeline/zoom/index.js +22 -0
- package/esm/timeline/zoom/index.js.map +1 -0
- package/package.json +2 -2
- package/src/date/datepicker/datepicker.stories.tsx +19 -21
- package/src/date/datepicker/datepicker.test.tsx +5 -5
- package/src/date/hooks/index.ts +3 -3
- package/src/date/hooks/useRangeDatepicker.test.tsx +6 -6
- package/src/date/index.ts +5 -5
- package/src/date/monthpicker/monthpicker.stories.tsx +5 -5
- package/src/date/utils/__tests__/get-dates.test.ts +0 -1
- package/src/dropdown/Dropdown.tsx +80 -0
- package/src/dropdown/Menu/Divider.tsx +18 -0
- package/src/dropdown/Menu/GroupedList/Heading.tsx +31 -0
- package/src/dropdown/Menu/GroupedList/Item.tsx +45 -0
- package/src/dropdown/Menu/GroupedList/index.tsx +33 -0
- package/src/dropdown/Menu/List/Item.tsx +44 -0
- package/src/dropdown/Menu/List/index.tsx +27 -0
- package/src/dropdown/Menu/index.tsx +85 -0
- package/src/dropdown/Toggle.tsx +52 -0
- package/src/dropdown/dropdown.stories.tsx +91 -0
- package/src/dropdown/index.ts +2 -0
- package/src/form/radio/RadioGroup.tsx +10 -0
- package/src/index.ts +3 -0
- package/src/internal-header/InternalHeader.tsx +44 -0
- package/src/internal-header/InternalHeaderButton.tsx +28 -0
- package/src/internal-header/InternalHeaderTitle.tsx +35 -0
- package/src/internal-header/InternalHeaderUser.tsx +39 -0
- package/src/internal-header/InternalHeaderUserButton.tsx +43 -0
- package/src/internal-header/header.stories.tsx +225 -0
- package/src/internal-header/index.ts +8 -0
- package/src/read-more/ReadMore.tsx +17 -0
- package/src/timeline/AxisLabels.tsx +143 -0
- package/src/timeline/Pin.tsx +169 -0
- package/src/timeline/Timeline.tsx +219 -0
- package/src/timeline/TimelineRow.tsx +122 -0
- package/src/timeline/hooks/usePeriodContext.tsx +22 -0
- package/src/timeline/hooks/useRowContext.tsx +26 -0
- package/src/timeline/hooks/useTimelineContext.tsx +37 -0
- package/src/timeline/hooks/useTimelineRows.ts +161 -0
- package/src/timeline/index.ts +6 -0
- package/src/timeline/period/ClickablePeriod.tsx +193 -0
- package/src/timeline/period/NonClickablePeriod.tsx +46 -0
- package/src/timeline/period/index.tsx +130 -0
- package/src/timeline/timeline.stories.tsx +444 -0
- package/src/timeline/utils/calc.ts +26 -0
- package/src/timeline/utils/filter.ts +32 -0
- package/src/timeline/utils/index.ts +6 -0
- package/src/timeline/utils/period.ts +48 -0
- package/src/timeline/utils/sort.ts +11 -0
- package/src/timeline/utils/timeline.ts +83 -0
- package/src/timeline/utils/types.external.ts +67 -0
- package/src/timeline/utils/types.internal.ts +76 -0
- package/src/timeline/zoom/ZoomButton.tsx +83 -0
- package/src/timeline/zoom/index.tsx +30 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ariaLabel, getConditionalClasses } from "../utils/period";
|
|
3
|
+
import cl from "clsx";
|
|
4
|
+
const NonClickablePeriod = ({ start, end, status, cropped, direction, left, width, icon, statusLabel, restProps, periodRef, }) => {
|
|
5
|
+
return (React.createElement("div", Object.assign({ ref: periodRef }, restProps, { className: cl(getConditionalClasses(cropped, direction, status), restProps === null || restProps === void 0 ? void 0 : restProps.classname), style: {
|
|
6
|
+
width: `${width}%`,
|
|
7
|
+
[direction]: `${left}%`,
|
|
8
|
+
} }),
|
|
9
|
+
React.createElement("span", { className: "navds-timeline__period--inner" },
|
|
10
|
+
icon,
|
|
11
|
+
React.createElement("span", { className: "sr-only" }, ariaLabel(start, end, status, statusLabel)))));
|
|
12
|
+
};
|
|
13
|
+
export default NonClickablePeriod;
|
|
14
|
+
//# sourceMappingURL=NonClickablePeriod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NonClickablePeriod.js","sourceRoot":"","sources":["../../../src/timeline/period/NonClickablePeriod.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,MAAM,MAAM,CAAC;AAMtB,MAAM,kBAAkB,GAAG,CAAC,EAC1B,KAAK,EACL,GAAG,EACH,MAAM,EACN,OAAO,EACP,SAAS,EACT,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,WAAW,EACX,SAAS,EACT,SAAS,GACuB,EAAE,EAAE;IACpC,OAAO,CACL,2CACE,GAAG,EAAE,SAAS,IACV,SAAS,IACb,SAAS,EAAE,EAAE,CACX,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,EACjD,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,CACrB,EACD,KAAK,EAAE;YACL,KAAK,EAAE,GAAG,KAAK,GAAG;YAClB,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,GAAG;SACxB;QAED,8BAAM,SAAS,EAAC,+BAA+B;YAC5C,IAAI;YACL,8BAAM,SAAS,EAAC,SAAS,IACtB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CACtC,CACF,CACH,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TimelineComponentTypes } from "../utils/types.internal";
|
|
3
|
+
export interface TimelinePeriodProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Period start date.
|
|
6
|
+
*/
|
|
7
|
+
start: Date;
|
|
8
|
+
/**
|
|
9
|
+
* Period end date.
|
|
10
|
+
*/
|
|
11
|
+
end: Date;
|
|
12
|
+
/**
|
|
13
|
+
* Icon for easier visual identification.
|
|
14
|
+
*/
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Period status.
|
|
18
|
+
* @default "neutral"
|
|
19
|
+
*/
|
|
20
|
+
status?: "success" | "warning" | "danger" | "info" | "neutral";
|
|
21
|
+
/**
|
|
22
|
+
* Status label for screen-readers
|
|
23
|
+
* e.g "Sykemeldt", "foreldrepermisjon"
|
|
24
|
+
*/
|
|
25
|
+
statusLabel?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Callback when selecting a period.
|
|
28
|
+
*/
|
|
29
|
+
onSelectPeriod?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Content displayed in Popover on click.
|
|
32
|
+
*/
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Visual active inidcation on period
|
|
36
|
+
* @note Make sure only one period is active at a time
|
|
37
|
+
*/
|
|
38
|
+
isActive?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface PeriodProps {
|
|
41
|
+
start: Date;
|
|
42
|
+
end: Date;
|
|
43
|
+
status: string;
|
|
44
|
+
cropped: string;
|
|
45
|
+
direction: string;
|
|
46
|
+
width: Number;
|
|
47
|
+
left: Number;
|
|
48
|
+
icon?: React.ReactNode;
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
statusLabel?: string;
|
|
51
|
+
restProps?: any;
|
|
52
|
+
}
|
|
53
|
+
export interface PeriodType extends React.ForwardRefExoticComponent<TimelinePeriodProps & React.RefAttributes<HTMLDivElement | HTMLButtonElement>> {
|
|
54
|
+
componentType: TimelineComponentTypes;
|
|
55
|
+
}
|
|
56
|
+
export declare const Period: PeriodType;
|
|
57
|
+
export default Period;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { usePeriodContext } from "../hooks/usePeriodContext";
|
|
3
|
+
import { useRowContext } from "../hooks/useRowContext";
|
|
4
|
+
import ClickablePeriod from "./ClickablePeriod";
|
|
5
|
+
import NonClickablePeriod from "./NonClickablePeriod";
|
|
6
|
+
export const Period = forwardRef(({ icon }, ref) => {
|
|
7
|
+
const { periods } = useRowContext();
|
|
8
|
+
const { periodId, restProps } = usePeriodContext();
|
|
9
|
+
const period = periods.find((p) => p.id === periodId);
|
|
10
|
+
if (!period) {
|
|
11
|
+
return React.createElement(React.Fragment, null);
|
|
12
|
+
}
|
|
13
|
+
const { start, endInclusive, width, horizontalPosition, status = "neutral", onSelectPeriod, cropped, direction, children, isActive, statusLabel, } = period;
|
|
14
|
+
return onSelectPeriod || children ? (React.createElement(ClickablePeriod, { periodRef: ref, start: start, end: endInclusive, status: status, onSelectPeriod: onSelectPeriod, cropped: cropped || "", direction: direction, width: width, left: horizontalPosition, icon: icon, children: children, isActive: isActive, statusLabel: statusLabel, restProps: restProps })) : (React.createElement(NonClickablePeriod, { periodRef: ref, start: start, end: endInclusive, status: status, cropped: cropped || "", direction: direction, width: width, left: horizontalPosition, icon: icon, statusLabel: statusLabel, restProps: restProps }));
|
|
15
|
+
});
|
|
16
|
+
Period.componentType = "period";
|
|
17
|
+
export default Period;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/timeline/period/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AA+DtD,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAC9B,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;IAChB,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,CAAC;IACpC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEnD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAEtD,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,yCAAK,CAAC;KACd;IACD,MAAM,EACJ,KAAK,EACL,YAAY,EACZ,KAAK,EACL,kBAAkB,EAClB,MAAM,GAAG,SAAS,EAClB,cAAc,EACd,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,WAAW,GACZ,GAAG,MAAM,CAAC;IAEX,OAAO,cAAc,IAAI,QAAQ,CAAC,CAAC,CAAC,CAClC,oBAAC,eAAe,IACd,SAAS,EAAE,GAA4C,EACvD,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,IAAI,EAAE,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACpB,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,kBAAkB,IACjB,SAAS,EAAE,GAAG,EACd,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,IAAI,EAAE,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;AACJ,CAAC,CACY,CAAC;AAEhB,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC;AAEhC,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const position: (date: Date, start: Date, endInclusive: Date) => number;
|
|
2
|
+
export declare const horizontalPositionAndWidth: (start: Date, endInclusive: Date, timelineStart: Date, timelineEndInclusive: Date) => {
|
|
3
|
+
horizontalPosition: number;
|
|
4
|
+
width: number;
|
|
5
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { differenceInMilliseconds } from "date-fns";
|
|
2
|
+
export const position = (date, start, endInclusive) => {
|
|
3
|
+
const diff = differenceInMilliseconds(endInclusive, start);
|
|
4
|
+
return (differenceInMilliseconds(date, start) / diff) * 100;
|
|
5
|
+
};
|
|
6
|
+
export const horizontalPositionAndWidth = (start, endInclusive, timelineStart, timelineEndInclusive) => {
|
|
7
|
+
const horizontalPosition = position(start, timelineStart, timelineEndInclusive);
|
|
8
|
+
const width = position(endInclusive, timelineStart, timelineEndInclusive) -
|
|
9
|
+
horizontalPosition;
|
|
10
|
+
return {
|
|
11
|
+
horizontalPosition: horizontalPosition,
|
|
12
|
+
width: width,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=calc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calc.js","sourceRoot":"","sources":["../../../src/timeline/utils/calc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAE,KAAW,EAAE,YAAkB,EAAE,EAAE;IACtE,MAAM,IAAI,GAAG,wBAAwB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC3D,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,KAAW,EACX,YAAkB,EAClB,aAAmB,EACnB,oBAA0B,EAC1B,EAAE;IACF,MAAM,kBAAkB,GAAG,QAAQ,CACjC,KAAK,EACL,aAAa,EACb,oBAAoB,CACrB,CAAC;IACF,MAAM,KAAK,GACT,QAAQ,CAAC,YAAY,EAAE,aAAa,EAAE,oBAAoB,CAAC;QAC3D,kBAAkB,CAAC;IACrB,OAAO;QACL,kBAAkB,EAAE,kBAAkB;QACtC,KAAK,EAAE,KAAK;KACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Spatial } from "./types.internal";
|
|
2
|
+
export interface Positioned {
|
|
3
|
+
horizontalPosition: number;
|
|
4
|
+
direction: "left" | "right";
|
|
5
|
+
}
|
|
6
|
+
export declare const isVisible: ({ horizontalPosition }: Positioned) => boolean;
|
|
7
|
+
export declare const getFirstDate: (periods: any) => any;
|
|
8
|
+
export declare const getLastDate: (periods: any) => any;
|
|
9
|
+
export declare const withinADay: (date1: Date, date2: Date) => boolean;
|
|
10
|
+
export declare const invisiblePeriods: ({ horizontalPosition, width, }: Positioned & Spatial) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { differenceInDays } from "date-fns";
|
|
2
|
+
export const isVisible = ({ horizontalPosition }) => horizontalPosition <= 98 && horizontalPosition >= 0;
|
|
3
|
+
export const getFirstDate = (periods) => {
|
|
4
|
+
return periods.sort((a, b) => a.start.getTime() - b.start.getTime())[0].start;
|
|
5
|
+
};
|
|
6
|
+
export const getLastDate = (periods) => {
|
|
7
|
+
return periods.sort((a, b) => a.end.getTime() - b.end.getTime())[periods.length - 1].end;
|
|
8
|
+
};
|
|
9
|
+
export const withinADay = (date1, date2) => differenceInDays(date1, date2) <= 1;
|
|
10
|
+
export const invisiblePeriods = ({ horizontalPosition, width, }) => horizontalPosition >= 0 && horizontalPosition <= 100 && width > 0;
|
|
11
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/timeline/utils/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAS5C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,kBAAkB,EAAc,EAAW,EAAE,CACvE,kBAAkB,IAAI,EAAE,IAAI,kBAAkB,IAAI,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAY,EAAE,EAAE;IAC3C,OAAO,OAAO,CAAC,IAAI,CACjB,CAAC,CAAc,EAAE,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAC1E,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAY,EAAE,EAAE;IAC1C,OAAO,OAAO,CAAC,IAAI,CACjB,CAAC,CAAc,EAAE,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CACtE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAW,EAAE,KAAW,EAAW,EAAE,CAC9D,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,kBAAkB,EAClB,KAAK,GACgB,EAAE,EAAE,CACzB,kBAAkB,IAAI,CAAC,IAAI,kBAAkB,IAAI,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getFirstDate, getLastDate, isVisible, type Positioned, } from "./filter";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/timeline/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,SAAS,GAEV,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import { format } from "date-fns";
|
|
3
|
+
export const getConditionalClasses = (cropped, direction, status) => {
|
|
4
|
+
return cl(`navds-timeline__period navds-timeline__period--${status}`, {
|
|
5
|
+
"navds-timeline__period--connected-both": cropped === "both",
|
|
6
|
+
"navds-timeline__period--connected-right": (cropped === "right" && direction === "left") ||
|
|
7
|
+
(cropped === "left" && direction === "right"),
|
|
8
|
+
"navds-timeline__period--connected-left": (cropped === "left" && direction === "left") ||
|
|
9
|
+
(cropped === "right" && direction === "right"),
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
const translateStatus = (status) => {
|
|
13
|
+
switch (status) {
|
|
14
|
+
case "success":
|
|
15
|
+
return "Suksess";
|
|
16
|
+
case "warning":
|
|
17
|
+
return "Advarsel";
|
|
18
|
+
case "danger":
|
|
19
|
+
return "Fare";
|
|
20
|
+
case "info":
|
|
21
|
+
return "Info";
|
|
22
|
+
case "neutral":
|
|
23
|
+
return "Nøytral";
|
|
24
|
+
default:
|
|
25
|
+
return status;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const ariaLabel = (startDate, endDate, status, statusLabel) => {
|
|
29
|
+
const start = format(startDate, "dd.MM.yyyy");
|
|
30
|
+
const end = format(endDate, "dd.MM.yyyy");
|
|
31
|
+
return `${statusLabel ? statusLabel : translateStatus(status)} fra ${start} til ${end}`;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=period.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"period.js","sourceRoot":"","sources":["../../../src/timeline/utils/period.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,OAAe,EACf,SAAiB,EACjB,MAAc,EACd,EAAE;IACF,OAAO,EAAE,CAAC,kDAAkD,MAAM,EAAE,EAAE;QACpE,wCAAwC,EAAE,OAAO,KAAK,MAAM;QAC5D,yCAAyC,EACvC,CAAC,OAAO,KAAK,OAAO,IAAI,SAAS,KAAK,MAAM,CAAC;YAC7C,CAAC,OAAO,KAAK,MAAM,IAAI,SAAS,KAAK,OAAO,CAAC;QAC/C,wCAAwC,EACtC,CAAC,OAAO,KAAK,MAAM,IAAI,SAAS,KAAK,MAAM,CAAC;YAC5C,CAAC,OAAO,KAAK,OAAO,IAAI,SAAS,KAAK,OAAO,CAAC;KACjD,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE;IACjD,QAAQ,MAAM,EAAE;QACd,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,UAAU,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,MAAM,CAAC;KACjB;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,SAAe,EACf,OAAa,EACb,MAAc,EACd,WAAoB,EACZ,EAAE;IACV,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1C,OAAO,GACL,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CACpD,QAAQ,KAAK,QAAQ,GAAG,EAAE,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Period, PositionedPeriod } from "./types.internal";
|
|
2
|
+
export declare const lastDate: (a: Date, b: Date) => number;
|
|
3
|
+
export declare const lastPeriod: (a: PositionedPeriod, b: PositionedPeriod) => number;
|
|
4
|
+
export declare const lastSinglePeriod: (a: Period, b: Period) => number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { differenceInMilliseconds } from "date-fns";
|
|
2
|
+
export const lastDate = (a, b) => differenceInMilliseconds(a, b);
|
|
3
|
+
export const lastPeriod = (a, b) => a.horizontalPosition - b.horizontalPosition;
|
|
4
|
+
export const lastSinglePeriod = (a, b) => differenceInMilliseconds(b.endInclusive, a.endInclusive);
|
|
5
|
+
//# sourceMappingURL=sort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../src/timeline/utils/sort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGpD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAO,EAAE,CAAO,EAAU,EAAE,CACnD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAmB,EAAE,CAAmB,EAAU,EAAE,CAC7E,CAAC,CAAC,kBAAkB,GAAG,CAAC,CAAC,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAC/D,wBAAwB,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { Period } from "./types.external";
|
|
3
|
+
type ParsedChild = {
|
|
4
|
+
label?: string;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
headingTag: string;
|
|
7
|
+
periods: Omit<Period, "id" | "endInclusive">[];
|
|
8
|
+
restProps: any;
|
|
9
|
+
ref: any;
|
|
10
|
+
};
|
|
11
|
+
export declare const parseRows: (rowChildren: ReactNode[]) => ParsedChild[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { omit } from "../../util";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export const parseRows = (rowChildren) => {
|
|
4
|
+
let parsedChildren = [];
|
|
5
|
+
rowChildren === null || rowChildren === void 0 ? void 0 : rowChildren.forEach((r) => {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
7
|
+
let periods = [];
|
|
8
|
+
if (React.isValidElement(r) && ((_a = r === null || r === void 0 ? void 0 : r.props) === null || _a === void 0 ? void 0 : _a.children)) {
|
|
9
|
+
if (Array.isArray(r.props.children)) {
|
|
10
|
+
for (let i = 0; i < r.props.children.length; i++) {
|
|
11
|
+
const p = r.props.children[i];
|
|
12
|
+
periods.push({
|
|
13
|
+
start: (_b = p === null || p === void 0 ? void 0 : p.props) === null || _b === void 0 ? void 0 : _b.start,
|
|
14
|
+
end: (_c = p === null || p === void 0 ? void 0 : p.props) === null || _c === void 0 ? void 0 : _c.end,
|
|
15
|
+
status: ((_d = p === null || p === void 0 ? void 0 : p.props) === null || _d === void 0 ? void 0 : _d.status) || "neutral",
|
|
16
|
+
onSelectPeriod: (_e = p.props) === null || _e === void 0 ? void 0 : _e.onSelectPeriod,
|
|
17
|
+
label: r.props.label,
|
|
18
|
+
icon: p.props.icon,
|
|
19
|
+
children: p.props.children,
|
|
20
|
+
isActive: p.props.isActive,
|
|
21
|
+
statusLabel: p.props.statusLabel,
|
|
22
|
+
restProps: omit(p.props, [
|
|
23
|
+
"start",
|
|
24
|
+
"end",
|
|
25
|
+
"status",
|
|
26
|
+
"onSelectPeriod",
|
|
27
|
+
"label",
|
|
28
|
+
"icon",
|
|
29
|
+
"children",
|
|
30
|
+
"isActive",
|
|
31
|
+
"statusLabel",
|
|
32
|
+
]),
|
|
33
|
+
ref: p === null || p === void 0 ? void 0 : p.ref,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
periods.push({
|
|
39
|
+
start: r.props.children.props.start,
|
|
40
|
+
end: r.props.children.props.end,
|
|
41
|
+
status: ((_f = r.props.children.props) === null || _f === void 0 ? void 0 : _f.status) || "neutral",
|
|
42
|
+
onSelectPeriod: (_g = r.props.children.props) === null || _g === void 0 ? void 0 : _g.onSelectPeriod,
|
|
43
|
+
label: r.props.label,
|
|
44
|
+
icon: (_h = r.props.children.props) === null || _h === void 0 ? void 0 : _h.icon,
|
|
45
|
+
children: (_j = r.props.children.props) === null || _j === void 0 ? void 0 : _j.children,
|
|
46
|
+
statusLabel: (_k = r.props.children.props) === null || _k === void 0 ? void 0 : _k.statusLabel,
|
|
47
|
+
restProps: omit(r.props.children.props, [
|
|
48
|
+
"start",
|
|
49
|
+
"end",
|
|
50
|
+
"status",
|
|
51
|
+
"onSelectPeriod",
|
|
52
|
+
"label",
|
|
53
|
+
"icon",
|
|
54
|
+
"children",
|
|
55
|
+
"isActive",
|
|
56
|
+
"statusLabel",
|
|
57
|
+
]),
|
|
58
|
+
ref: (_m = (_l = r.props) === null || _l === void 0 ? void 0 : _l.children) === null || _m === void 0 ? void 0 : _m.ref,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
parsedChildren.push({
|
|
62
|
+
label: r.props.label,
|
|
63
|
+
icon: r.props.icon,
|
|
64
|
+
headingTag: r.props.headingTag,
|
|
65
|
+
periods: periods,
|
|
66
|
+
restProps: omit(r.props, ["label", "icon", "headingTag"]),
|
|
67
|
+
ref: r === null || r === void 0 ? void 0 : r.ref,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return parsedChildren;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=timeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../../src/timeline/utils/timeline.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type PeriodStatus = "success" | "warning" | "danger" | "info" | "neutral";
|
|
3
|
+
export type Percentage = number;
|
|
4
|
+
export interface Positioned {
|
|
5
|
+
horizontalPosition: number;
|
|
6
|
+
direction: "left" | "right";
|
|
7
|
+
}
|
|
8
|
+
export interface Period {
|
|
9
|
+
id: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
start: Date;
|
|
12
|
+
endInclusive: Date;
|
|
13
|
+
status?: PeriodStatus;
|
|
14
|
+
onSelectPeriod?: () => void;
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
end: Date;
|
|
18
|
+
isActive?: boolean;
|
|
19
|
+
statusLabel?: string;
|
|
20
|
+
restProps?: any;
|
|
21
|
+
ref?: Element;
|
|
22
|
+
}
|
|
23
|
+
export interface PositionedPeriod extends Period, Positioned {
|
|
24
|
+
width: number;
|
|
25
|
+
active?: boolean;
|
|
26
|
+
cropped?: "left" | "right" | "both";
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
className?: string;
|
|
29
|
+
hoverLabel?: React.ReactNode;
|
|
30
|
+
infoPin?: boolean;
|
|
31
|
+
start: Date;
|
|
32
|
+
}
|
|
33
|
+
export interface Spatial {
|
|
34
|
+
width: number;
|
|
35
|
+
}
|
|
36
|
+
export interface AxisLabel extends Positioned, Spatial {
|
|
37
|
+
label: string;
|
|
38
|
+
date: Date;
|
|
39
|
+
}
|
|
40
|
+
export interface InternalSimpleTimeline {
|
|
41
|
+
id: string;
|
|
42
|
+
periods: PositionedPeriod[];
|
|
43
|
+
}
|
|
44
|
+
export interface SimplePeriod {
|
|
45
|
+
/**
|
|
46
|
+
* Startdato for perioden, mao. periodens høyre kant.
|
|
47
|
+
*/
|
|
48
|
+
start: Date;
|
|
49
|
+
/**
|
|
50
|
+
* Sluttdato for perioden, mao. periodens venstre kant.
|
|
51
|
+
*/
|
|
52
|
+
end: Date;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.external.js","sourceRoot":"","sources":["../../../src/timeline/utils/types.external.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type TimelineComponentTypes = "row" | "pin" | "period";
|
|
3
|
+
export type PeriodStatus = "success" | "warning" | "danger" | "info" | "neutral";
|
|
4
|
+
export type Percentage = number;
|
|
5
|
+
export interface Positioned {
|
|
6
|
+
horizontalPosition: number;
|
|
7
|
+
direction: "left" | "right";
|
|
8
|
+
}
|
|
9
|
+
export interface Period {
|
|
10
|
+
id: string;
|
|
11
|
+
start: Date;
|
|
12
|
+
endInclusive: Date;
|
|
13
|
+
status?: PeriodStatus;
|
|
14
|
+
onSelectPeriod?: () => void;
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
isActive?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface PositionedPeriod extends Period, Positioned {
|
|
20
|
+
width: number;
|
|
21
|
+
active?: boolean;
|
|
22
|
+
cropped?: "left" | "right" | "both";
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
hoverLabel?: React.ReactNode;
|
|
26
|
+
infoPin?: boolean;
|
|
27
|
+
end: Date;
|
|
28
|
+
statusLabel?: string;
|
|
29
|
+
restProps?: any;
|
|
30
|
+
ref?: any;
|
|
31
|
+
}
|
|
32
|
+
export interface Spatial {
|
|
33
|
+
width: number;
|
|
34
|
+
}
|
|
35
|
+
export interface AxisLabel extends Positioned, Spatial {
|
|
36
|
+
label: string;
|
|
37
|
+
date: Date;
|
|
38
|
+
}
|
|
39
|
+
export interface InternalSimpleTimeline {
|
|
40
|
+
label: string;
|
|
41
|
+
id: string;
|
|
42
|
+
periods: PositionedPeriod[];
|
|
43
|
+
icon?: React.ReactNode;
|
|
44
|
+
headingTag: "h2" | "h3" | "h4" | "h5" | "h6";
|
|
45
|
+
restProps: any;
|
|
46
|
+
ref: any;
|
|
47
|
+
}
|
|
48
|
+
export interface SelectedPeriod {
|
|
49
|
+
/**
|
|
50
|
+
* Start of the period.
|
|
51
|
+
*/
|
|
52
|
+
start: Date;
|
|
53
|
+
/**
|
|
54
|
+
* End of the period.
|
|
55
|
+
*/
|
|
56
|
+
end: Date;
|
|
57
|
+
/**
|
|
58
|
+
* Period id
|
|
59
|
+
*/
|
|
60
|
+
id: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.internal.js","sourceRoot":"","sources":["../../../src/timeline/utils/types.internal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface TimelineZoomButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* e.g 3mnd, 6mnd etc
|
|
5
|
+
*/
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Zoom interval in months or years
|
|
9
|
+
*/
|
|
10
|
+
interval: "month" | "year";
|
|
11
|
+
/**
|
|
12
|
+
* How many units of the interval that will be applied
|
|
13
|
+
* e.g interval="month" + count={3} equals 3 months
|
|
14
|
+
*/
|
|
15
|
+
count: number;
|
|
16
|
+
}
|
|
17
|
+
export type ZoomButtonType = React.ForwardRefExoticComponent<TimelineZoomButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
export declare const ZoomButton: ZoomButtonType;
|
|
19
|
+
export default ZoomButton;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { Detail } from "../../typography/Detail";
|
|
13
|
+
import { addMonths, addYears, format, isSameDay, subMonths, subYears, } from "date-fns";
|
|
14
|
+
import React, { forwardRef } from "react";
|
|
15
|
+
import { useTimelineContext } from "../hooks/useTimelineContext";
|
|
16
|
+
export const ZoomButton = forwardRef((_a, ref) => {
|
|
17
|
+
var { label, interval, count } = _a, rest = __rest(_a, ["label", "interval", "count"]);
|
|
18
|
+
const { setStart, endDate, startDate, direction } = useTimelineContext();
|
|
19
|
+
let startOfRange;
|
|
20
|
+
if (interval === "month") {
|
|
21
|
+
startOfRange =
|
|
22
|
+
direction === "left"
|
|
23
|
+
? subMonths(endDate, count)
|
|
24
|
+
: addMonths(startDate, count);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
startOfRange =
|
|
28
|
+
direction === "left"
|
|
29
|
+
? subYears(endDate, count)
|
|
30
|
+
: addYears(startDate, count);
|
|
31
|
+
}
|
|
32
|
+
const currentZoom = direction === "left"
|
|
33
|
+
? isSameDay(startDate, startOfRange)
|
|
34
|
+
: isSameDay(endDate, startOfRange);
|
|
35
|
+
return (React.createElement(Detail, { as: "li" },
|
|
36
|
+
React.createElement("button", Object.assign({ type: "button", "aria-label": !currentZoom
|
|
37
|
+
? `Zoom tidslinjen ${format(startOfRange, "dd.MM.yyyy")} til ${format(endDate, "dd.MM.yyyy")}`
|
|
38
|
+
: "Tilbakestill til initiell tidsperspektiv", ref: ref }, rest, { className: "navds-timeline__zoom-button", onClick: () => {
|
|
39
|
+
setStart(startOfRange);
|
|
40
|
+
}, "aria-pressed": currentZoom }), label)));
|
|
41
|
+
});
|
|
42
|
+
export default ZoomButton;
|
|
43
|
+
//# sourceMappingURL=ZoomButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoomButton.js","sourceRoot":"","sources":["../../../src/timeline/zoom/ZoomButton.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,EACT,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAsBjE,MAAM,CAAC,MAAM,UAAU,GAAmB,UAAU,CAClD,CAAC,EAAmC,EAAE,GAAG,EAAE,EAAE;QAA5C,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,OAAW,EAAN,IAAI,cAAjC,8BAAmC,CAAF;IAChC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAEzE,IAAI,YAAkB,CAAC;IAEvB,IAAI,QAAQ,KAAK,OAAO,EAAE;QACxB,YAAY;YACV,SAAS,KAAK,MAAM;gBAClB,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC;gBAC3B,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KACnC;SAAM;QACL,YAAY;YACV,SAAS,KAAK,MAAM;gBAClB,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;gBAC1B,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KAClC;IAED,MAAM,WAAW,GACf,SAAS,KAAK,MAAM;QAClB,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,YAAY,CAAC;QACpC,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAEvC,OAAO,CACL,oBAAC,MAAM,IAAC,EAAE,EAAC,IAAI;QACb,8CACE,IAAI,EAAC,QAAQ,gBAEX,CAAC,WAAW;gBACV,CAAC,CAAC,mBAAmB,MAAM,CACvB,YAAY,EACZ,YAAY,CACb,QAAQ,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE;gBAC1C,CAAC,CAAC,0CAA0C,EAEhD,GAAG,EAAE,GAAG,IACJ,IAAI,IACR,SAAS,EAAC,6BAA6B,EACvC,OAAO,EAAE,GAAG,EAAE;gBACZ,QAAQ,CAAC,YAAY,CAAC,CAAC;YACzB,CAAC,kBACa,WAAW,KAExB,KAAK,CACC,CACF,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ZoomButtonType } from "./ZoomButton";
|
|
3
|
+
interface ZoomProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export interface ZoomType<Props = ZoomProps> extends React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLUListElement>> {
|
|
7
|
+
Button: ZoomButtonType;
|
|
8
|
+
componentType: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const Zoom: ZoomType<ZoomProps>;
|
|
11
|
+
export default Zoom;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import cl from "clsx";
|
|
13
|
+
import React, { forwardRef } from "react";
|
|
14
|
+
import ZoomButton from "./ZoomButton";
|
|
15
|
+
export const Zoom = forwardRef((_a, ref) => {
|
|
16
|
+
var { className, children } = _a, rest = __rest(_a, ["className", "children"]);
|
|
17
|
+
return (React.createElement("ul", Object.assign({ ref: ref, className: cl(className, "navds-timeline__zoom") }, rest), children));
|
|
18
|
+
});
|
|
19
|
+
Zoom.Button = ZoomButton;
|
|
20
|
+
Zoom.componentType = "zoom";
|
|
21
|
+
export default Zoom;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/timeline/zoom/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,UAA8B,MAAM,cAAc,CAAC;AAc1D,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC5B,CAAC,EAAgC,EAAE,GAAG,EAAE,EAAE;QAAzC,EAAE,SAAS,EAAE,QAAQ,OAAW,EAAN,IAAI,cAA9B,yBAAgC,CAAF;IAC7B,OAAO,CACL,0CAAI,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,sBAAsB,CAAC,IAAM,IAAI,GACrE,QAAQ,CACN,CACN,CAAC;AACJ,CAAC,CACU,CAAC;AAEd,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;AACzB,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;AAE5B,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@floating-ui/react": "0.24.1",
|
|
41
|
-
"@navikt/aksel-icons": "^
|
|
41
|
+
"@navikt/aksel-icons": "^4.0.0",
|
|
42
42
|
"@radix-ui/react-tabs": "1.0.0",
|
|
43
43
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
44
44
|
"clsx": "^1.2.1",
|