@trackunit/react-components 0.0.1-alpha-d61feec588.0 → 0.0.1-alpha-a2aba2c20d.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.
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Matcher } from "react-day-picker";
3
- export interface DayPickerProps {
3
+ import { CommonProps } from "../../common/CommonProps";
4
+ export interface DayPickerProps extends CommonProps {
4
5
  /**
5
6
  * A callback function for when a date is selected
6
7
  */
@@ -8,15 +9,18 @@ export interface DayPickerProps {
8
9
  /**
9
10
  * Define any days which may not be selected
10
11
  */
11
- disabledDays: Matcher | Matcher[] | undefined;
12
+ disabledDays?: Matcher | Matcher[];
12
13
  /**
13
14
  * Set any days which are selected
14
15
  */
15
- selectedDays: Matcher | Matcher[] | undefined;
16
+ selectedDays?: Matcher | Matcher[];
16
17
  /**
17
18
  * Set the language
18
19
  */
19
20
  language: string;
21
+ /**
22
+ * The maximum amount of days that can be selected
23
+ */
20
24
  max?: number;
21
25
  }
22
26
  /**
@@ -25,4 +29,4 @@ export interface DayPickerProps {
25
29
  * @param {DayPickerProps} props - The props for the DayPicker component
26
30
  * @returns {JSX.Element} DayPicker component
27
31
  */
28
- export declare const DayPicker: ({ onDaySelect, disabledDays, selectedDays, language, ...rest }: DayPickerProps) => JSX.Element;
32
+ export declare const DayPicker: ({ onDaySelect, disabledDays, selectedDays, language, className, dataTestId, max, }: DayPickerProps) => JSX.Element;
@@ -1,11 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { Matcher } from "react-day-picker";
3
- import { Size } from "../../common";
3
+ import { CommonProps, Size } from "../../common/CommonProps";
4
4
  import { ButtonColor } from "../buttons";
5
5
  import { PopoverPlacement } from "../Popover";
6
- export interface DayPickerPopoverProps {
6
+ export interface DayPickerPopoverProps extends CommonProps {
7
7
  disabledDays?: Matcher | Matcher[] | undefined;
8
- className?: string;
9
8
  onDaySelect: (day: Date) => void;
10
9
  selectedDay?: Date;
11
10
  color?: ButtonColor;
@@ -20,4 +19,4 @@ export interface DayPickerPopoverProps {
20
19
  * @param {DayPickerPopoverProps} props - The props for the DayPickerPopover component
21
20
  * @returns {JSX.Element} DayPickerPopover component
22
21
  */
23
- export declare const DayPickerPopover: ({ disabledDays, className, selectedDay, onDaySelect, color, placement, size, buttonContent, language, }: DayPickerPopoverProps) => JSX.Element;
22
+ export declare const DayPickerPopover: ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color, placement, size, buttonContent, language, }: DayPickerPopoverProps) => JSX.Element;
@@ -1,12 +1,27 @@
1
1
  /// <reference types="react" />
2
2
  import { DateRange, Matcher } from "react-day-picker";
3
+ import { CommonProps } from "../../common/CommonProps";
3
4
  export declare type IDateRange = DateRange;
4
- export interface DayRangePickerProps {
5
+ export interface DayRangePickerProps extends CommonProps {
6
+ /**
7
+ * A callback function for when a range is selected
8
+ */
5
9
  onRangeSelect?: (range: IDateRange | undefined) => void;
6
- selectedDays: IDateRange;
7
- dataTestId?: string;
10
+ /**
11
+ * Define any days which may not be selected
12
+ */
8
13
  disabledDays?: Matcher | Matcher[];
14
+ /**
15
+ * Set any days which are selected
16
+ */
17
+ selectedDays: IDateRange;
18
+ /**
19
+ * Set the language
20
+ */
9
21
  language: string;
22
+ /**
23
+ * The maximum amount of days that can be selected
24
+ */
10
25
  max?: number;
11
26
  }
12
27
  /**
@@ -15,4 +30,4 @@ export interface DayRangePickerProps {
15
30
  * @param {DayRangePickerProps} props - The props for the DayRangePicker component
16
31
  * @returns {JSX.Element} DayRangePicker component
17
32
  */
18
- export declare const DayRangePicker: ({ onRangeSelect, selectedDays, disabledDays, dataTestId, language, max, }: DayRangePickerProps) => JSX.Element;
33
+ export declare const DayRangePicker: ({ onRangeSelect, selectedDays, disabledDays, dataTestId, language, className, max, }: DayRangePickerProps) => JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { Placement } from "@floating-ui/react-dom-interactions";
2
+ import { ReactElement } from "react";
3
+ import { CommonProps } from "../../common";
4
+ declare type Render = (data: {
5
+ close: () => void;
6
+ }) => ReactElement;
7
+ export declare type PopoverPlacement = Placement;
8
+ export declare type PopoverActivation = {
9
+ click?: boolean;
10
+ hover?: boolean;
11
+ };
12
+ export interface PopoverProps extends CommonProps {
13
+ /**
14
+ * What to render indide the popover with callback to close the popover
15
+ */
16
+ render: Render;
17
+ /**
18
+ * Where to preferentially render the popover relative to the invoking element.
19
+ * Will not be respected in case of insufficient space.
20
+ */
21
+ placement?: PopoverPlacement;
22
+ /**
23
+ * Action(s) that activates the tooltip
24
+ */
25
+ activation?: PopoverActivation;
26
+ /**
27
+ * The element, usually a button, that activates the popover.
28
+ * Event handling is automatic and tied to this element. No manual Event handling is necessary.
29
+ */
30
+ children: ReactElement;
31
+ }
32
+ /**
33
+ * @param {PopoverProps} props The children to render in the popover
34
+ * @returns {ReactElement} Popover with specified content and placement
35
+ */
36
+ export declare const Popover: ({ children, render, placement, activation, className, dataTestId, }: PopoverProps) => JSX.Element;
37
+ export {};
@@ -1,5 +1,4 @@
1
- export * from "./AnimatedPopover";
1
+ export * from "./Popover";
2
2
  export * from "./PopoverList";
3
3
  export * from "./PopoverListItem";
4
4
  export * from "./PopoverTitle";
5
- export * from "./usePopover";
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { CommonProps } from "../../common";
3
3
  import { IconProps } from "../Icon/Icon";
4
4
  import { TooltipProps } from "../Tooltip";
5
- export interface TipProps extends CommonProps {
5
+ export interface TipProps extends CommonProps, Pick<TooltipProps, "placement" | "mode"> {
6
6
  /**
7
7
  * Child nodes to render inside the tip.
8
8
  */
@@ -11,10 +11,6 @@ export interface TipProps extends CommonProps {
11
11
  * The props for setting the icon on this tip.
12
12
  */
13
13
  iconProps?: Partial<IconProps>;
14
- /**
15
- * The props for setting the tooltip on this tip.
16
- */
17
- tooltipProps?: Partial<TooltipProps>;
18
14
  /**
19
15
  * The element type the tip will be rendered as.
20
16
  */
@@ -31,4 +27,4 @@ export interface TipProps extends CommonProps {
31
27
  * @param {TipProps} props - The props for the Tip component
32
28
  * @returns {JSX.Element} Tip component
33
29
  */
34
- export declare const Tip: ({ children, iconProps, tooltipProps, dataTestId, link, renderAs, className, }: TipProps) => JSX.Element;
30
+ export declare const Tip: ({ children, iconProps, dataTestId, link, renderAs, className, placement, mode, }: TipProps) => JSX.Element;
@@ -1,23 +1,20 @@
1
1
  import * as React from "react";
2
+ import { CommonProps } from "../../common";
2
3
  import { PopoverPlacement } from "../Popover";
3
4
  import { TextType } from "../Text";
4
- export interface TooltipProps {
5
+ export interface TooltipProps extends CommonProps {
5
6
  /**
6
7
  * The text to be displayed in the tooltip.
7
8
  */
8
9
  label: string | React.ReactNode;
9
10
  /**
10
- * Where the tooltip should be placed.
11
+ * Where the tooltip should preferentially be placed.
11
12
  */
12
13
  placement?: PopoverPlacement;
13
14
  /**
14
15
  * Child nodes
15
16
  */
16
17
  children?: React.ReactNode;
17
- /**
18
- * Id of test component.
19
- */
20
- dataTestId?: string;
21
18
  /**
22
19
  * Whether the tooltip is disabled or not.
23
20
  */
@@ -26,14 +23,6 @@ export interface TooltipProps {
26
23
  * To select either "light" or "dark" mode.
27
24
  */
28
25
  mode?: "light" | "dark";
29
- /**
30
- * Offset value of the tooltip.
31
- */
32
- offset?: [number, number];
33
- /**
34
- * Additional classes to the component.
35
- */
36
- className?: string;
37
26
  /**
38
27
  * Type of content.
39
28
  */
@@ -45,4 +34,4 @@ export interface TooltipProps {
45
34
  * @param {TooltipProps} props - The props for the Tooltip component
46
35
  * @returns {JSX.Element} Tooltip component
47
36
  */
48
- export declare const Tooltip: ({ label, placement, children, dataTestId, disabled, mode, offset, className, contentTextType, }: TooltipProps) => JSX.Element;
37
+ export declare const Tooltip: ({ children, dataTestId, disabled, className, ...rest }: TooltipProps) => JSX.Element;
@@ -38,6 +38,10 @@ export interface ButtonProps extends ButtonCommonProps {
38
38
  * The Id of the form to submit, for button type submit
39
39
  */
40
40
  form?: string;
41
+ /**
42
+ * The name of the button
43
+ */
44
+ name?: string;
41
45
  }
42
46
  /**
43
47
  * Buttons allow users to perform an action when triggered.
@@ -24,6 +24,7 @@ export * from "./NumberInput/NumberInput";
24
24
  export * from "./PageHeader";
25
25
  export * from "./Pagination/Pagination";
26
26
  export * from "./Popover";
27
+ export * from "./Popover/Popover";
27
28
  export * from "./Prompt";
28
29
  export * from "./RadioGroup";
29
30
  export * from "./SectionHeader";
package/index.js CHANGED
@@ -1,18 +1,17 @@
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, useRef, Fragment as Fragment$1, useCallback, createElement, memo, useEffect, useContext } from 'react';
4
+ import React__default, { useState, forwardRef, useMemo, cloneElement, useCallback, createElement, useRef, memo, useEffect, 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';
8
- import { useMeasure, useCopyToClipboard, useKeyPressEvent } from 'react-use';
8
+ import { useMeasure, useCopyToClipboard } from 'react-use';
9
9
  import { format, formatDistance } from 'date-fns';
10
- import { useSpring, animated } from '@react-spring/web';
11
- import usePortal from 'react-useportal';
12
- import { createPopper } from '@popperjs/core';
10
+ import { useFloating, offset, shift, flip, autoUpdate, useInteractions, useClick, useHover, useRole, useDismiss, FloatingPortal, FloatingFocusManager } from '@floating-ui/react-dom-interactions';
13
11
  import { Link, UNSAFE_NavigationContext } from 'react-router-dom';
14
12
  import { DayPicker as DayPicker$1 } from 'react-day-picker';
15
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
+ import usePortal from 'react-useportal';
16
15
  import { Helmet } from 'react-helmet';
17
16
  import ReactSelect, { components } from 'react-select';
18
17
  export { default as ValueType } from 'react-select';
@@ -116,7 +115,7 @@ const Spinner = ({
116
115
  containerClassName,
117
116
  dataTestId
118
117
  }) => {
119
- return jsx(Container$9, Object.assign({
118
+ return jsx(Container$8, Object.assign({
120
119
  "$mode": mode,
121
120
  "$centered": centered,
122
121
  className: containerClassName
@@ -152,7 +151,7 @@ const StyledSpinner$1 = tw.span`
152
151
  ${p => p.$mode === "dark" ? tws`tu-spinner--dark` : null}
153
152
  ${getSpinnerStyles()}
154
153
  `;
155
- const Container$9 = tw.div`
154
+ const Container$8 = tw.div`
156
155
  tu-spinner--container
157
156
  ${p => p.$centered ? tws`tu-spinner--container-centered` : null}
158
157
  `;
@@ -359,7 +358,7 @@ const Icon$1 = ({
359
358
  }, {
360
359
  children: jsx(IconComponent, {
361
360
  "data-testid": dataTestId ? `${dataTestId}-${name}` : name,
362
- className: `${iconSizeClassName} ${colorClassNames} ${className} ${name} aspect-square`,
361
+ className: `${iconSizeClassName} ${colorClassNames} ${className !== null && className !== void 0 ? className : ""} ${name} aspect-square`,
363
362
  style: fillColor ? Object.assign(Object.assign({}, style), {
364
363
  fill: fillColor
365
364
  }) : Object.assign({}, style)
@@ -714,7 +713,7 @@ const Alert = ({
714
713
  ref && ref.current && ref.current.scrollIntoView && ref.current.scrollIntoView();
715
714
  }
716
715
  }, [ref, autoScroll]);
717
- return jsxs(Container$8, Object.assign({
716
+ return jsxs(Container$7, Object.assign({
718
717
  "$color": color,
719
718
  className: className,
720
719
  "data-testid": dataTestId,
@@ -802,7 +801,7 @@ const getBackgroundColor = () => ({
802
801
  return colors[$color];
803
802
  };
804
803
 
805
- const Container$8 = tw.div`
804
+ const Container$7 = tw.div`
806
805
  tu-alert
807
806
  ${p => p.$inline ? tws`tu-alert--inline` : null}
808
807
  ${getBackgroundColor()}
@@ -1281,7 +1280,7 @@ const CardHeader = ({
1281
1280
  className: className,
1282
1281
  "$density": density
1283
1282
  }, {
1284
- children: jsxs(Container$7, {
1283
+ children: jsxs(Container$6, {
1285
1284
  children: [jsxs("div", {
1286
1285
  children: [jsxs(HeadingContainer$1, {
1287
1286
  children: [jsx(Heading$1, Object.assign({
@@ -1311,7 +1310,7 @@ const CardHeader = ({
1311
1310
  const BottomBorderedDensityContainer = twx(DensityContainer)`
1312
1311
  tu-card__header-density-container
1313
1312
  `;
1314
- const Container$7 = tw.div`
1313
+ const Container$6 = tw.div`
1315
1314
  tu-card__header
1316
1315
  `;
1317
1316
  const HeadingContainer$1 = tw.div`
@@ -1810,182 +1809,94 @@ const DateInput = forwardRef((_a, ref) => {
1810
1809
  }, rest));
1811
1810
  });
1812
1811
 
1813
- var PopoverLifecycle;
1814
-
1815
- (function (PopoverLifecycle) {
1816
- PopoverLifecycle["closed"] = "closed";
1817
- PopoverLifecycle["open"] = "open";
1818
- PopoverLifecycle["closing"] = "closing";
1819
- })(PopoverLifecycle || (PopoverLifecycle = {}));
1820
1812
  /**
1821
- * The usePopover Hook.
1822
- *
1823
- * @param {UsePopoverProps} props - The props for the usePopover hook
1824
- * @returns {UsePopoverProps} - UsePopoverProps
1813
+ * @param {PopoverProps} props The children to render in the popover
1814
+ * @returns {ReactElement} Popover with specified content and placement
1825
1815
  */
1826
1816
 
1827
-
1828
- const usePopover = ({
1829
- targetRef,
1830
- popoverRef,
1831
- placement = "auto",
1832
- offset = [0, 8]
1833
- }) => {
1834
- const [lifecycle, setLifecycle] = React.useState(PopoverLifecycle.closed);
1835
- const popperRef = React.useRef(null);
1836
- React.useLayoutEffect(() => {
1837
- if (targetRef.current && popoverRef.current) {
1838
- popperRef.current = createPopper(targetRef.current, popoverRef.current, {
1839
- placement,
1840
- strategy: "fixed",
1841
- modifiers: [{
1842
- name: "offset",
1843
- options: {
1844
- offset
1845
- }
1846
- }, {
1847
- name: "flip",
1848
- options: {
1849
- flipVariations: true
1850
- }
1851
- }]
1852
- });
1853
- }
1854
-
1855
- return () => {
1856
- var _a;
1857
-
1858
- (_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
1859
- };
1860
- }, [popoverRef, targetRef, lifecycle, placement, offset]);
1861
-
1862
- const onShow = () => {
1863
- if (lifecycle !== PopoverLifecycle.open) {
1864
- setLifecycle(PopoverLifecycle.open);
1865
- }
1866
- };
1867
-
1868
- const onHide = () => {
1869
- setLifecycle(PopoverLifecycle.closing);
1870
- };
1871
-
1872
- const onClosed = () => {
1873
- setLifecycle(PopoverLifecycle.closed);
1874
- };
1875
-
1876
- return {
1877
- targetRef,
1878
- popoverRef,
1879
- onShow,
1880
- onHide,
1881
- popoverProps: {
1882
- lifecycle,
1883
- onClosed
1884
- }
1885
- };
1886
- };
1887
-
1888
- /**
1889
- * The Popover component is used to display some content on top of another.
1890
- * Use a popover to expose a small amount of information or functionality.
1891
- *
1892
- * @param {AnimatedPopoverProps} props - The props for the Card component
1893
- * @returns {JSX.Element} Popover component
1894
- */
1895
-
1896
- const AnimatedPopover = React.forwardRef(({
1897
- lifecycle,
1898
- onRequestClose,
1817
+ const Popover = ({
1899
1818
  children,
1900
- onClosed,
1901
- enterDelay,
1902
- exitDelay,
1819
+ render,
1820
+ placement,
1821
+ activation = {
1822
+ click: true,
1823
+ hover: false
1824
+ },
1903
1825
  className,
1904
- dataTestId,
1905
- bindTo,
1906
- enableBackdrop = true
1907
- }, ref) => {
1826
+ dataTestId
1827
+ }) => {
1828
+ const [open, setOpen] = useState(false);
1908
1829
  const {
1909
- Portal
1910
- } = usePortal({
1911
- bindTo
1830
+ x,
1831
+ y,
1832
+ reference,
1833
+ floating,
1834
+ strategy,
1835
+ context
1836
+ } = useFloating({
1837
+ open,
1838
+ onOpenChange: setOpen,
1839
+ middleware: [offset(8), shift(), flip({
1840
+ crossAxis: true,
1841
+ fallbackPlacements: ["top", "bottom", "left", "right"]
1842
+ })],
1843
+ placement,
1844
+ whileElementsMounted: autoUpdate
1912
1845
  });
1913
-
1914
- const onClose = e => {
1915
- if (lifecycle === PopoverLifecycle.open) {
1916
- e.preventDefault();
1917
- e.stopPropagation();
1918
- onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
1919
- }
1920
- };
1921
-
1922
- useKeyPressEvent("Escape", onClose);
1923
-
1924
- if (lifecycle === PopoverLifecycle.closed) {
1925
- // eslint-disable-next-line react/jsx-no-useless-fragment
1926
- return jsx(Fragment, {});
1927
- }
1928
-
1929
- return jsxs(Portal, {
1930
- children: [lifecycle !== PopoverLifecycle.closing && enableBackdrop && jsx(Backdrop$1, {
1931
- onClick: onClose
1932
- }), jsx(StyledContainer, Object.assign({
1933
- ref: ref,
1934
- className: className,
1935
- "data-testid": dataTestId
1936
- }, {
1937
- children: jsx(AnimatedContainer, Object.assign({
1938
- lifecycle: lifecycle,
1939
- onClosed: onClosed,
1940
- enterDelay: enterDelay,
1941
- exitDelay: exitDelay
1846
+ const {
1847
+ getReferenceProps,
1848
+ getFloatingProps
1849
+ } = useInteractions([useClick(context, {
1850
+ enabled: activation.click,
1851
+ ignoreMouse: activation.hover
1852
+ }), useHover(context, {
1853
+ enabled: activation.hover
1854
+ }), useRole(context), useDismiss(context)]); // Preserve the consumer's ref
1855
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1856
+
1857
+ const ref = useMemo(() => mergeRefs([reference, children.ref]), [reference, children]);
1858
+ return jsxs(Fragment, {
1859
+ children: [cloneElement(children, getReferenceProps(Object.assign({
1860
+ ref
1861
+ }, children.props))), jsx(FloatingPortal, {
1862
+ children: open && jsx(FloatingFocusManager, Object.assign({
1863
+ context: context,
1864
+ modal: false,
1865
+ order: ["reference", "content"],
1866
+ returnFocus: false
1942
1867
  }, {
1943
- children: children
1868
+ children: jsx("div", Object.assign({
1869
+ ref: floating,
1870
+ className: `tu-popover-container animate-fade-in-fast ${className !== null && className !== void 0 ? className : ""}`,
1871
+ "data-testid": dataTestId,
1872
+ style: {
1873
+ position: strategy,
1874
+ top: y !== null && y !== void 0 ? y : 0,
1875
+ left: x !== null && x !== void 0 ? x : 0
1876
+ }
1877
+ }, getFloatingProps(), {
1878
+ children: render({
1879
+ close: () => {
1880
+ setOpen(false);
1881
+ }
1882
+ })
1883
+ }))
1944
1884
  }))
1945
- }))]
1946
- });
1947
- });
1948
- const Backdrop$1 = tw.div`
1949
- tu-popover-backdrop
1950
- `;
1951
-
1952
- const AnimatedContainer = ({
1953
- lifecycle,
1954
- onClosed,
1955
- enterDelay = 0,
1956
- exitDelay = 0,
1957
- children
1958
- }) => {
1959
- const props = useSpring({
1960
- config: {
1961
- tension: lifecycle === PopoverLifecycle.closing ? 2000 : 1500,
1962
- friction: 100,
1963
- precision: 0.1
1964
- },
1965
- from: {
1966
- opacity: 0,
1967
- transform: "scale(0.98)"
1968
- },
1969
- to: lifecycle === PopoverLifecycle.open ? {
1970
- opacity: 1,
1971
- transform: "scale(1)"
1972
- } : lifecycle === PopoverLifecycle.closing ? {
1973
- opacity: 0,
1974
- transform: "scale(0.98)"
1975
- } : {},
1976
- delay: lifecycle === PopoverLifecycle.open ? enterDelay : exitDelay,
1977
- onRest: () => lifecycle === PopoverLifecycle.closing && (onClosed === null || onClosed === void 0 ? void 0 : onClosed())
1885
+ })]
1978
1886
  });
1979
- return jsx(animated.div, Object.assign({
1980
- style: props
1981
- }, {
1982
- children: children
1983
- }));
1984
- };
1985
-
1986
- const StyledContainer = tw.div`
1987
- tu-popover-container
1988
- `;
1887
+ }; // Utility to merge refs — Heavily inspired by https://github.com/gregberge/react-merge-refs
1888
+
1889
+ function mergeRefs(refs) {
1890
+ return value => {
1891
+ refs.forEach(ref => {
1892
+ if (typeof ref === "function") {
1893
+ ref(value);
1894
+ } else if (ref !== null) {
1895
+ ref.current = value;
1896
+ }
1897
+ });
1898
+ };
1899
+ }
1989
1900
 
1990
1901
  /**
1991
1902
  * The PopoverList component.
@@ -2093,7 +2004,7 @@ const PopoverTitle = ({
2093
2004
  className,
2094
2005
  dataTestId
2095
2006
  }) => {
2096
- return jsxs(Container$6, Object.assign({
2007
+ return jsxs(Container$5, Object.assign({
2097
2008
  "$divider": divider,
2098
2009
  className: className,
2099
2010
  "data-testid": dataTestId
@@ -2109,7 +2020,7 @@ const PopoverTitle = ({
2109
2020
  })), action]
2110
2021
  }));
2111
2022
  };
2112
- const Container$6 = tw.div`
2023
+ const Container$5 = tw.div`
2113
2024
  tu-popover-title-container
2114
2025
  ${p => p.$divider && `tu-popover-title-container--divider`}
2115
2026
  `;
@@ -2124,65 +2035,65 @@ tu-popover-title-text
2124
2035
  * @returns {JSX.Element} Tooltip component
2125
2036
  */
2126
2037
 
2127
- const Tooltip = ({
2038
+ const Tooltip = _a => {
2039
+ var {
2040
+ children,
2041
+ dataTestId,
2042
+ disabled,
2043
+ className
2044
+ } = _a,
2045
+ rest = __rest(_a, ["children", "dataTestId", "disabled", "className"]);
2046
+
2047
+ const wrappedChildren = jsx(Flex$1, Object.assign({
2048
+ className: className,
2049
+ "data-testid": dataTestId && `${dataTestId}-parent`
2050
+ }, {
2051
+ children: children
2052
+ }));
2053
+
2054
+ if (disabled) {
2055
+ return wrappedChildren;
2056
+ }
2057
+
2058
+ return jsx(TooltipContainer, Object.assign({
2059
+ dataTestId: dataTestId
2060
+ }, rest, {
2061
+ children: wrappedChildren
2062
+ }));
2063
+ };
2064
+
2065
+ const TooltipContainer = ({
2128
2066
  label,
2129
2067
  placement = "bottom",
2130
- children,
2131
- dataTestId,
2132
- disabled,
2133
2068
  mode = "dark",
2134
- offset,
2135
- className,
2136
- contentTextType = "p"
2137
- }) => {
2138
- const target = React.useRef(null);
2139
- const popover = React.useRef(null);
2140
- const {
2141
- popoverRef,
2142
- targetRef,
2143
- onShow,
2144
- onHide,
2145
- popoverProps
2146
- } = usePopover({
2147
- targetRef: target,
2148
- popoverRef: popover,
2149
- placement,
2150
- offset
2151
- });
2152
- return jsxs(Fragment, {
2153
- children: [jsx(Flex$1, Object.assign({
2154
- className: className,
2155
- onMouseEnter: onShow,
2156
- onMouseLeave: onHide,
2157
- ref: targetRef,
2158
- "data-testid": dataTestId && `${dataTestId}-parent`
2159
- }, {
2160
- children: children
2161
- })), !disabled && jsx(Container$5, Object.assign({
2162
- ref: popoverRef,
2163
- onRequestClose: onHide,
2164
- enterDelay: 450
2165
- }, popoverProps, {
2166
- dataTestId: dataTestId,
2167
- enableBackdrop: false
2069
+ contentTextType = "p",
2070
+ children,
2071
+ dataTestId
2072
+ }) => jsx(StyledPopover, Object.assign({
2073
+ className: "tu-tooltip__container",
2074
+ placement: placement,
2075
+ activation: {
2076
+ hover: true
2077
+ },
2078
+ dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "",
2079
+ render: () => jsx(Content, Object.assign({
2080
+ "$mode": mode
2081
+ }, {
2082
+ children: jsx(Text$1, Object.assign({
2083
+ inverted: mode === "dark",
2084
+ type: contentTextType
2168
2085
  }, {
2169
- children: jsx(Content, Object.assign({
2170
- "$mode": mode
2171
- }, {
2172
- children: jsx(Text$1, Object.assign({
2173
- inverted: mode === "dark",
2174
- type: contentTextType
2175
- }, {
2176
- children: label
2177
- }))
2178
- }))
2179
- }))]
2180
- });
2181
- };
2086
+ children: label
2087
+ }))
2088
+ }))
2089
+ }, {
2090
+ children: children
2091
+ }));
2092
+
2182
2093
  const Flex$1 = tw.div`
2183
2094
  inline-flex
2184
2095
  `;
2185
- const Container$5 = twx(AnimatedPopover)`
2096
+ const StyledPopover = twx(Popover)`
2186
2097
  tu-tooltip__container
2187
2098
  `;
2188
2099
  const Content = tw.div`
@@ -2201,30 +2112,27 @@ const Content = tw.div`
2201
2112
  const Tip = ({
2202
2113
  children,
2203
2114
  iconProps,
2204
- tooltipProps,
2205
2115
  dataTestId,
2206
2116
  link,
2207
2117
  renderAs = "span",
2208
- className
2118
+ className,
2119
+ placement = "bottom",
2120
+ mode
2209
2121
  }) => {
2210
- var _a;
2211
-
2212
- const ifAnchorTag = () => {
2213
- return renderAs === "a";
2214
- };
2215
-
2122
+ const ifAnchorTag = renderAs === "a";
2216
2123
  return jsx(TipContainer, Object.assign({
2217
2124
  "data-testid": dataTestId,
2218
2125
  "$as": renderAs,
2219
- href: ifAnchorTag() ? link : undefined,
2220
- target: ifAnchorTag() ? "_blank" : undefined,
2126
+ href: ifAnchorTag ? link : undefined,
2127
+ target: ifAnchorTag ? "_blank" : undefined,
2221
2128
  className: className
2222
2129
  }, {
2223
2130
  children: jsx(Tooltip, Object.assign({
2224
2131
  label: children,
2225
- dataTestId: `${dataTestId}-tooltip`
2226
- }, tooltipProps, {
2227
- className: `${(_a = tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className) !== null && _a !== void 0 ? _a : ""} tu-tip-tooltip`
2132
+ dataTestId: `${dataTestId}-tooltip`,
2133
+ mode: mode,
2134
+ className: "tu-tip-tooltip",
2135
+ placement: placement
2228
2136
  }, {
2229
2137
  children: jsx(Icon$1, Object.assign({
2230
2138
  name: "QuestionMarkCircleIcon",
@@ -2264,7 +2172,7 @@ const FormGroup = ({
2264
2172
  }, {
2265
2173
  children: [jsxs(ContainerBefore, {
2266
2174
  children: [jsx(Label$2, Object.assign({
2267
- "data-testid": `${dataTestId}-label`
2175
+ dataTestId: `${dataTestId}-label`
2268
2176
  }, {
2269
2177
  children: label
2270
2178
  })), tip && jsx(Tip, Object.assign({
@@ -2391,23 +2299,27 @@ const useLocale = language => {
2391
2299
  * @returns {JSX.Element} DayPicker component
2392
2300
  */
2393
2301
 
2394
- const DayPicker = _a => {
2395
- var {
2396
- onDaySelect,
2397
- disabledDays,
2398
- selectedDays,
2399
- language
2400
- } = _a,
2401
- rest = __rest(_a, ["onDaySelect", "disabledDays", "selectedDays", "language"]);
2402
-
2302
+ const DayPicker = ({
2303
+ onDaySelect,
2304
+ disabledDays,
2305
+ selectedDays,
2306
+ language,
2307
+ className,
2308
+ dataTestId,
2309
+ max
2310
+ }) => {
2403
2311
  const locale = useLocale(language);
2404
- return jsx(DayPicker$1, Object.assign({
2312
+ return jsx(DayPicker$1, {
2405
2313
  onDayClick: onDaySelect,
2406
2314
  selected: selectedDays,
2407
2315
  locale: locale,
2408
2316
  disabled: disabledDays,
2409
- className: "custom-day-picker"
2410
- }, rest));
2317
+ className: `custom-day-picker ${className !== null && className !== void 0 ? className : ""}`,
2318
+ max: max,
2319
+ footer: jsx("div", {
2320
+ "data-testid": dataTestId
2321
+ })
2322
+ });
2411
2323
  };
2412
2324
 
2413
2325
  /**
@@ -2420,29 +2332,27 @@ const DayPicker = _a => {
2420
2332
  const DayPickerPopover = ({
2421
2333
  disabledDays,
2422
2334
  className,
2335
+ dataTestId,
2423
2336
  selectedDay,
2424
2337
  onDaySelect,
2425
2338
  color = "secondary",
2426
- placement = "bottom",
2339
+ placement,
2427
2340
  size = "small",
2428
2341
  buttonContent,
2429
2342
  language
2430
2343
  }) => {
2431
- const target = useRef(null);
2432
- const popover = useRef(null);
2433
- const {
2434
- popoverRef,
2435
- targetRef,
2436
- onShow,
2437
- onHide,
2438
- popoverProps
2439
- } = usePopover({
2440
- targetRef: target,
2441
- popoverRef: popover,
2442
- placement: placement
2443
- });
2444
- return jsxs(Fragment$1, {
2445
- children: [jsx(Button, Object.assign({
2344
+ return jsx(Popover, Object.assign({
2345
+ placement: placement,
2346
+ render: () => jsx(PopoverList, {
2347
+ children: jsx(DayPicker, {
2348
+ disabledDays: disabledDays,
2349
+ onDaySelect: onDaySelect,
2350
+ selectedDays: selectedDay,
2351
+ language: language
2352
+ })
2353
+ })
2354
+ }, {
2355
+ children: jsx(Button, Object.assign({
2446
2356
  color: color,
2447
2357
  size: size,
2448
2358
  className: className,
@@ -2450,29 +2360,11 @@ const DayPickerPopover = ({
2450
2360
  name: "CalendarIcon",
2451
2361
  size: "small"
2452
2362
  }),
2453
- ref: targetRef,
2454
- onClick: onShow
2363
+ dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker"
2455
2364
  }, {
2456
2365
  children: buttonContent
2457
- })), jsx(AnimatedPopover, Object.assign({
2458
- ref: popoverRef,
2459
- onRequestClose: () => {
2460
- var _a;
2461
-
2462
- onHide();
2463
- (_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
2464
- }
2465
- }, popoverProps, {
2466
- children: jsx(PopoverList, {
2467
- children: jsx(DayPicker, {
2468
- disabledDays: disabledDays,
2469
- onDaySelect: onDaySelect,
2470
- selectedDays: selectedDay,
2471
- language: language
2472
- })
2473
- })
2474
- }))]
2475
- });
2366
+ }))
2367
+ }));
2476
2368
  };
2477
2369
 
2478
2370
  /**
@@ -2488,6 +2380,7 @@ const DayRangePicker = ({
2488
2380
  disabledDays,
2489
2381
  dataTestId,
2490
2382
  language,
2383
+ className,
2491
2384
  max
2492
2385
  }) => {
2493
2386
  const locale = useLocale(language);
@@ -2505,20 +2398,19 @@ const DayRangePicker = ({
2505
2398
  });
2506
2399
  }
2507
2400
  }, [onRangeSelect]);
2508
- return jsx("div", Object.assign({
2509
- "data-testid": dataTestId
2510
- }, {
2511
- children: jsx(DayPicker$1, {
2512
- mode: "range",
2513
- onSelect: onSelect,
2514
- selected: selectedDays,
2515
- defaultMonth: selectedDays && selectedDays.from,
2516
- locale: locale,
2517
- disabled: disabledDays,
2518
- className: "custom-day-picker range-picker",
2519
- max: max
2401
+ return jsx(DayPicker$1, {
2402
+ mode: "range",
2403
+ onSelect: onSelect,
2404
+ selected: selectedDays,
2405
+ defaultMonth: selectedDays && selectedDays.from,
2406
+ locale: locale,
2407
+ disabled: disabledDays,
2408
+ className: `custom-day-picker range-picker ${className !== null && className !== void 0 ? className : ""}`,
2409
+ max: max,
2410
+ footer: jsx("div", {
2411
+ "data-testid": dataTestId
2520
2412
  })
2521
- }));
2413
+ });
2522
2414
  };
2523
2415
 
2524
2416
  /**
@@ -3276,10 +3168,12 @@ const SkeletonLines = memo(({
3276
3168
  style: {
3277
3169
  height: getHeight(i),
3278
3170
  width: getWidth(i),
3279
- margin: margin
3171
+ margin: lines > 1 ? margin : ""
3280
3172
  }
3281
3173
  }, {
3282
- children: "\u00A0"
3174
+ children: lines > 1 && jsx(Fragment, {
3175
+ children: "\u00A0"
3176
+ })
3283
3177
  }), i));
3284
3178
  } // eslint-disable-next-line react/jsx-no-useless-fragment
3285
3179
 
@@ -5540,4 +5434,4 @@ const Layout = tw.div`
5540
5434
  tu-layout-TwoColumnLayout
5541
5435
  `;
5542
5436
 
5543
- 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$1 as Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeader, Pagination, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, 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, usePopover, usePrompt, useTimeout };
5437
+ export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, 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, MultiSelectMenuItem, NumberField, NumberInput, PageHeader, Pagination, Popover, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, 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,24 +1,23 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.1-alpha-d61feec588.0",
3
+ "version": "0.0.1-alpha-a2aba2c20d.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
7
- "@trackunit/css-core": "0.0.1-alpha-d61feec588.0",
8
- "@trackunit/tailwind-styled-components": "0.0.1-alpha-d61feec588.0",
7
+ "@trackunit/css-core": "0.0.1-alpha-a2aba2c20d.0",
8
+ "@trackunit/tailwind-styled-components": "0.0.1-alpha-a2aba2c20d.0",
9
9
  "react": "17.0.2",
10
- "@trackunit/ui-design-tokens": "0.0.1-alpha-d61feec588.0",
10
+ "@trackunit/ui-design-tokens": "0.0.1-alpha-a2aba2c20d.0",
11
11
  "echarts-for-react": "^3.0.2",
12
12
  "echarts": "^5.4.0",
13
13
  "uuid": "^8.3.2",
14
14
  "react-use": "^17.4.0",
15
15
  "date-fns": "^2.29.3",
16
16
  "react-day-picker": "^8.3.0",
17
- "@trackunit/ui-icons": "0.0.1-alpha-d61feec588.0",
17
+ "@trackunit/ui-icons": "0.0.1-alpha-a2aba2c20d.0",
18
18
  "react-useportal": "1.0.17",
19
- "@react-spring/web": "9.5.4",
19
+ "@floating-ui/react-dom-interactions": "^0.10.1",
20
20
  "react-router-dom": "6.4.1",
21
- "@popperjs/core": "^2.11.6",
22
21
  "react-helmet": "^6.1.0",
23
22
  "react-select": "^5.4.0",
24
23
  "jest-canvas-mock": "^2.4.0"
@@ -1,43 +0,0 @@
1
- import * as React from "react";
2
- import { CommonProps } from "../../common/CommonProps";
3
- import { PopoverLifecycle } from "./usePopover";
4
- export interface AnimatedPopoverProps extends CommonProps {
5
- /**
6
- * Controls the lifecycle of the popover.
7
- */
8
- lifecycle: PopoverLifecycle;
9
- /**
10
- * Sets the popover to closing state.
11
- */
12
- onRequestClose: () => void;
13
- /**
14
- * Sets the popover to closed state.
15
- */
16
- onClosed: () => void;
17
- /**
18
- * Child nodes
19
- */
20
- children: React.ReactNode;
21
- /**
22
- * The delay(in seconds) for triggering the popover state when entering it.
23
- */
24
- enterDelay?: number;
25
- /**
26
- * The delay(in seconds) for triggering the popover state when exiting it.
27
- */
28
- exitDelay?: number;
29
- /** An element to use as the portal root for the popover component */
30
- bindTo?: HTMLElement;
31
- /**
32
- * Whether the popover should have a backdrop or not.
33
- */
34
- enableBackdrop?: boolean;
35
- }
36
- /**
37
- * The Popover component is used to display some content on top of another.
38
- * Use a popover to expose a small amount of information or functionality.
39
- *
40
- * @param {AnimatedPopoverProps} props - The props for the Card component
41
- * @returns {JSX.Element} Popover component
42
- */
43
- export declare const AnimatedPopover: React.ForwardRefExoticComponent<AnimatedPopoverProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,42 +0,0 @@
1
- import { Placement } from "@popperjs/core";
2
- import * as React from "react";
3
- export declare type PopoverPlacement = Placement;
4
- export interface UsePopoverProps<T, Y> {
5
- /**
6
- * Reference to the target component.
7
- */
8
- targetRef: React.RefObject<T>;
9
- /**
10
- * Reference to the popover component.
11
- */
12
- popoverRef: React.RefObject<Y>;
13
- /**
14
- * Placement of the popover.
15
- */
16
- placement?: PopoverPlacement;
17
- /**
18
- * The positional offset of the popover from the target component.
19
- */
20
- offset?: [number, number];
21
- }
22
- export declare enum PopoverLifecycle {
23
- closed = "closed",
24
- open = "open",
25
- closing = "closing"
26
- }
27
- /**
28
- * The usePopover Hook.
29
- *
30
- * @param {UsePopoverProps} props - The props for the usePopover hook
31
- * @returns {UsePopoverProps} - UsePopoverProps
32
- */
33
- export declare const usePopover: <T extends HTMLElement, Y extends HTMLElement>({ targetRef, popoverRef, placement, offset, }: UsePopoverProps<T, Y>) => {
34
- targetRef: React.RefObject<T>;
35
- popoverRef: React.RefObject<Y>;
36
- onShow: () => void;
37
- onHide: () => void;
38
- popoverProps: {
39
- lifecycle: PopoverLifecycle;
40
- onClosed: () => void;
41
- };
42
- };