@trackunit/react-components 0.1.58 → 0.1.61

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.js CHANGED
@@ -3,7 +3,6 @@ import { tw, tws, twx } from '@trackunit/tailwind-styled-components';
3
3
  import * as React from 'react';
4
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
- import EChart from 'echarts-for-react';
7
6
  import { useMeasure, useCopyToClipboard } from 'react-use';
8
7
  import { format, formatDistance } from 'date-fns';
9
8
  import { useFloating, offset, flip, size, shift, autoUpdate, useInteractions, useClick, useHover, useRole, useDismiss, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
@@ -293,7 +292,7 @@ const Root$9 = tw.span `
293
292
  * @param {ActionButtonProps} props - The props for the ActionButton component
294
293
  * @returns {JSX.Element} ActionButton component
295
294
  */
296
- const ActionButton = ({ type, value, dataTestId, iconSize }) => {
295
+ const ActionButton = ({ type, value, dataTestId, iconSize, disabled }) => {
297
296
  const getIconName = () => {
298
297
  switch (type) {
299
298
  case "PHONE_NUMBER":
@@ -319,7 +318,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize }) => {
319
318
  return window.open(`tel:${value}`);
320
319
  }
321
320
  };
322
- return (jsx(ActionContainer, { children: jsx(StyledIconButton, { "$fieldSize": iconSize, dataTestId: dataTestId || "testIconButtonId", size: "small", color: "tertiary", icon: jsx(Icon, { size: "small", name: getIconName() }), onClick: ButtonAction }) }));
321
+ return (jsx(ActionContainer, { children: jsx(StyledIconButton, { "$fieldSize": iconSize, disabled: disabled, dataTestId: dataTestId || "testIconButtonId", size: "small", color: "tertiary", icon: jsx(Icon, { size: "small", name: getIconName() }), onClick: ButtonAction }) }));
323
322
  };
324
323
  const ActionContainer = tw.div `
325
324
  tu-action-container
@@ -717,62 +716,6 @@ const HeadingContainer$1 = tw.div `
717
716
  tu-card__header-heading-container
718
717
  `;
719
718
 
720
- /**
721
- * The Chart component is a wrapper component for ECharts.
722
- *
723
- * Handles events and click functionality.
724
- *
725
- * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
726
- *
727
- * @param {ChartProps} props - The props for the Chart component
728
- * @returns {JSX.Element} Chart component
729
- */
730
- const Chart = ({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart, merge = true, loadingOption, timezoneLabel, renderer = "canvas", dataTestId, }) => {
731
- var _a, _b;
732
- const echartsRef = React.useRef(null);
733
- const eventHandlers = React.useMemo(() => {
734
- const values = {};
735
- if (onDataZoom !== undefined) {
736
- values.dataZoom = onDataZoom;
737
- }
738
- if (onBrush !== undefined) {
739
- values.brush = onBrush;
740
- }
741
- if (onBrushSelected !== undefined) {
742
- values.brushSelected = onBrushSelected;
743
- }
744
- if (mouseLeaveChart !== undefined) {
745
- values.globalout = mouseLeaveChart;
746
- }
747
- if (mouseMoveChart !== undefined) {
748
- values.mouseMove = (event) => {
749
- var _a;
750
- mouseMoveChart(event, (_a = echartsRef === null || echartsRef === void 0 ? void 0 : echartsRef.current) === null || _a === void 0 ? void 0 : _a.getEchartsInstance());
751
- };
752
- }
753
- return values;
754
- }, [onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, mouseMoveChart]);
755
- React.useEffect(() => {
756
- var _a;
757
- const instance = (_a = echartsRef === null || echartsRef === void 0 ? void 0 : echartsRef.current) === null || _a === void 0 ? void 0 : _a.getEchartsInstance();
758
- if (instance && onClick) {
759
- instance.on("click", onClick);
760
- }
761
- return () => {
762
- if (instance && !instance.isDisposed()) {
763
- instance.off("click", onClick);
764
- }
765
- };
766
- }, [onClick, echartsRef]);
767
- return (jsx(ChartContainer, Object.assign({ style: { height: (_a = style === null || style === void 0 ? void 0 : style.height) !== null && _a !== void 0 ? _a : "300px", width: (_b = style === null || style === void 0 ? void 0 : style.width) !== null && _b !== void 0 ? _b : "100%" }, "data-testid": dataTestId }, { children: showLoading ? (jsxs(SpinnerContainer, { children: [jsx(Spinner, { centering: "centered" }), (loadingOption === null || loadingOption === void 0 ? void 0 : loadingOption.text) && (jsx(Text$1, Object.assign({ align: "center", subtle: true }, { children: loadingOption.text })))] })) : (jsxs(Fragment, { children: [jsx(EChart, { ref: echartsRef, option: options, opts: { width: "auto", height: "auto", renderer: renderer }, notMerge: !merge, onEvents: eventHandlers, className: className, style: style, onChartReady: onChartReady }), timezoneLabel] })) })));
768
- };
769
- const SpinnerContainer = tw.div `
770
- tu-chart-spinner-container
771
- `;
772
- const ChartContainer = tw.div `
773
- tu-chart-container
774
- `;
775
-
776
719
  /**
777
720
  * The Label component is used for labels for input fields.
778
721
  * This component is **not used directly**, but is part of the FormGroup and Field components.
@@ -1257,6 +1200,66 @@ const Overlay = tw.div `
1257
1200
  ${({ $open }) => $open && tws `tu-drawer__overlay--open`}
1258
1201
  `;
1259
1202
 
1203
+ /**
1204
+ * The Drop Zone can be used to drag and drop files
1205
+ *
1206
+ * @param {DropZoneProps} props - The props for the DropZone component
1207
+ * @returns {JSX.Element} DropZone component
1208
+ */
1209
+ const DropZone = (_a) => {
1210
+ var { className, dataTestId, filesSelected, label, size = "large", isInvalid = false, disabled = false } = _a, rest = __rest(_a, ["className", "dataTestId", "filesSelected", "label", "size", "isInvalid", "disabled"]);
1211
+ const [dragActive, setDragActive] = React__default.useState(false);
1212
+ const [fileDropped, setFileDropped] = React__default.useState(false);
1213
+ // function that handles drag enter, drag leave and drag over
1214
+ const handleDrag = (e) => {
1215
+ e.preventDefault();
1216
+ e.stopPropagation();
1217
+ if ((e.type === "dragenter" || e.type === "dragover") && !disabled) {
1218
+ setDragActive(true);
1219
+ }
1220
+ else if (e.type === "dragleave") {
1221
+ setDragActive(false);
1222
+ }
1223
+ };
1224
+ //function to handle when user clicks on dropzone to upload
1225
+ const handleChange = (e) => {
1226
+ e.preventDefault();
1227
+ e.stopPropagation();
1228
+ if (e.target.files && !disabled) {
1229
+ filesSelected(e.target.files);
1230
+ }
1231
+ };
1232
+ //funtion to handle drop
1233
+ const handleDrop = (e) => {
1234
+ e.preventDefault();
1235
+ e.stopPropagation();
1236
+ setDragActive(false);
1237
+ if (e.dataTransfer.files && e.dataTransfer.files[0] && !disabled) {
1238
+ filesSelected(e.dataTransfer.files);
1239
+ setFileDropped(true);
1240
+ }
1241
+ };
1242
+ return (jsxs(Root$5, Object.assign({ "$disabled": disabled, "$isInvalid": isInvalid, "$dragActive": dragActive, "$fileDropped": fileDropped, "$size": size, className: className, "data-testid": dataTestId, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop, onClick: e => {
1243
+ if (disabled) {
1244
+ e.preventDefault();
1245
+ e.stopPropagation();
1246
+ }
1247
+ } }, rest, { children: [jsx("input", { title: "Hidden File Input", type: "file", id: "input-file-upload", onChange: handleChange, className: "hidden" }), jsxs(DropZoneLabel, Object.assign({ htmlFor: "input-file-upload", "data-testid": dataTestId && `${dataTestId}-label` }, { children: [jsx(Icon, { type: "solid", name: "ArrowUpCircleIcon", color: isInvalid ? "danger" : "neutral", style: !isInvalid ? { color: "rgb(156 163 175)" } : {} }), jsx("span", { children: label })] }))] })));
1248
+ };
1249
+ const Root$5 = tw.div `
1250
+ tu-drop-zone
1251
+ ${({ $size }) => ($size === "small" ? tws `tu-drop-zone--small` : null)}
1252
+ ${({ $size }) => ($size === "medium" ? tws `tu-drop-zone--medium` : null)}
1253
+ ${({ $size }) => ($size === "large" ? tws `tu-drop-zone--large` : null)}
1254
+ ${({ $dragActive }) => ($dragActive ? tws `tu-drop-zone--drag-active` : null)}
1255
+ ${({ $fileDropped }) => ($fileDropped ? tws `tu-drop-zone--drop-complete` : null)}
1256
+ ${({ $isInvalid }) => ($isInvalid ? tws `tu-drop-zone--invalid` : null)}
1257
+ ${({ $disabled }) => ($disabled ? tws `tu-drop-zone--disabled` : null)}
1258
+ `;
1259
+ const DropZoneLabel = tw.label `
1260
+ tu-drop-zone__label
1261
+ `;
1262
+
1260
1263
  /**
1261
1264
  * A Email Input component is used for input of the type Email.
1262
1265
  *
@@ -1268,12 +1271,29 @@ const Overlay = tw.div `
1268
1271
  * For specific input types make sure to use the corresponding input component.
1269
1272
  */
1270
1273
  const EmailInput = React.forwardRef((_a, ref) => {
1271
- var { fieldSize = "medium", disableAction = false, dataTestId } = _a, rest = __rest(_a, ["fieldSize", "disableAction", "dataTestId"]);
1274
+ var { fieldSize = "medium", disabled = false, dataTestId } = _a, rest = __rest(_a, ["fieldSize", "disabled", "dataTestId"]);
1272
1275
  const [email, setEmail] = React.useState("");
1273
1276
  const sendEmail = () => {
1274
1277
  return window.open(`mailto:${email}`);
1275
1278
  };
1276
- return (jsx(BaseInput, Object.assign({ dataTestId: dataTestId, fieldSize: fieldSize, ref: ref, type: "email", placeholder: rest.placeholder || "mail@example.com", onChange: e => setEmail(e.target.value) }, rest, { actions: !disableAction && (jsx(ActionButton, { value: email, type: "EMAIL", onClick: sendEmail, dataTestId: dataTestId && `${dataTestId}-emailIcon`, iconSize: fieldSize })) })));
1279
+ return (jsx(BaseInput, Object.assign({ dataTestId: dataTestId, fieldSize: fieldSize, ref: ref, type: "email", placeholder: rest.placeholder || "mail@example.com", onChange: e => setEmail(e.target.value) }, rest, { actions: jsx(ActionButton, { disabled: disabled, value: email, type: "EMAIL", onClick: sendEmail, dataTestId: dataTestId && `${dataTestId}-emailIcon`, iconSize: fieldSize }) })));
1280
+ });
1281
+
1282
+ /**
1283
+ * The EmailField component is used to enter email.
1284
+ * EmailField validates that user enters a valid email address.
1285
+ *
1286
+ */
1287
+ const EmailField = forwardRef((_a, ref) => {
1288
+ var { label, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
1289
+ const [value, setValue] = useState(defaultValue);
1290
+ // Type guard to check if value is a string
1291
+ function isString(inputValue) {
1292
+ return typeof inputValue === "string";
1293
+ }
1294
+ // Check the regular expression only if value is a string
1295
+ const renderAsInvalid = !!errorMessage || (isString(value) && !/^\S+@\S+\.\S+$/.test(value));
1296
+ return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(EmailInput, Object.assign({ ref: ref, value: value, onChange: e => setValue(e.target.value), isInvalid: renderAsInvalid, disabled: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1277
1297
  });
1278
1298
 
1279
1299
  /**
@@ -1298,7 +1318,7 @@ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className,
1298
1318
  * @param {IndicatorProps} props - The props for the Indicator component
1299
1319
  * @returns {JSX.Element} Indicator component
1300
1320
  */
1301
- const Indicator$1 = (_a) => {
1321
+ const Indicator = (_a) => {
1302
1322
  var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping"]);
1303
1323
  return (jsxs(Container$4, Object.assign({ "$color": color, "data-testid": dataTestId }, rest, { title: !withLabel ? label : undefined }, { children: [jsxs(IconBackground, Object.assign({ "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", "$withBackground": withBackground }, { children: [ping && jsx(Ping, { "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" }), icon] })), label !== undefined && withLabel && (jsx(Label$1, Object.assign({ "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label" }, { children: label })))] })));
1304
1324
  };
@@ -1377,37 +1397,6 @@ const Ping = tw.span `
1377
1397
  tu-indicator__ping
1378
1398
  `;
1379
1399
 
1380
- /**
1381
- * The LegendItem component is used to show form legends.
1382
- *
1383
- * @param {ILegendItem} props - The props for the LegendItem component
1384
- * @returns {JSX.Element} LegendItem component
1385
- */
1386
- const LegendItem = ({ className, label, disabled, selected, onClick, color, dataTestId }) => {
1387
- const handleOnClick = onClick && !disabled ? () => onClick() : undefined;
1388
- return (jsxs(Root$5, Object.assign({ "data-testid": dataTestId, "$disabled": disabled, className: className, "$selected": selected, onClick: handleOnClick }, { children: [jsx(Indicator, { style: { backgroundColor: color }, "$selected": selected }), label && jsx("p", { children: label })] })));
1389
- };
1390
- const Root$5 = tw.div `
1391
- inline-flex
1392
- items-center
1393
- transition-all
1394
- ease-in-out
1395
- duration-200
1396
- text-neutral-500
1397
- hover:text-neutral-700
1398
- text-sm
1399
- gap-2
1400
- ${p => (p.$disabled ? tws `text-neutral-300` : p.$selected ? tws `text-black` : "")}
1401
- ${p => (p.$selected ? tws `font-medium` : null)}
1402
- ${p => (p.onClick ? tws `cursor-pointer` : tws `cursor-default`)}
1403
- `;
1404
- const Indicator = tw.div `
1405
- w-3
1406
- h-3
1407
- rounded-[50%]
1408
- ${p => (p.$selected ? tws `border border-black border-opacity-50` : null)}
1409
- `;
1410
-
1411
1400
  /**
1412
1401
  * The MenuItem component is used to display a menu, primarily meant to be used in a list form.
1413
1402
  *
@@ -1723,7 +1712,7 @@ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, page
1723
1712
  useEffect(() => {
1724
1713
  if (pageIndex !== undefined && (isNaN(pageIndex) || pageIndex < 0)) {
1725
1714
  setPage(pageIndex);
1726
- pageIndex !== undefined && setCurrentPage(String(pageIndex + 1));
1715
+ setCurrentPage(String(pageIndex + 1));
1727
1716
  }
1728
1717
  }, [pageIndex, setPage, setCurrentPage, pageCount]);
1729
1718
  const handlePageChange = useCallback((action) => {
@@ -1781,72 +1770,6 @@ const PhoneInput = React.forwardRef((_a, ref) => {
1781
1770
  return (jsx(BaseInput, Object.assign({ ref: ref, dataTestId: dataTestId, fieldSize: fieldSize, type: "tel", onChange: e => setPhoneNumber(e.target.value), actions: !disableAction && (jsx(ActionButton, { value: phoneNumber, type: "PHONE_NUMBER", onClick: callNumber, dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest)));
1782
1771
  });
1783
1772
 
1784
- /**
1785
- * Create a PieChart with legends based on our current Chart component
1786
- *
1787
- * @param {PieChartProps} props - The props for the Chart component
1788
- * @returns {JSX.Element} Chart component
1789
- */
1790
- const PieChart = ({ data, size = "full", loading, onClick, className, dataTestId, }) => (jsxs(ChartRoot, Object.assign({ className: className, "data-testid": dataTestId }, { children: [jsx("div", { children: size === "full" && (jsx("div", Object.assign({ className: "flex flex-col", "data-testid": "legend" }, { children: data === null || data === void 0 ? void 0 : data.map(item => (jsx(LegendItem, { dataTestId: `legend-${item.id}`, label: (item === null || item === void 0 ? void 0 : item.count) !== undefined ? `${item.name} (${item.count})` : item.name, onClick: onClick ? () => onClick(item) : undefined, selected: item.selected, color: item.color }, item.id))) }))) }), jsx(Chart, { showLoading: loading, style: size === "full" ? { height: 110, width: 110 } : { height: 60, width: 60 }, onClick: evt => {
1791
- const clickedEntry = data === null || data === void 0 ? void 0 : data.find(x => x.id === evt.data.id);
1792
- if (onClick && clickedEntry) {
1793
- onClick(clickedEntry);
1794
- }
1795
- }, options: {
1796
- legend: {
1797
- show: false,
1798
- },
1799
- tooltip: {
1800
- show: false,
1801
- },
1802
- series: [
1803
- {
1804
- type: "pie",
1805
- radius: ["50%", "75%"],
1806
- center: ["50%", "50%"],
1807
- minAngle: 10,
1808
- selectedOffset: 8,
1809
- itemStyle: {
1810
- borderColor: "#ffffff",
1811
- borderWidth: 2,
1812
- },
1813
- avoidLabelOverlap: false,
1814
- label: {
1815
- show: false,
1816
- position: "center",
1817
- fontSize: "18",
1818
- fontWeight: "bold",
1819
- },
1820
- emphasis: {
1821
- label: {
1822
- show: true,
1823
- formatter: "{c}",
1824
- },
1825
- },
1826
- labelLine: {
1827
- show: false,
1828
- },
1829
- data: data === null || data === void 0 ? void 0 : data.map(item => {
1830
- var _a;
1831
- return ({
1832
- id: item.id,
1833
- name: item.name,
1834
- value: (_a = item === null || item === void 0 ? void 0 : item.count) !== null && _a !== void 0 ? _a : 0,
1835
- itemStyle: { color: item.color },
1836
- });
1837
- }),
1838
- },
1839
- ],
1840
- } })] })));
1841
- const ChartRoot = tw.div `
1842
- flex
1843
- flex-direction-col
1844
- flex-wrap-reverse
1845
- justify-between
1846
- items-center
1847
- h-full
1848
- `;
1849
-
1850
1773
  function useConfirmExit(confirmExit, when = true) {
1851
1774
  const { navigator } = useContext(UNSAFE_NavigationContext);
1852
1775
  useEffect(() => {
@@ -2658,7 +2581,7 @@ const Timeline = ({ className, dataTestId, children }) => {
2658
2581
  * @param {TimeLineElementProps} props the props
2659
2582
  * @returns {JSX.Element} component
2660
2583
  */
2661
- const TimelineElement = ({ date, children, className, dataTestId = "timeline-date", dot = jsx(Indicator$1, { className: tws `mt-[-1px]`, color: "neutral", icon: jsx(Icon, { name: "CalendarIcon", size: "large" }) }), header = `${format(date, "MMM d, yyyy")} (${formatDistance(date, new Date(), { addSuffix: true })})`, onClick, }) => {
2584
+ const TimelineElement = ({ date, children, className, dataTestId = "timeline-date", dot = jsx(Indicator, { className: tws `mt-[-1px]`, color: "neutral", icon: jsx(Icon, { name: "CalendarIcon", size: "large" }) }), header = `${format(date, "MMM d, yyyy")} (${formatDistance(date, new Date(), { addSuffix: true })})`, onClick, }) => {
2662
2585
  var _a;
2663
2586
  return (jsxs("li", Object.assign({ className: `${tws `tu-timeline-element`}${(_a = " " + className) !== null && _a !== void 0 ? _a : ""} `, "data-date": `${date}`, "data-testid": dataTestId && `${dataTestId}`, onClick: () => onClick && onClick() }, { children: [jsx("div", Object.assign({ className: tws `tu-timeline-element__dot` }, { children: dot })), jsx("div", { children: header }), jsx("div", {}), jsx("div", { children: jsx("div", { children: children }) })] })));
2664
2587
  };
@@ -3162,4 +3085,4 @@ const Layout = tw.div `
3162
3085
  tu-layout-TwoColumnLayout
3163
3086
  `;
3164
3087
 
3165
- export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, ContentGridArea, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, EmailInput, ExternalLink, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MoreMenu, MultiSelectMenuItem, NavGridArea, NumberField, NumberInput, PageHeader, Pagination, PhoneInput, PieChart, Popover, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Search, SectionHeader, Select, SelectPrefix, Sidebar, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleGridArea, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, UploadField, UploadInput, ValueBar, docs, getDevicePixelRatio, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useDevicePixelRatio, useLocalStorage, useModal, usePrompt, useTimeout };
3088
+ export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Checkbox, Collapse, ContentGridArea, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, DropZone, EmailField, EmailInput, ExternalLink, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon, IconButton, Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MoreMenu, MultiSelectMenuItem, NavGridArea, NumberField, NumberInput, PageHeader, Pagination, PhoneInput, Popover, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Search, SectionHeader, Select, SelectPrefix, Sidebar, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleGridArea, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, UploadField, UploadInput, ValueBar, docs, getDevicePixelRatio, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useDevicePixelRatio, useLocalStorage, useModal, usePrompt, useTimeout };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.58",
3
+ "version": "0.1.61",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
@@ -8,8 +8,6 @@
8
8
  "@trackunit/tailwind-styled-components": "0.0.54",
9
9
  "react": "18.2.0",
10
10
  "@trackunit/ui-design-tokens": "0.0.60",
11
- "echarts": "5.4.0",
12
- "echarts-for-react": "3.0.2",
13
11
  "react-use": "17.4.0",
14
12
  "date-fns": "2.29.3",
15
13
  "react-day-picker": "8.3.7",
@@ -1,8 +1,9 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps } from "../../common";
3
+ import { ButtonCommonProps } from "../buttons";
3
4
  type ActionType = "PHONE_NUMBER" | "WEB_ADDRESS" | "EMAIL";
4
5
  type FieldSize = "small" | "medium";
5
- interface ActionButtonProps extends CommonProps {
6
+ interface ActionButtonProps extends ButtonCommonProps, CommonProps {
6
7
  /**
7
8
  * The type of action performed when clicking the button.
8
9
  */
@@ -26,5 +27,5 @@ interface ActionButtonProps extends CommonProps {
26
27
  * @param {ActionButtonProps} props - The props for the ActionButton component
27
28
  * @returns {JSX.Element} ActionButton component
28
29
  */
29
- export declare const ActionButton: ({ type, value, dataTestId, iconSize }: ActionButtonProps) => JSX.Element;
30
+ export declare const ActionButton: ({ type, value, dataTestId, iconSize, disabled }: ActionButtonProps) => JSX.Element;
30
31
  export {};
@@ -0,0 +1,34 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps, Size } from "../../common";
3
+ import { BaseInputProps } from "../BaseInput";
4
+ type BaseInputExposedProps = Omit<BaseInputProps, "type" | "suffix" | "prefix" | "addonAfter" | "addonBefore" | "actions" | "placeholder" | "fieldSize" | "size" | "nonInteractive">;
5
+ export interface DropZoneProps extends BaseInputExposedProps, CommonProps {
6
+ /**
7
+ * A string to set the label in Drop Zone.
8
+ */
9
+ label: string;
10
+ /**
11
+ * A flag to disable the drop zone.
12
+ */
13
+ disabled?: boolean;
14
+ /**
15
+ * The size of the dropZone
16
+ * small - padding:8px, medium - padding:16px large - padding:32px
17
+ */
18
+ size?: Size;
19
+ /**
20
+ * The files dropped can be accessed within filesSelected
21
+ *
22
+ * @param file
23
+ * @returns
24
+ */
25
+ filesSelected: (file: FileList) => void;
26
+ }
27
+ /**
28
+ * The Drop Zone can be used to drag and drop files
29
+ *
30
+ * @param {DropZoneProps} props - The props for the DropZone component
31
+ * @returns {JSX.Element} DropZone component
32
+ */
33
+ export declare const DropZone: ({ className, dataTestId, filesSelected, label, size, isInvalid, disabled, ...rest }: DropZoneProps) => JSX.Element;
34
+ export {};
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { BaseInputProps } from "../BaseInput";
3
+ import { FormGroupProps } from "../FormGroup/FormGroup";
4
+ type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
5
+ export interface EmailFieldProps extends FormGroupExposedProps, BaseInputProps {
6
+ /**
7
+ * If a value is set, the field is rendered in its invalid state.
8
+ */
9
+ errorMessage?: string;
10
+ }
11
+ /**
12
+ * The EmailField component is used to enter email.
13
+ * EmailField validates that user enters a valid email address.
14
+ *
15
+ */
16
+ export declare const EmailField: import("react").ForwardRefExoticComponent<EmailFieldProps & import("react").RefAttributes<HTMLInputElement>>;
17
+ export {};
@@ -1,12 +1,5 @@
1
1
  import * as React from "react";
2
- import { CommonProps } from "../../common";
3
2
  import { BaseInputProps } from "../BaseInput";
4
- export interface EmailInputProps extends BaseInputProps, CommonProps {
5
- /**
6
- * A flag to disable the email button.
7
- */
8
- disableAction?: boolean;
9
- }
10
3
  /**
11
4
  * A Email Input component is used for input of the type Email.
12
5
  *
@@ -17,4 +10,4 @@ export interface EmailInputProps extends BaseInputProps, CommonProps {
17
10
  * A reference to the input element is provided as the `ref` prop.
18
11
  * For specific input types make sure to use the corresponding input component.
19
12
  */
20
- export declare const EmailInput: React.ForwardRefExoticComponent<EmailInputProps & React.RefAttributes<HTMLInputElement>>;
13
+ export declare const EmailInput: React.ForwardRefExoticComponent<BaseInputProps & React.RefAttributes<HTMLInputElement>>;
@@ -4,7 +4,6 @@ export * from "./Badge";
4
4
  export * from "./BaseInput";
5
5
  export * from "./buttons";
6
6
  export * from "./Card";
7
- export * from "./Chart";
8
7
  export * from "./Checkbox";
9
8
  export * from "./Collapse";
10
9
  export * from "./CopyableText";
@@ -12,6 +11,8 @@ export * from "./DateField/DateField";
12
11
  export * from "./DateInput/DateInput";
13
12
  export * from "./DayPicker";
14
13
  export * from "./Drawer/Drawer";
14
+ export * from "./DropZone/DropZone";
15
+ export * from "./EmailField/EmailField";
15
16
  export * from "./EmailInput";
16
17
  export * from "./ExternalLink/ExternalLink";
17
18
  export * from "./FormGroup/FormGroup";
@@ -19,7 +20,6 @@ export * from "./Heading";
19
20
  export * from "./Icon/Icon";
20
21
  export * from "./Indicator";
21
22
  export * from "./Label";
22
- export * from "./LegendItem";
23
23
  export * from "./Menu";
24
24
  export * from "./Modal";
25
25
  export * from "./NumberField/NumberField";
@@ -27,7 +27,6 @@ export * from "./NumberInput/NumberInput";
27
27
  export * from "./PageHeader";
28
28
  export * from "./Pagination/Pagination";
29
29
  export * from "./PhoneInput";
30
- export * from "./PieChart";
31
30
  export * from "./Popover";
32
31
  export * from "./Popover/Popover";
33
32
  export * from "./Prompt";
@@ -1,81 +0,0 @@
1
- import { EChartsType } from "echarts";
2
- import * as React from "react";
3
- import { CommonProps } from "../../common";
4
- export interface IOptionsType {
5
- [key: string]: any;
6
- }
7
- export interface ChartProps extends CommonProps {
8
- /**
9
- * Option values for EChart.
10
- */
11
- options: IOptionsType;
12
- /**
13
- * Whether or not to low the preloader.
14
- */
15
- showLoading?: boolean;
16
- /**
17
- * onClick event.
18
- */
19
- onClick?: (event: any) => void;
20
- /**
21
- * onDataZoom event.
22
- */
23
- onDataZoom?: (event: any) => void;
24
- /**
25
- * onBrush event.
26
- */
27
- onBrush?: (event: any) => void;
28
- /**
29
- * Event fired when brush is selected.
30
- */
31
- onBrushSelected?: (event: any) => void;
32
- /**
33
- * Event fired when mouse leaves the chart.
34
- */
35
- mouseLeaveChart?: () => void;
36
- /**
37
- * Event fired when mouse is moving over the chart.
38
- */
39
- mouseMoveChart?: (event: any, chart: EChartsType | undefined) => void;
40
- /**
41
- * CSS styles for the chart.
42
- */
43
- style?: Record<string, string | number>;
44
- /**
45
- * To denote of chart is ready or not.
46
- */
47
- onChartReady?: (chart: any) => void;
48
- /**
49
- * Whether to merge with previous option.
50
- */
51
- merge?: boolean;
52
- /**
53
- * Values for the loading component.
54
- */
55
- loadingOption?: {
56
- text: string;
57
- };
58
- /**
59
- * Time-zone label.
60
- */
61
- timezoneLabel?: React.ReactNode;
62
- /**
63
- * Type of rendered used. Either "svg" or "canvas".
64
- */
65
- renderer?: "svg" | "canvas";
66
- /**
67
- * Value used to find element by `data-testid` attribute.
68
- */
69
- dataTestId?: string;
70
- }
71
- /**
72
- * The Chart component is a wrapper component for ECharts.
73
- *
74
- * Handles events and click functionality.
75
- *
76
- * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
77
- *
78
- * @param {ChartProps} props - The props for the Chart component
79
- * @returns {JSX.Element} Chart component
80
- */
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 +0,0 @@
1
- export * from "./Chart";
@@ -1,17 +0,0 @@
1
- /// <reference types="react" />
2
- export interface ILegendItem {
3
- label?: string;
4
- selected?: boolean;
5
- disabled?: boolean;
6
- onClick?: () => void;
7
- color: string;
8
- className?: string;
9
- dataTestId?: string;
10
- }
11
- /**
12
- * The LegendItem component is used to show form legends.
13
- *
14
- * @param {ILegendItem} props - The props for the LegendItem component
15
- * @returns {JSX.Element} LegendItem component
16
- */
17
- export declare const LegendItem: ({ className, label, disabled, selected, onClick, color, dataTestId }: ILegendItem) => JSX.Element;
@@ -1 +0,0 @@
1
- export * from "./LegendItem";
@@ -1,55 +0,0 @@
1
- /// <reference types="react" />
2
- import { CommonProps } from "../../common/CommonProps";
3
- 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 {};
@@ -1 +0,0 @@
1
- export * from "./PieChart";