@trackunit/react-components 0.0.208 → 0.1.1

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/index.css CHANGED
@@ -52,14 +52,12 @@
52
52
 
53
53
  &--small {
54
54
  @apply py-1
55
- px-2
56
- max-h-7;
55
+ px-2;
57
56
  }
58
57
 
59
58
  &--large {
60
59
  @apply py-2
61
- px-4
62
- max-h-9;
60
+ px-4;
63
61
  }
64
62
 
65
63
  &--primary {
@@ -74,16 +72,15 @@
74
72
  }
75
73
 
76
74
  &--secondary {
77
- @apply bg-slate-200
78
- text-slate-600
79
- hover:bg-slate-400
80
- hover:text-slate-800
81
- active:text-slate-700
82
- active:bg-slate-300
83
- focus:ring-slate-300
84
- disabled:bg-slate-200
85
- disabled:hover:bg-slate-200
86
- disabled:text-slate-400;
75
+ @apply component-button-secondary-color
76
+ hover:bg-secondary-400
77
+ hover:text-secondary-800
78
+ active:text-secondary-700
79
+ active:bg-secondary-300
80
+ focus:ring-secondary-300
81
+ disabled:bg-secondary-200
82
+ disabled:hover:bg-secondary-200
83
+ disabled:text-secondary-400;
87
84
  }
88
85
 
89
86
  &--danger {
@@ -111,7 +108,8 @@
111
108
  }
112
109
 
