@trackunit/react-components 0.1.47 → 0.1.51

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
@@ -2698,6 +2698,34 @@ tu-toggle__description
2698
2698
  ${({ $disabled }) => $disabled && tws `tu-toggle__description--disabled`}
2699
2699
  `;
2700
2700
 
2701
+ /**
2702
+ * A thin wrapper around the `BaseInput` component for upload input fields.
2703
+ *
2704
+ * NOTE: If shown with a label, please use the `UploadField` component instead.
2705
+ */
2706
+ const UploadInput = forwardRef((_a, ref) => {
2707
+ var { disabled, acceptedTypes, nonInteractive, uploadLabel, multipleFiles } = _a, rest = __rest(_a, ["disabled", "acceptedTypes", "nonInteractive", "uploadLabel", "multipleFiles"]);
2708
+ return (jsx(UploadInputContainer, { children: jsx(BaseInput, Object.assign({ addonBefore: uploadLabel, ref: ref, disabled: disabled, accept: acceptedTypes, multiple: multipleFiles, type: "file", nonInteractive: nonInteractive,
2709
+ // onClick used to work with nonInteractive option
2710
+ onClick: event => {
2711
+ if (nonInteractive) {
2712
+ event.preventDefault();
2713
+ event.stopPropagation();
2714
+ }
2715
+ } }, rest)) }));
2716
+ });
2717
+ const UploadInputContainer = tw.label `
2718
+ tu-upload-input`;
2719
+
2720
+ /**
2721
+ * Upload fields enable the user to upload Files.
2722
+ */
2723
+ const UploadField = forwardRef((_a, ref) => {
2724
+ var { label, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
2725
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2726
+ return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, dataTestId: `${dataTestId}-FormGroup` }, { children: jsx(UploadInput, Object.assign({ ref: ref, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
2727
+ });
2728
+
2701
2729
  /**
2702
2730
  * Helper function to get normalized score in range 0-1 used by the ValueBar
2703
2731
  *
@@ -3136,4 +3164,4 @@ const Layout = tw.div `
3136
3164
  tu-layout-TwoColumnLayout
3137
3165
  `;
3138
3166
 
3139
- 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, ValueBar, docs, getDevicePixelRatio, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useDevicePixelRatio, useLocalStorage, useModal, usePrompt, useTimeout };
3167
+ 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 };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.47",
3
+ "version": "0.1.51",
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.69",
8
- "@trackunit/tailwind-styled-components": "0.0.52",
7
+ "@trackunit/css-core": "0.0.71",
8
+ "@trackunit/tailwind-styled-components": "0.0.53",
9
9
  "react": "18.2.0",
10
- "@trackunit/ui-design-tokens": "0.0.56",
11
- "@trackunit/react-core-contexts-test": "0.1.24",
10
+ "@trackunit/ui-design-tokens": "0.0.58",
11
+ "@trackunit/react-core-contexts-test": "0.1.26",
12
12
  "echarts": "5.4.0",
13
13
  "echarts-for-react": "3.0.2",
14
14
  "uuid": "8.3.2",
@@ -16,7 +16,7 @@
16
16
  "date-fns": "2.29.3",
17
17
  "react-day-picker": "8.3.7",
18
18
  "@floating-ui/react": "0.15.1",
19
- "@trackunit/ui-icons": "0.0.57",
19
+ "@trackunit/ui-icons": "0.0.58",
20
20
  "react-browser-hooks": "2.2.4",
21
21
  "react-useportal": "1.0.17",
22
22
  "react-router-dom": "6.4.5",
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { FormGroupProps } from "../FormGroup/FormGroup";
3
+ import { UploadInputProps } from "../UploadInput/UploadInput";
4
+ type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
5
+ export interface UploadFieldProps extends UploadInputProps, FormGroupExposedProps {
6
+ /**
7
+ * If a value is set, the field is rendered in its invalid state.
8
+ */
9
+ errorMessage?: string;
10
+ }
11
+ /**
12
+ * Upload fields enable the user to upload Files.
13
+ */
14
+ export declare const UploadField: import("react").ForwardRefExoticComponent<UploadFieldProps & import("react").RefAttributes<HTMLInputElement>>;
15
+ export {};
@@ -0,0 +1,33 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "../../common";
3
+ import { BaseInputProps } from "../BaseInput";
4
+ type BaseInputExposedProps = Omit<BaseInputProps, "type" | "suffix" | "prefix" | "addonAfter" | "addonBefore" | "actions" | "placeholder">;
5
+ export interface UploadInputProps extends BaseInputExposedProps, CommonProps {
6
+ /**
7
+ * A flag to disable the upload input.
8
+ */
9
+ disabled?: boolean;
10
+ /**
11
+ * A string to set the file formats, for example '.pdf' or '.pdf, .jgp'.
12
+ */
13
+ acceptedTypes?: string;
14
+ /**
15
+ * Label for the file selector button,
16
+ */
17
+ uploadLabel: string;
18
+ /**
19
+ * A flag to allow the upload input to accept multiple files.
20
+ */
21
+ multipleFiles?: boolean;
22
+ /**
23
+ * A flag to disable interaction with input for example if you want to use input as a child of higher component
24
+ */
25
+ nonInteractive?: boolean;
26
+ }
27
+ /**
28
+ * A thin wrapper around the `BaseInput` component for upload input fields.
29
+ *
30
+ * NOTE: If shown with a label, please use the `UploadField` component instead.
31
+ */
32
+ export declare const UploadInput: import("react").ForwardRefExoticComponent<UploadInputProps & import("react").RefAttributes<HTMLInputElement>>;
33
+ export {};
@@ -49,4 +49,6 @@ export * from "./Timeline/Timeline";
49
49
  export * from "./Tip";
50
50
  export * from "./Toggle";
51
51
  export * from "./Tooltip";
52
+ export * from "./UploadField/UploadField";
53
+ export * from "./UploadInput/UploadInput";
52
54
  export * from "./ValueBar";