@trackunit/react-components 0.0.147 → 0.0.152

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.
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps } from "../../common";
3
+ import { EChartsType } from "echarts";
3
4
  export interface IOptionsType {
4
5
  [key: string]: any;
5
6
  }
@@ -32,6 +33,10 @@ export interface ChartProps extends CommonProps {
32
33
  * Event fired when mouse leaves the chart.
33
34
  */
34
35
  mouseLeaveChart?: () => void;
36
+ /**
37
+ * Event fired when mouse is moving over the chart.
38
+ */
39
+ mouseMoveChart?: (event: any, chart: EChartsType | undefined) => void;
35
40
  /**
36
41
  * CSS styles for the chart.
37
42
  */
@@ -73,4 +78,4 @@ export interface ChartProps extends CommonProps {
73
78
  * @param {ChartProps} props - The props for the Chart component
74
79
  * @returns {JSX.Element} Chart component
75
80
  */
76
- export declare const Chart: ({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) => JSX.Element;
81
+ export declare const Chart: ({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export interface ILegendItem {
3
- label: string;
3
+ label?: string;
4
4
  selected?: boolean;
5
5
  disabled?: boolean;
6
6
  onClick?: () => void;
@@ -20,7 +20,6 @@ export interface PopoverListItemProps extends CommonProps {
20
20
  * The child nodes.
21
21
  */
22
22
  children: React.ReactNode;
23
- renderAs?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
24
23
  }
25
24
  /**
26
25
  * The PopoverListItem component.
@@ -28,4 +27,4 @@ export interface PopoverListItemProps extends CommonProps {
28
27
  * @param {PopoverListItemProps} props - The props for the PopoverListItem component
29
28
  * @returns {JSX.Element} PopoverListItem component
30
29
  */
31
- export declare const PopoverListItem: ({ selected, children, disabled, ariaLabel, url, onClick, prefix, suffix, renderAs, dataTestId, }: PopoverListItemProps) => JSX.Element;
30
+ export declare const PopoverListItem: ({ selected, children, disabled, ariaLabel, url, onClick, prefix, suffix, dataTestId, }: PopoverListItemProps) => JSX.Element;
package/index.js CHANGED
@@ -10,10 +10,10 @@ import { format, formatDistance } from 'date-fns';
10
10
  import { useSpring, animated } from '@react-spring/web';
11
11
  import usePortal from 'react-useportal';
12
12
  import { createPopper } from '@popperjs/core';
13
+ import { Link, UNSAFE_NavigationContext } from 'react-router-dom';
13
14
  import { DayPicker as DayPicker$1 } from 'react-day-picker';
14
15
  import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
15
16
  import { Helmet } from 'react-helmet';
16
- import { UNSAFE_NavigationContext } from 'react-router-dom';
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';
@@ -1412,6 +1412,7 @@ const Chart = ({
1412
1412
  onBrush,
1413
1413
  onBrushSelected,
1414
1414
  mouseLeaveChart,
1415
+ mouseMoveChart,
1415
1416
  merge = true,
1416
1417
  loadingOption,
1417
1418
  timezoneLabel,
@@ -1440,8 +1441,16 @@ const Chart = ({
1440
1441
  values.globalout = mouseLeaveChart;
1441
1442
  }
1442
1443
 
1444
+ if (mouseMoveChart !== undefined) {
1445
+ values.mouseMove = event => {
1446
+ var _a;
1447
+
1448
+ mouseMoveChart(event, (_a = echartsRef === null || echartsRef === void 0 ? void 0 : echartsRef.current) === null || _a === void 0 ? void 0 : _a.getEchartsInstance());
1449
+ };
1450
+ }
1451
+
1443
1452
  return values;
1444
- }, [onDataZoom, onBrush, onBrushSelected, mouseLeaveChart]);
1453
+ }, [onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart]);
1445
1454
  React.useEffect(() => {
1446
1455
  var _a;
1447
1456
 
@@ -1506,7 +1515,7 @@ const ChartContainer = tw.div`
1506
1515
  * @returns {JSX.Element} Label component
1507
1516
  */
1508
1517
 
1509
- const Label$3 = ({
1518
+ const Label$2 = ({
1510
1519
  id,
1511
1520
  htmlFor,
1512
1521
  children,
@@ -1659,7 +1668,7 @@ const Checkbox = React.forwardRef((_a, ref) => {
1659
1668
  onKeyPress: onKeyPress
1660
1669
  }, {
1661
1670
  children: icon
1662
- })), label && jsx(Label$3, Object.assign({
1671
+ })), label && jsx(Label$2, Object.assign({
1663
1672
  className: tws`cursor-pointer`,
1664
1673
  htmlFor: uuid,
1665
1674
  disabled: isReadonly,
@@ -2093,7 +2102,6 @@ const PopoverListItem = ({
2093
2102
  onClick,
2094
2103
  prefix,
2095
2104
  suffix,
2096
- renderAs,
2097
2105
  dataTestId
2098
2106
  }) => {
2099
2107
  const content = jsxs("div", Object.assign({
@@ -2118,9 +2126,8 @@ const PopoverListItem = ({
2118
2126
  "aria-label": ariaLabel,
2119
2127
  "data-testid": dataTestId
2120
2128
  }, {
2121
- children: url ? jsx(UnstyledAnchor, Object.assign({
2122
- "$as": renderAs,
2123
- href: url
2129
+ children: url ? jsx(PopoverLink, Object.assign({
2130
+ to: url
2124
2131
  }, {
2125
2132
  children: content
2126
2133
  })) : content
@@ -2135,7 +2142,7 @@ const ListItem = tw.li`
2135
2142
  tu-popover-list-item
2136
2143
  ${p => p.disabled && tws`tu-popover-list-item--disabled`}
2137
2144
  `;
2138
- const UnstyledAnchor = tw.a`
2145
+ const PopoverLink = twx(Link)`
2139
2146
  tu-popover-list-item__anchor
2140
2147
  `;
2141
2148
 
@@ -2314,7 +2321,7 @@ const FormGroup = ({
2314
2321
  "$disabled": disabled
2315
2322
  }, {
2316
2323
  children: [jsxs(ContainerBefore, {
2317
- children: [jsx(Label$3, Object.assign({
2324
+ children: [jsx(Label$2, Object.assign({
2318
2325
  "data-testid": `${dataTestId}-label`
2319
2326
  }, {
2320
2327
  children: label
@@ -2610,7 +2617,7 @@ const Indicator$1 = _a => {
2610
2617
  children: [ping && jsx(Ping, {
2611
2618
  "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping"
2612
2619
  }), icon]
2613
- })), label !== undefined && withLabel && jsx(Label$2, Object.assign({
2620
+ })), label !== undefined && withLabel && jsx(Label$1, Object.assign({
2614
2621
  "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label"
2615
2622
  }, {
2616
2623
  children: label
@@ -2668,6 +2675,24 @@ const Container$4 = tw.div`
2668
2675
  case colors.UNKNOWN:
2669
2676
  return tws`tu-indicator--unknown`;
2670
2677
 
2678
+ case colors.ON_RENT:
2679
+ return tws`tu-indicator--on-rent`;
2680
+
2681
+ case colors.AVAILABLE:
2682
+ return tws`tu-indicator--available`;
2683
+
2684
+ case colors.PICKUP_READY:
2685
+ return tws`tu-indicator--pickup-ready`;
2686
+
2687
+ case colors.TRANSFER:
2688
+ return tws`tu-indicator--transfer`;
2689
+
2690
+ case colors.IN_REPAIR:
2691
+ return tws`tu-indicator--in-repair`;
2692
+
2693
+ case colors.OTHER_RENTAL_STATUS:
2694
+ return tws`tu-indicator--other-rental-status`;
2695
+
2671
2696
  default:
2672
2697
  return "";
2673
2698
  }
@@ -2682,7 +2707,7 @@ const IconBackground = tw.div`
2682
2707
  return $withBackground ? "" : "tu-indicator__icon-background--none";
2683
2708
  }}
2684
2709
  `;
2685
- const Label$2 = tw.div`
2710
+ const Label$1 = tw.div`
2686
2711
  tu-indicator__label
2687
2712
  `;
2688
2713
  const Ping = tw.span`
@@ -2708,16 +2733,17 @@ const LegendItem = ({
2708
2733
  const handleOnClick = onClick && !disabled ? () => onClick() : undefined;
2709
2734
  return jsxs(Root$2, Object.assign({
2710
2735
  "data-testid": dataTestId,
2711
- disabled: disabled,
2736
+ "$disabled": disabled,
2712
2737
  className: className,
2713
- selected: selected,
2738
+ "$selected": selected,
2714
2739
  onClick: handleOnClick
2715
2740
  }, {
2716
2741
  children: [jsx(Indicator, {
2717
2742
  style: {
2718
2743
  backgroundColor: color
2719
- }
2720
- }), jsx(Label$1, {
2744
+ },
2745
+ "$selected": selected
2746
+ }), label && jsx("p", {
2721
2747
  children: label
2722
2748
  })]
2723
2749
  }));
@@ -2729,19 +2755,18 @@ const Root$2 = tw.div`
2729
2755
  ease-in-out
2730
2756
  duration-200
2731
2757
  text-neutral-500
2732
- ${p => p.disabled ? tws`text-neutral-300` : p.selected ? tws`text-black` : tws`text-neutral-500`}
2733
- ${p => p.selected ? tws`font-medium` : null}
2758
+ hover:text-neutral-700
2759
+ text-sm
2760
+ gap-2
2761
+ ${p => p.$disabled ? tws`text-neutral-300` : p.$selected ? tws`text-black` : ""}
2762
+ ${p => p.$selected ? tws`font-medium` : null}
2734
2763
  ${p => p.onClick ? tws`cursor-pointer` : tws`cursor-default`}
2735
2764
  `;
2736
- const Indicator = tw.span`
2737
- block
2765
+ const Indicator = tw.div`
2738
2766
  w-3
2739
2767
  h-3
2740
2768
  rounded-[50%]
2741
- mr-2
2742
- `;
2743
- const Label$1 = tw.span`
2744
- text-sm
2769
+ ${p => p.$selected ? tws`border border-black border-opacity-50` : null}
2745
2770
  `;
2746
2771
 
2747
2772
  /**
@@ -3308,7 +3333,7 @@ const RadioItem = ({
3308
3333
  "data-testid": dataTestId,
3309
3334
  "$checked": isChecked
3310
3335
  }), jsxs(LabelContainer$1, {
3311
- children: [jsx(Label$3, Object.assign({
3336
+ children: [jsx(Label$2, Object.assign({
3312
3337
  htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${uuid}`,
3313
3338
  dataTestId: `${dataTestId}-Label`,
3314
3339
  disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
@@ -3370,7 +3395,7 @@ const SelectContainer$1 = ({
3370
3395
  "$hasError": hasError,
3371
3396
  "$isDisabled": isDisabled
3372
3397
  }, {
3373
- children: [label && !hideLabel && jsx(Label$3, Object.assign({
3398
+ children: [label && !hideLabel && jsx(Label$2, Object.assign({
3374
3399
  htmlFor: id
3375
3400
  }, {
3376
3401
  children: label
@@ -4732,7 +4757,7 @@ const Toggle = React.forwardRef(({
4732
4757
  })
4733
4758
  }))]
4734
4759
  })), jsxs(LabelContainer, {
4735
- children: [jsx(Label$3, Object.assign({
4760
+ children: [jsx(Label$2, Object.assign({
4736
4761
  htmlFor: id,
4737
4762
  dataTestId: `${dataTestId}-Label`,
4738
4763
  disabled: disabled
@@ -5298,4 +5323,4 @@ const Layout = tw.div`
5298
5323
  tu-layout-TwoColumnLayout
5299
5324
  `;
5300
5325
 
5301
- export { ActionButton, Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$3 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, activityColors, colors, criticalityColors, docs, generalColors, getOrderedOptions, getValueBarColorByValue, intentColors, isMultiValue, rentalStatusColors, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
5326
+ export { ActionButton, Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, activityColors, colors, criticalityColors, docs, generalColors, getOrderedOptions, getValueBarColorByValue, intentColors, isMultiValue, rentalStatusColors, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.147",
3
+ "version": "0.0.152",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
@@ -9,6 +9,7 @@
9
9
  "react": "17.0.2",
10
10
  "@trackunit/ui-design-tokens": "0.0.43",
11
11
  "echarts-for-react": "^3.0.2",
12
+ "echarts": "^5.4.0",
12
13
  "uuid": "^8.3.2",
13
14
  "react-use": "^17.4.0",
14
15
  "date-fns": "^2.29.3",
@@ -17,8 +18,8 @@
17
18
  "react-useportal": "1.0.16",
18
19
  "react-helmet": "^6.1.0",
19
20
  "@react-spring/web": "9.5.2",
20
- "@popperjs/core": "^2.11.6",
21
21
  "react-router-dom": "6.4.1",
22
+ "@popperjs/core": "^2.11.6",
22
23
  "react-select": "^5.4.0",
23
24
  "jest-canvas-mock": "^2.4.0"
24
25
  },