113
110
  &--tertiary {
114
- @apply bg-white border
111
+ @apply bg-white
112
+ border
115
113
  text-slate-600
116
114
  active:bg-slate-100
117
115
  active:text-slate-700
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { tw, tws, twx } from '@trackunit/tailwind-styled-components';
3
3
  import * as React from 'react';
4
- import React__default, { useState, forwardRef, useMemo, cloneElement, useCallback, Children, useRef, memo, useEffect, useContext } from 'react';
4
+ import React__default, { useState, forwardRef, useMemo, cloneElement, useCallback, useEffect, Children, useRef, memo, useContext } from 'react';
5
5
  import { HeroIconsArray, heroIconLookup, TrackunitSolidIconsArray, TrackunitOutlineIconsArray, trackunitIconLookup } from '@trackunit/ui-icons';
6
6
  import EChart from 'echarts-for-react';
7
7
  import { v4 } from 'uuid';
@@ -13,7 +13,7 @@ import { DayPicker as DayPicker$1 } from 'react-day-picker';
13
13
  import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
14
14
  import { useClickOutside } from 'react-browser-hooks';
15
15
  import usePortal from 'react-useportal';
16
- import { Helmet } from 'react-helmet';
16
+ import { HelmetProvider, Helmet } from 'react-helmet-async';
17
17
  import ReactSelect, { components } from 'react-select';
18
18
  export { default as ValueType } from 'react-select';
19
19
  import ReactAsyncCreatableSelect from 'react-select/async-creatable';
@@ -332,7 +332,7 @@ const Icon$1 = ({
332
332
  className: iconSizeClassName
333
333
  })
334
334
  }, {
335
- children: jsx(Root$6, Object.assign({
335
+ children: jsx(Root$7, Object.assign({
336
336
  "$color": color,
337
337
  onClick: onClick,
338
338
  "data-testid": dataTestId,
@@ -351,7 +351,7 @@ const Icon$1 = ({
351
351
  const LoadingDot = tw.span`
352
352
  tu-loading-dot
353
353
  `;
354
- const Root$6 = tw.span`
354
+ const Root$7 = tw.span`
355
355
  tu-icon
356
356
  ${({
357
357
  $color
@@ -922,18 +922,20 @@ const ROLE_CARD = "region";
922
922
  * @param {CardProps} props - The props for the Card component
923
923
  * @returns {JSX.Element} Card component
924
924
  */
925
- const Card = ({
926
- children,
927
- onClick,
928
- fullHeight = false,
929
- onMouseEnter,
930
- onMouseLeave,
931
- className,
932
- dataTestId,
933
- overflow = "visible",
934
- gridArea
935
- }) => {
936
- return jsx(StyledCard$1, Object.assign({
925
+ const Card = _a => {
926
+ var {
927
+ children,
928
+ onClick,
929
+ fullHeight = false,
930
+ onMouseEnter,
931
+ onMouseLeave,
932
+ className,
933
+ dataTestId,
934
+ overflow = "visible",
935
+ gridArea
936
+ } = _a,
937
+ rest = __rest(_a, ["children", "onClick", "fullHeight", "onMouseEnter", "onMouseLeave", "className", "dataTestId", "overflow", "gridArea"]);
938
+ return jsx(StyledCard$2, Object.assign({}, rest, {
937
939
  "$fullHeight": fullHeight,
938
940
  "$overflow": overflow,
939
941
  onClick: onClick,
@@ -963,7 +965,7 @@ const getOverflow$1 = () => ({
963
965
  };
964
966
  return overflows[$overflow];
965
967
  };
966
- const StyledCard$1 = tw.div`
968
+ const StyledCard$2 = tw.div`
967
969
  tu-card
968
970
  ${p => p.$fullHeight ? `h-full` : null}
969
971
 
@@ -1010,12 +1012,9 @@ const getDirection = () => ({
1010
1012
  return directions[$direction];
1011
1013
  };
1012
1014
  const densityAuto = tws`
1013
- gap-3
1014
- p-3
1015
- sm:gap-4
1016
- sm:p-4
1017
- md:gap-4
1018
- md:p-6
1015
+ component-card-spacing
1016
+ sm:component-card-spacing-sm
1017
+ md:component-card-spacing-md
1019
1018
  `;
1020
1019
  const DensityFinder = ({
1021
1020
  $density
@@ -1353,7 +1352,7 @@ const Label$2 = ({
1353
1352
  disabled,
1354
1353
  isInvalid
1355
1354
  }) => {
1356
- return jsx(Root$5, Object.assign({
1355
+ return jsx(Root$6, Object.assign({
1357
1356
  id: id || "",
1358
1357
  htmlFor: htmlFor || "",
1359
1358
  className: className,
@@ -1364,7 +1363,7 @@ const Label$2 = ({
1364
1363
  children: children
1365
1364
  }));
1366
1365
  };
1367
- const Root$5 = tw.label`
1366
+ const Root$6 = tw.label`
1368
1367
  tu-label
1369
1368
  ${({
1370
1369
  $disabled
@@ -2278,6 +2277,123 @@ const DayRangePicker = ({
2278
2277
  });
2279
2278
  };
2280
2279
 
2280
+ /**
2281
+ * The drawer provides a slideover which can be used to provide access to different locations in the application.
2282
+ *
2283
+ * @param {DrawerProps} props - The props for the Drawer component
2284
+ * @returns {JSX.Element} Drawer component
2285
+ */
2286
+ const Drawer = ({
2287
+ open,
2288
+ onClose = () => {},
2289
+ children,
2290
+ disableOverlay = false,
2291
+ position = "left",
2292
+ className,
2293
+ dataTestId
2294
+ }) => {
2295
+ const {
2296
+ context
2297
+ } = useFloating();
2298
+ useEffect(() => {
2299
+ // Close overlay when pressing escape button.
2300
+ const onKeyPress = e => {
2301
+ if (e.key === "Escape") {
2302
+ onClose();
2303
+ }
2304
+ };
2305
+ if (open) {
2306
+ window.addEventListener("keyup", onKeyPress);
2307
+ }
2308
+ return () => {
2309
+ window.removeEventListener("keyup", onKeyPress);
2310
+ };
2311
+ }, [open, onClose]);
2312
+ return jsx(FloatingFocusManager, Object.assign({
2313
+ context: context
2314
+ }, {
2315
+ children: open ? jsxs(Root$5, Object.assign({
2316
+ id: "drawer"
2317
+ }, {
2318
+ children: [!disableOverlay && jsx(Overlay, {
2319
+ "aria-hidden": open,
2320
+ "$open": open,
2321
+ onClick: onClose,
2322
+ id: "drawer__overlay"
2323
+ }), jsx(StyledCard$1, Object.assign({
2324
+ "aria-hidden": open,
2325
+ "data-testId": dataTestId,
2326
+ "$open": open,
2327
+ "$position": position,
2328
+ id: "drawer__card",
2329
+ className: className
2330
+ }, {
2331
+ children: children
2332
+ }))]
2333
+ })) :
2334
+ // eslint-disable-next-line react/jsx-no-useless-fragment
2335
+ jsx(Fragment, {})
2336
+ }));
2337
+ };
2338
+ const getPositionStyles = $position => {
2339
+ switch ($position) {
2340
+ case "top":
2341
+ return tws`tu-drawer__card--top`;
2342
+ case "right":
2343
+ return tws`tu-drawer__card--right`;
2344
+ case "bottom":
2345
+ return tws`tu-drawer__card--bottom`;
2346
+ case "left":
2347
+ default:
2348
+ return tws`tu-drawer__card--left`;
2349
+ }
2350
+ };
2351
+ const StyledCard$1 = twx(Card)`
2352
+ tu-drawer__card
2353
+ ${({
2354
+ $open
2355
+ }) => $open && tws`tu-drawer__card--open`}
2356
+ ${({
2357
+ $position
2358
+ }) => getPositionStyles($position)}
2359
+ `;
2360
+ const Root$5 = tw.div`
2361
+ tu-drawer
2362
+ `;
2363
+ const Overlay = tw.div`
2364
+ tu-drawer__overlay
2365
+ ${({
2366
+ $open
2367
+ }) => $open && tws`tu-drawer__overlay--open`}
2368
+ `;
2369
+
2370
+ /**
2371
+ * The external link component is used to link to an external page outside the Trackunit Manager.
2372
+ *
2373
+ * @param {ExternalLinkProps} props - The props for the external link component
2374
+ * @returns {JSX.Element} External Link component
2375
+ */
2376
+ const ExternalLink = ({
2377
+ rel = "noreferrer",
2378
+ target = "_blank",
2379
+ href,
2380
+ className,
2381
+ children = href,
2382
+ title = href,
2383
+ dataTestId
2384
+ }) => {
2385
+ return jsx("a", Object.assign({
2386
+ "data-testid": dataTestId,
2387
+ className: className,
2388
+ title: title,
2389
+ href: href,
2390
+ rel: rel,
2391
+ target: target
2392
+ }, {
2393
+ children: children
2394
+ }));
2395
+ };
2396
+
2281
2397
  /**
2282
2398
  * Indicators are non-interactive elements that communicate essential aspects of the state of an asset.
2283
2399
  *
@@ -2558,16 +2674,6 @@ const Divider = tw.hr`
2558
2674
  tu-menu-list__divider
2559
2675
  `;
2560
2676
 
2561
- var DotsDirection;
2562
- (function (DotsDirection) {
2563
- DotsDirection[DotsDirection["horizontal"] = 0] = "horizontal";
2564
- DotsDirection[DotsDirection["vertical"] = 1] = "vertical";
2565
- })(DotsDirection || (DotsDirection = {}));
2566
- var MenuPlacement;
2567
- (function (MenuPlacement) {
2568
- MenuPlacement[MenuPlacement["above"] = 0] = "above";
2569
- MenuPlacement[MenuPlacement["below"] = 1] = "below";
2570
- })(MenuPlacement || (MenuPlacement = {}));
2571
2677
  /**
2572
2678
  * A kebab menu component.
2573
2679
  * Advice: fill it with MenuList
@@ -2578,37 +2684,43 @@ var MenuPlacement;
2578
2684
  const MoreMenu = ({
2579
2685
  className,
2580
2686
  dataTestId,
2581
- dotsDirection = DotsDirection.horizontal,
2582
- menuPlacement = MenuPlacement.below,
2687
+ dotsDirection = "horizontal",
2688
+ menuPlacement,
2583
2689
  iconProps = {
2584
2690
  size: "medium"
2585
2691
  },
2586
2692
  iconButtonProps = {
2587
2693
  size: "small",
2588
2694
  circular: true,
2695
+ square: true,
2589
2696
  color: "tertiary"
2590
2697
  },
2591
2698
  children
2592
2699
  }) => {
2593
2700
  const [actionMenuIsOpen, setActionMenuIsOpen] = useState(false);
2594
- const dotsName = dotsDirection === DotsDirection.horizontal ? "DotsHorizontalIcon" : "DotsVerticalIcon";
2701
+ const dotsName = dotsDirection === "horizontal" ? "DotsHorizontalIcon" : "DotsVerticalIcon";
2595
2702
  const actionMenuRef = useRef(null);
2596
2703
  useClickOutside(actionMenuRef, () => {
2597
2704
  setActionMenuIsOpen(false);
2598
2705
  });
2599
- return jsxs(Root$3, Object.assign({
2706
+ return jsx(Root$3, Object.assign({
2600
2707
  ref: actionMenuRef,
2601
2708
  className: className,
2602
2709
  "data-testid": dataTestId
2603
2710
  }, {
2604
- children: [actionMenuIsOpen && menuPlacement === MenuPlacement.above && children, jsx(IconButton, Object.assign({}, iconButtonProps, {
2605
- icon: jsx(Icon$1, Object.assign({
2606
- name: dotsName
2607
- }, iconProps)),
2608
- onClick: () => {
2609
- setActionMenuIsOpen(!actionMenuIsOpen);
2610
- }
2611
- })), actionMenuIsOpen && menuPlacement === MenuPlacement.below && children]
2711
+ children: jsx(Popover, Object.assign({
2712
+ render: () => children,
2713
+ placement: menuPlacement
2714
+ }, {
2715
+ children: jsx(IconButton, Object.assign({}, iconButtonProps, {
2716
+ icon: jsx(Icon$1, Object.assign({
2717
+ name: dotsName
2718
+ }, iconProps)),
2719
+ onClick: () => {
2720
+ setActionMenuIsOpen(!actionMenuIsOpen);
2721
+ }
2722
+ }))
2723
+ }))
2612
2724
  }));
2613
2725
  };
2614
2726
  const Root$3 = tw.div`
@@ -2680,17 +2792,15 @@ const Modal = React.forwardRef(({
2680
2792
  children: jsx(StyledCard, Object.assign({
2681
2793
  dataTestId: dataTestId,
2682
2794
  className: className,
2683
- maxWidth: maxWidth
2795
+ "$maxWidth": maxWidth
2684
2796
  }, {
2685
2797
  children: children
2686
2798
  }))
2687
2799
  }))
2688
2800
  }));
2689
2801
  });
2690
- const getCardMaxWidth = () => ({
2691
- maxWidth
2692
- }) => {
2693
- maxWidth = maxWidth ? maxWidth : "full";
2802
+ const getCardMaxWidth = $maxWidth => {
2803
+ $maxWidth = $maxWidth ? $maxWidth : "full";
2694
2804
  const widths = {
2695
2805
  slim: tws`tu-modal__card--slim`,
2696
2806
  narrow: tws`tu-modal__card--narrow`,
@@ -2698,11 +2808,13 @@ const getCardMaxWidth = () => ({
2698
2808
  normal: tws`tu-modal__card--normal`,
2699
2809
  full: ""
2700
2810
  };
2701
- return widths[maxWidth];
2811
+ return widths[$maxWidth];
2702
2812
  };
2703
2813
  const StyledCard = twx(Card)`
2704
2814
  tu-modal__card
2705
- ${getCardMaxWidth()}
2815
+ ${({
2816
+ $maxWidth
2817
+ }) => getCardMaxWidth($maxWidth)}
2706
2818
  `;
2707
2819
  const StyledDiv = tw.div`
2708
2820
  tu-modal__container
@@ -3201,6 +3313,108 @@ const PageInput = tw.input`
3201
3313
  [-moz-appearance:textfield]
3202
3314
  `;
3203
3315
 
3316
+ /**
3317
+ * Create a PieChart with legends based on our current Chart component
3318
+ *
3319
+ * @param {PieChartProps} props - The props for the Chart component
3320
+ * @returns {JSX.Element} Chart component
3321
+ */
3322
+ const PieChart = ({
3323
+ data,
3324
+ size = "full",
3325
+ loading,
3326
+ onClick,
3327
+ className,
3328
+ dataTestId
3329
+ }) => jsxs(ChartRoot, Object.assign({
3330
+ className: className,
3331
+ "data-testid": dataTestId
3332
+ }, {
3333
+ children: [jsx("div", {
3334
+ children: size === "full" && jsx("div", Object.assign({
3335
+ className: "flex flex-col",
3336
+ "data-testid": "legend"
3337
+ }, {
3338
+ children: data === null || data === void 0 ? void 0 : data.map(item => jsx(LegendItem, {
3339
+ dataTestId: `legend-${item.id}`,
3340
+ label: (item === null || item === void 0 ? void 0 : item.count) !== undefined ? `${item.name} (${item.count})` : item.name,
3341
+ onClick: onClick ? () => onClick(item) : undefined,
3342
+ selected: item.selected,
3343
+ color: item.color
3344
+ }, item.id))
3345
+ }))
3346
+ }), jsx(Chart, {
3347
+ showLoading: loading,
3348
+ style: size === "full" ? {
3349
+ height: 110,
3350
+ width: 110
3351
+ } : {
3352
+ height: 60,
3353
+ width: 60
3354
+ },
3355
+ onClick: evt => {
3356
+ const clickedEntry = data === null || data === void 0 ? void 0 : data.find(x => x.id === evt.data.id);
3357
+ if (onClick && clickedEntry) {
3358
+ onClick(clickedEntry);
3359
+ }
3360
+ },
3361
+ options: {
3362
+ legend: {
3363
+ show: false
3364
+ },
3365
+ tooltip: {
3366
+ show: false
3367
+ },
3368
+ series: [{
3369
+ type: "pie",
3370
+ radius: ["50%", "75%"],
3371
+ center: ["50%", "50%"],
3372
+ minAngle: 10,
3373
+ selectedOffset: 8,
3374
+ itemStyle: {
3375
+ borderColor: "#ffffff",
3376
+ borderWidth: 2
3377
+ },
3378
+ avoidLabelOverlap: false,
3379
+ label: {
3380
+ show: false,
3381
+ position: "center",
3382
+ fontSize: "18",
3383
+ fontWeight: "bold"
3384
+ },
3385
+ emphasis: {
3386
+ label: {
3387
+ show: true,
3388
+ formatter: "{c}"
3389
+ }
3390
+ },
3391
+ labelLine: {
3392
+ show: false
3393
+ },
3394
+ data: data === null || data === void 0 ? void 0 : data.map(item => {
3395
+ var _a;
3396
+ return {
3397
+ id: item.id,
3398
+ name: item.name,
3399
+ value: (_a = item === null || item === void 0 ? void 0 : item.count) !== null && _a !== void 0 ? _a : 0,
3400
+ itemStyle: {
3401
+ color: item.color
3402
+ }
3403
+ };
3404
+ })
3405
+ }]
3406
+ }
3407
+ })]
3408
+ }));
3409
+ const ChartRoot = tw.div`
3410
+ flex
3411
+ flex-direction-col
3412
+ flex-wrap-reverse
3413
+ justify-between
3414
+ items-center
3415
+ h-full
3416
+ `;
3417
+
3204
3418
  function useConfirmExit(confirmExit, when = true) {
3205
3419
  const {
3206
3420
  navigator
@@ -3507,8 +3721,10 @@ const SectionHeader = ({
3507
3721
  addon
3508
3722
  }) => {
3509
3723
  return jsxs(SectionHeaderContainer, {
3510
- children: [jsx(Helmet, {
3511
- title: title
3724
+ children: [jsx(HelmetProvider, {
3725
+ children: jsx(Helmet, {
3726
+ title: title
3727
+ })
3512
3728
  }), jsxs(StyledFlex, {
3513
3729
  children: [jsx(Heading$1, Object.assign({
3514
3730
  variant: "secondary",
@@ -5218,4 +5434,4 @@ const Layout = tw.div`
5218
5434
  tu-layout-TwoColumnLayout
5219
5435
  `;
5220
5436
 
5221
- export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, DotsDirection, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MenuPlacement, MinTopFullContentLayout, Modal, ModalBackdrop, MoreMenu, MultiSelectMenuItem, NumberField, NumberInput, PageHeader, Pagination, Popover, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Search, SectionHeader, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, docs, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePrompt, useTimeout };
5437
+ export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, ExternalLink, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MoreMenu, MultiSelectMenuItem, NumberField, NumberInput, PageHeader, Pagination, PieChart, Popover, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Search, SectionHeader, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, docs, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePrompt, useTimeout };
package/package.json CHANGED
@@ -1,26 +1,27 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.208",
3
+ "version": "0.1.1",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
7
7
  "@trackunit/css-core": "0.0.64",
8
- "@storybook/addon-docs": "6.5.12",
8
+ "@storybook/addon-docs": "6.5.14",
9
9
  "@trackunit/tailwind-styled-components": "0.0.50",
10
- "react": "17.0.2",
10
+ "react": "18.2.0",
11
11
  "@trackunit/ui-design-tokens": "0.0.51",
12
+ "@trackunit/react-core-contexts-test": "0.1.12",
12
13
  "echarts-for-react": "3.0.2",
13
14
  "echarts": "5.4.0",
14
15
  "uuid": "8.3.2",
15
16
  "react-use": "17.4.0",
16
17
  "date-fns": "2.29.3",
17
18
  "react-day-picker": "8.3.7",
19
+ "@floating-ui/react-dom-interactions": "0.13.3",
18
20
  "@trackunit/ui-icons": "0.0.54",
19
21
  "react-browser-hooks": "2.2.4",
20
22
  "react-useportal": "1.0.17",
21
- "@floating-ui/react-dom-interactions": "0.13.3",
22
- "react-router-dom": "6.4.3",
23
- "react-helmet": "6.1.0",
23
+ "react-router-dom": "6.4.5",
24
+ "react-helmet-async": "1.3.0",
24
25
  "react-select": "5.7.0",
25
26
  "jest-canvas-mock": "2.4.0"
26
27
  },
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
3
  export declare const ROLE_CARD = "region";
4
4
  declare type Overflow = "visible" | "hidden" | "scroll" | "auto";
5
- export interface CardProps extends CommonProps {
5
+ export interface CardProps extends CommonProps, React.InputHTMLAttributes<HTMLDivElement> {
6
6
  /**
7
7
  * Whether the card should have full height or not.
8
8
  */
@@ -41,5 +41,5 @@ export interface CardProps extends CommonProps {
41
41
  * @param {CardProps} props - The props for the Card component
42
42
  * @returns {JSX.Element} Card component
43
43
  */
44
- export declare const Card: ({ children, onClick, fullHeight, onMouseEnter, onMouseLeave, className, dataTestId, overflow, gridArea, }: CardProps) => JSX.Element;
44
+ export declare const Card: ({ children, onClick, fullHeight, onMouseEnter, onMouseLeave, className, dataTestId, overflow, gridArea, ...rest }: CardProps) => JSX.Element;
45
45
  export {};
@@ -5,6 +5,10 @@ export interface CheckboxProps extends CommonProps, React.InputHTMLAttributes<HT
5
5
  * A string element to be displayed as a label
6
6
  */
7
7
  label?: React.ReactNode;
8
+ /**
9
+ * Children to be displayed
10
+ */
11
+ children?: React.ReactNode;
8
12
  /**
9
13
  * An boolean flag to set checkbox to disabled state
10
14
  */
@@ -0,0 +1,32 @@
1
+ import * as React from "react";
2
+ import { CommonProps } from "../../common";
3
+ export declare type Position = "left" | "right" | "top" | "bottom";
4
+ export interface DrawerProps extends CommonProps {
5
+ /**
6
+ * Specifies whether the drawer is open or not.
7
+ */
8
+ open: boolean;
9
+ /**
10
+ * The onClose handler for the drawer.
11
+ */
12
+ onClose?: () => void;
13
+ /**
14
+ * The position of the drawer.
15
+ */
16
+ position?: Position;
17
+ /**
18
+ * The child node that will be rendered inside the drawer.
19
+ */
20
+ children?: React.ReactNode;
21
+ /**
22
+ * Whether the drawer needs an overlay or not. Without the overlay, user will have to handle mechanism for closing the drawer.
23
+ */
24
+ disableOverlay?: boolean;
25
+ }
26
+ /**
27
+ * The drawer provides a slideover which can be used to provide access to different locations in the application.
28
+ *
29
+ * @param {DrawerProps} props - The props for the Drawer component
30
+ * @returns {JSX.Element} Drawer component
31
+ */
32
+ export declare const Drawer: ({ open, onClose, children, disableOverlay, position, className, dataTestId, }: DrawerProps) => JSX.Element;
@@ -0,0 +1,31 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "../../common";
3
+ export interface ExternalLinkProps extends CommonProps {
4
+ /**
5
+ * The URL to which users are redirected
6
+ */
7
+ href: string;
8
+ /**
9
+ * Child elements.
10
+ */
11
+ children: React.ReactNode;
12
+ /**
13
+ * The text to display on the URL. Defaults to the url itself.
14
+ */
15
+ title?: string;
16
+ /**
17
+ * Where to display the linked URL. Defaults to "_blank".
18
+ */
19
+ target?: "_blank" | "_self" | "_parent" | "top";
20
+ /**
21
+ * Used to specify the relationship between the link and the current document. Defaults to "noreferrer".
22
+ */
23
+ rel?: string;
24
+ }
25
+ /**
26
+ * The external link component is used to link to an external page outside the Trackunit Manager.
27
+ *
28
+ * @param {ExternalLinkProps} props - The props for the external link component
29
+ * @returns {JSX.Element} External Link component
30
+ */
31
+ export declare const ExternalLink: ({ rel, target, href, className, children, title, dataTestId, }: ExternalLinkProps) => JSX.Element;
@@ -2,20 +2,15 @@
2
2
  import { CommonProps } from "../../../common/CommonProps";
3
3
  import { IconButtonProps } from "../../buttons";
4
4
  import { IconProps } from "../../Icon/Icon";
5
- export declare enum DotsDirection {
6
- horizontal = 0,
7
- vertical = 1
8
- }
9
- export declare enum MenuPlacement {
10
- above = 0,
11
- below = 1
12
- }
5
+ import { PopoverPlacement } from "../../Popover";
6
+ export declare type DotsDirection = "horizontal" | "vertical";
7
+ export declare type MenuPlacement = "above" | "below";
13
8
  declare type FilteredIconProps = Omit<IconProps, "name">;
14
9
  declare type FilteredIconButtonProps = Omit<IconButtonProps, "icon" | "onClick">;
15
10
  export interface MoreMenuProps extends CommonProps {
16
11
  children: JSX.Element;
17
12
  dotsDirection?: DotsDirection;
18
- menuPlacement?: MenuPlacement;
13
+ menuPlacement?: PopoverPlacement;
19
14
  iconProps?: FilteredIconProps;
20
15
  iconButtonProps?: FilteredIconButtonProps;
21
16
  }
@@ -0,0 +1,55 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "../../common";
3
+ declare type Size = "compact" | "full";
4
+ export interface ChartData<T extends object = object> {
5
+ /**
6
+ * Unique ID for this entry. Not visibile for the user
7
+ */
8
+ id: string;
9
+ /**
10
+ * The text to show for to the user
11
+ */
12
+ name: string;
13
+ /**
14
+ * Number of elements with wrapped under this item
15
+ */
16
+ count?: number;
17
+ /**
18
+ * The color to use in the chart and legends for this item
19
+ */
20
+ color: string;
21
+ /**
22
+ * If selected, it'll be highlighted
23
+ */
24
+ selected?: boolean;
25
+ /**
26
+ * Supply the original object that this chart data item was constructed from. It'll be available on callbacks
27
+ */
28
+ original?: T;
29
+ }
30
+ export interface PieChartProps<T extends object> extends CommonProps {
31
+ /**
32
+ * Array of data points to show
33
+ */
34
+ data: ChartData<T>[] | undefined;
35
+ /**
36
+ * onClick handler which includes the data object clicked on
37
+ */
38
+ onClick?: (data: ChartData<T>) => void;
39
+ /**
40
+ * Show chart as loading
41
+ */
42
+ loading?: boolean;
43
+ /**
44
+ * When compact, the chart is smaller and legends are hidden.
45
+ */
46
+ size?: Size;
47
+ }
48
+ /**
49
+ * Create a PieChart with legends based on our current Chart component
50
+ *
51
+ * @param {PieChartProps} props - The props for the Chart component
52
+ * @returns {JSX.Element} Chart component
53
+ */
54
+ export declare const PieChart: <T extends object>({ data, size, loading, onClick, className, dataTestId, }: PieChartProps<T>) => JSX.Element;
55
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./PieChart";
@@ -11,6 +11,8 @@ export * from "./CopyableText";
11
11
  export * from "./DateField/DateField";
12
12
  export * from "./DateInput/DateInput";
13
13
  export * from "./DayPicker";
14
+ export * from "./Drawer/Drawer";
15
+ export * from "./ExternalLink/ExternalLink";
14
16
  export * from "./FormGroup/FormGroup";
15
17
  export * from "./Heading";
16
18
  export * from "./Icon/Icon";
@@ -23,6 +25,7 @@ export * from "./NumberField/NumberField";
23
25
  export * from "./NumberInput/NumberInput";
24
26
  export * from "./PageHeader";
25
27
  export * from "./Pagination/Pagination";
28
+ export * from "./PieChart";
26
29
  export * from "./Popover";
27
30
  export * from "./Popover/Popover";
28
31
  export * from "./Prompt";
@@ -1,4 +1,4 @@
1
- import { RenderHookOptions } from "@testing-library/react-hooks";
2
- declare const customRenderHook: <T, K>(callback: (props: T) => K, options?: RenderHookOptions<T> | undefined) => import("@testing-library/react-hooks").RenderHookResult<T, K, import("@testing-library/react-hooks").Renderer<T>>;
3
- export * from "@testing-library/react-hooks";
1
+ import { RenderHookOptions } from "@testing-library/react";
2
+ declare const customRenderHook: <T, K>(callback: (props: T) => K, options?: RenderHookOptions<T, typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement> | undefined) => import("@testing-library/react").RenderHookResult<K, T>;
3
+ export * from "@testing-library/react";
4
4
  export { customRenderHook as renderHook };