@navikt/ds-react 3.4.2 → 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.
Files changed (234) hide show
  1. package/_docs.json +5615 -3780
  2. package/cjs/date/hooks/index.js +4 -4
  3. package/cjs/date/index.js +6 -6
  4. package/cjs/dropdown/Dropdown.js +57 -0
  5. package/cjs/dropdown/Menu/Divider.js +47 -0
  6. package/cjs/dropdown/Menu/GroupedList/Heading.js +47 -0
  7. package/cjs/dropdown/Menu/GroupedList/Item.js +54 -0
  8. package/cjs/dropdown/Menu/GroupedList/index.js +51 -0
  9. package/cjs/dropdown/Menu/GroupedList/package.json +6 -0
  10. package/cjs/dropdown/Menu/List/Item.js +54 -0
  11. package/cjs/dropdown/Menu/List/index.js +49 -0
  12. package/cjs/dropdown/Menu/List/package.json +6 -0
  13. package/cjs/dropdown/Menu/index.js +64 -0
  14. package/cjs/dropdown/Menu/package.json +6 -0
  15. package/cjs/dropdown/Toggle.js +66 -0
  16. package/cjs/dropdown/index.js +23 -0
  17. package/cjs/dropdown/package.json +6 -0
  18. package/cjs/form/radio/RadioGroup.js +10 -0
  19. package/cjs/index.js +3 -0
  20. package/cjs/internal-header/InternalHeader.js +55 -0
  21. package/cjs/internal-header/InternalHeaderButton.js +47 -0
  22. package/cjs/internal-header/InternalHeaderTitle.js +48 -0
  23. package/cjs/internal-header/InternalHeaderUser.js +51 -0
  24. package/cjs/internal-header/InternalHeaderUserButton.js +54 -0
  25. package/cjs/internal-header/index.js +8 -0
  26. package/cjs/internal-header/package.json +6 -0
  27. package/cjs/read-more/ReadMore.js +17 -0
  28. package/cjs/timeline/AxisLabels.js +90 -0
  29. package/cjs/timeline/Pin.js +106 -0
  30. package/cjs/timeline/Timeline.js +162 -0
  31. package/cjs/timeline/TimelineRow.js +86 -0
  32. package/cjs/timeline/hooks/usePeriodContext.js +16 -0
  33. package/cjs/timeline/hooks/useRowContext.js +18 -0
  34. package/cjs/timeline/hooks/useTimelineContext.js +23 -0
  35. package/cjs/timeline/hooks/useTimelineRows.js +79 -0
  36. package/cjs/timeline/index.js +8 -0
  37. package/cjs/timeline/package.json +6 -0
  38. package/cjs/timeline/period/ClickablePeriod.js +120 -0
  39. package/cjs/timeline/period/NonClickablePeriod.js +18 -0
  40. package/cjs/timeline/period/index.js +46 -0
  41. package/cjs/timeline/period/package.json +6 -0
  42. package/cjs/timeline/utils/calc.js +19 -0
  43. package/cjs/timeline/utils/filter.js +18 -0
  44. package/cjs/timeline/utils/index.js +7 -0
  45. package/cjs/timeline/utils/package.json +6 -0
  46. package/cjs/timeline/utils/period.js +40 -0
  47. package/cjs/timeline/utils/sort.js +10 -0
  48. package/cjs/timeline/utils/timeline.js +79 -0
  49. package/cjs/timeline/utils/types.external.js +2 -0
  50. package/cjs/timeline/utils/types.internal.js +2 -0
  51. package/cjs/timeline/zoom/ZoomButton.js +68 -0
  52. package/cjs/timeline/zoom/index.js +50 -0
  53. package/cjs/timeline/zoom/package.json +6 -0
  54. package/esm/date/hooks/index.d.ts +3 -3
  55. package/esm/date/hooks/index.js +3 -3
  56. package/esm/date/hooks/index.js.map +1 -1
  57. package/esm/date/index.d.ts +3 -3
  58. package/esm/date/index.js +3 -3
  59. package/esm/date/index.js.map +1 -1
  60. package/esm/dropdown/Dropdown.d.ts +37 -0
  61. package/esm/dropdown/Dropdown.js +29 -0
  62. package/esm/dropdown/Dropdown.js.map +1 -0
  63. package/esm/dropdown/Menu/Divider.d.ts +4 -0
  64. package/esm/dropdown/Menu/Divider.js +19 -0
  65. package/esm/dropdown/Menu/Divider.js.map +1 -0
  66. package/esm/dropdown/Menu/GroupedList/Heading.d.ts +10 -0
  67. package/esm/dropdown/Menu/GroupedList/Heading.js +19 -0
  68. package/esm/dropdown/Menu/GroupedList/Heading.js.map +1 -0
  69. package/esm/dropdown/Menu/GroupedList/Item.d.ts +11 -0
  70. package/esm/dropdown/Menu/GroupedList/Item.js +26 -0
  71. package/esm/dropdown/Menu/GroupedList/Item.js.map +1 -0
  72. package/esm/dropdown/Menu/GroupedList/index.d.ts +15 -0
  73. package/esm/dropdown/Menu/GroupedList/index.js +23 -0
  74. package/esm/dropdown/Menu/GroupedList/index.js.map +1 -0
  75. package/esm/dropdown/Menu/List/Item.d.ts +11 -0
  76. package/esm/dropdown/Menu/List/Item.js +26 -0
  77. package/esm/dropdown/Menu/List/Item.js.map +1 -0
  78. package/esm/dropdown/Menu/List/index.d.ts +13 -0
  79. package/esm/dropdown/Menu/List/index.js +21 -0
  80. package/esm/dropdown/Menu/List/index.js.map +1 -0
  81. package/esm/dropdown/Menu/index.d.ts +27 -0
  82. package/esm/dropdown/Menu/index.js +36 -0
  83. package/esm/dropdown/Menu/index.js.map +1 -0
  84. package/esm/dropdown/Toggle.d.ts +10 -0
  85. package/esm/dropdown/Toggle.js +38 -0
  86. package/esm/dropdown/Toggle.js.map +1 -0
  87. package/esm/dropdown/index.d.ts +2 -0
  88. package/esm/dropdown/index.js +3 -0
  89. package/esm/dropdown/index.js.map +1 -0
  90. package/esm/form/radio/RadioGroup.d.ts +10 -0
  91. package/esm/form/radio/RadioGroup.js +10 -0
  92. package/esm/form/radio/RadioGroup.js.map +1 -1
  93. package/esm/index.d.ts +3 -0
  94. package/esm/index.js +3 -0
  95. package/esm/index.js.map +1 -1
  96. package/esm/internal-header/InternalHeader.d.ts +16 -0
  97. package/esm/internal-header/InternalHeader.js +27 -0
  98. package/esm/internal-header/InternalHeader.js.map +1 -0
  99. package/esm/internal-header/InternalHeaderButton.d.ts +11 -0
  100. package/esm/internal-header/InternalHeaderButton.js +19 -0
  101. package/esm/internal-header/InternalHeaderButton.js.map +1 -0
  102. package/esm/internal-header/InternalHeaderTitle.d.ts +11 -0
  103. package/esm/internal-header/InternalHeaderTitle.js +20 -0
  104. package/esm/internal-header/InternalHeaderTitle.js.map +1 -0
  105. package/esm/internal-header/InternalHeaderUser.d.ts +14 -0
  106. package/esm/internal-header/InternalHeaderUser.js +23 -0
  107. package/esm/internal-header/InternalHeaderUser.js.map +1 -0
  108. package/esm/internal-header/InternalHeaderUserButton.d.ts +15 -0
  109. package/esm/internal-header/InternalHeaderUserButton.js +26 -0
  110. package/esm/internal-header/InternalHeaderUserButton.js.map +1 -0
  111. package/esm/internal-header/index.d.ts +5 -0
  112. package/esm/internal-header/index.js +2 -0
  113. package/esm/internal-header/index.js.map +1 -0
  114. package/esm/read-more/ReadMore.d.ts +17 -0
  115. package/esm/read-more/ReadMore.js +17 -0
  116. package/esm/read-more/ReadMore.js.map +1 -1
  117. package/esm/timeline/AxisLabels.d.ts +6 -0
  118. package/esm/timeline/AxisLabels.js +81 -0
  119. package/esm/timeline/AxisLabels.js.map +1 -0
  120. package/esm/timeline/Pin.d.ts +17 -0
  121. package/esm/timeline/Pin.js +81 -0
  122. package/esm/timeline/Pin.js.map +1 -0
  123. package/esm/timeline/Timeline.d.ts +45 -0
  124. package/esm/timeline/Timeline.js +134 -0
  125. package/esm/timeline/Timeline.js.map +1 -0
  126. package/esm/timeline/TimelineRow.d.ts +22 -0
  127. package/esm/timeline/TimelineRow.js +58 -0
  128. package/esm/timeline/TimelineRow.js.map +1 -0
  129. package/esm/timeline/hooks/usePeriodContext.d.ts +9 -0
  130. package/esm/timeline/hooks/usePeriodContext.js +13 -0
  131. package/esm/timeline/hooks/usePeriodContext.js.map +1 -0
  132. package/esm/timeline/hooks/useRowContext.d.ts +11 -0
  133. package/esm/timeline/hooks/useRowContext.js +15 -0
  134. package/esm/timeline/hooks/useRowContext.js.map +1 -0
  135. package/esm/timeline/hooks/useTimelineContext.d.ts +15 -0
  136. package/esm/timeline/hooks/useTimelineContext.js +20 -0
  137. package/esm/timeline/hooks/useTimelineContext.js.map +1 -0
  138. package/esm/timeline/hooks/useTimelineRows.d.ts +4 -0
  139. package/esm/timeline/hooks/useTimelineRows.js +74 -0
  140. package/esm/timeline/hooks/useTimelineRows.js.map +1 -0
  141. package/esm/timeline/index.d.ts +6 -0
  142. package/esm/timeline/index.js +2 -0
  143. package/esm/timeline/index.js.map +1 -0
  144. package/esm/timeline/period/ClickablePeriod.d.ts +9 -0
  145. package/esm/timeline/period/ClickablePeriod.js +93 -0
  146. package/esm/timeline/period/ClickablePeriod.js.map +1 -0
  147. package/esm/timeline/period/NonClickablePeriod.d.ts +7 -0
  148. package/esm/timeline/period/NonClickablePeriod.js +14 -0
  149. package/esm/timeline/period/NonClickablePeriod.js.map +1 -0
  150. package/esm/timeline/period/index.d.ts +57 -0
  151. package/esm/timeline/period/index.js +18 -0
  152. package/esm/timeline/period/index.js.map +1 -0
  153. package/esm/timeline/utils/calc.d.ts +5 -0
  154. package/esm/timeline/utils/calc.js +15 -0
  155. package/esm/timeline/utils/calc.js.map +1 -0
  156. package/esm/timeline/utils/filter.d.ts +10 -0
  157. package/esm/timeline/utils/filter.js +11 -0
  158. package/esm/timeline/utils/filter.js.map +1 -0
  159. package/esm/timeline/utils/index.d.ts +1 -0
  160. package/esm/timeline/utils/index.js +2 -0
  161. package/esm/timeline/utils/index.js.map +1 -0
  162. package/esm/timeline/utils/period.d.ts +2 -0
  163. package/esm/timeline/utils/period.js +33 -0
  164. package/esm/timeline/utils/period.js.map +1 -0
  165. package/esm/timeline/utils/sort.d.ts +4 -0
  166. package/esm/timeline/utils/sort.js +5 -0
  167. package/esm/timeline/utils/sort.js.map +1 -0
  168. package/esm/timeline/utils/timeline.d.ts +12 -0
  169. package/esm/timeline/utils/timeline.js +73 -0
  170. package/esm/timeline/utils/timeline.js.map +1 -0
  171. package/esm/timeline/utils/types.external.d.ts +53 -0
  172. package/esm/timeline/utils/types.external.js +2 -0
  173. package/esm/timeline/utils/types.external.js.map +1 -0
  174. package/esm/timeline/utils/types.internal.d.ts +61 -0
  175. package/esm/timeline/utils/types.internal.js +2 -0
  176. package/esm/timeline/utils/types.internal.js.map +1 -0
  177. package/esm/timeline/zoom/ZoomButton.d.ts +19 -0
  178. package/esm/timeline/zoom/ZoomButton.js +43 -0
  179. package/esm/timeline/zoom/ZoomButton.js.map +1 -0
  180. package/esm/timeline/zoom/index.d.ts +11 -0
  181. package/esm/timeline/zoom/index.js +22 -0
  182. package/esm/timeline/zoom/index.js.map +1 -0
  183. package/package.json +2 -2
  184. package/src/date/datepicker/datepicker.stories.tsx +19 -21
  185. package/src/date/datepicker/datepicker.test.tsx +5 -5
  186. package/src/date/hooks/index.ts +3 -3
  187. package/src/date/hooks/useRangeDatepicker.test.tsx +6 -6
  188. package/src/date/index.ts +5 -5
  189. package/src/date/monthpicker/monthpicker.stories.tsx +5 -5
  190. package/src/date/utils/__tests__/get-dates.test.ts +0 -1
  191. package/src/dropdown/Dropdown.tsx +80 -0
  192. package/src/dropdown/Menu/Divider.tsx +18 -0
  193. package/src/dropdown/Menu/GroupedList/Heading.tsx +31 -0
  194. package/src/dropdown/Menu/GroupedList/Item.tsx +45 -0
  195. package/src/dropdown/Menu/GroupedList/index.tsx +33 -0
  196. package/src/dropdown/Menu/List/Item.tsx +44 -0
  197. package/src/dropdown/Menu/List/index.tsx +27 -0
  198. package/src/dropdown/Menu/index.tsx +85 -0
  199. package/src/dropdown/Toggle.tsx +52 -0
  200. package/src/dropdown/dropdown.stories.tsx +91 -0
  201. package/src/dropdown/index.ts +2 -0
  202. package/src/form/radio/RadioGroup.tsx +10 -0
  203. package/src/index.ts +3 -0
  204. package/src/internal-header/InternalHeader.tsx +44 -0
  205. package/src/internal-header/InternalHeaderButton.tsx +28 -0
  206. package/src/internal-header/InternalHeaderTitle.tsx +35 -0
  207. package/src/internal-header/InternalHeaderUser.tsx +39 -0
  208. package/src/internal-header/InternalHeaderUserButton.tsx +43 -0
  209. package/src/internal-header/header.stories.tsx +225 -0
  210. package/src/internal-header/index.ts +8 -0
  211. package/src/read-more/ReadMore.tsx +17 -0
  212. package/src/timeline/AxisLabels.tsx +143 -0
  213. package/src/timeline/Pin.tsx +169 -0
  214. package/src/timeline/Timeline.tsx +219 -0
  215. package/src/timeline/TimelineRow.tsx +122 -0
  216. package/src/timeline/hooks/usePeriodContext.tsx +22 -0
  217. package/src/timeline/hooks/useRowContext.tsx +26 -0
  218. package/src/timeline/hooks/useTimelineContext.tsx +37 -0
  219. package/src/timeline/hooks/useTimelineRows.ts +161 -0
  220. package/src/timeline/index.ts +6 -0
  221. package/src/timeline/period/ClickablePeriod.tsx +193 -0
  222. package/src/timeline/period/NonClickablePeriod.tsx +46 -0
  223. package/src/timeline/period/index.tsx +130 -0
  224. package/src/timeline/timeline.stories.tsx +444 -0
  225. package/src/timeline/utils/calc.ts +26 -0
  226. package/src/timeline/utils/filter.ts +32 -0
  227. package/src/timeline/utils/index.ts +6 -0
  228. package/src/timeline/utils/period.ts +48 -0
  229. package/src/timeline/utils/sort.ts +11 -0
  230. package/src/timeline/utils/timeline.ts +83 -0
  231. package/src/timeline/utils/types.external.ts +67 -0
  232. package/src/timeline/utils/types.internal.ts +76 -0
  233. package/src/timeline/zoom/ZoomButton.tsx +83 -0
  234. 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,2 @@
1
+ export { getFirstDate, getLastDate, isVisible, } from "./filter";
2
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export declare const getConditionalClasses: (cropped: string, direction: string, status: string) => string;
2
+ export declare const ariaLabel: (startDate: Date, endDate: Date, status: string, statusLabel?: string) => string;
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.external.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.internal.js.map
@@ -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.4.2",
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": "^3.4.2",
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",