@trackunit/react-components 0.1.57 → 0.1.59
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
|
@@ -293,7 +293,7 @@ const Root$9 = tw.span `
|
|
|
293
293
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
294
294
|
* @returns {JSX.Element} ActionButton component
|
|
295
295
|
*/
|
|
296
|
-
const ActionButton = ({ type, value, dataTestId, iconSize }) => {
|
|
296
|
+
const ActionButton = ({ type, value, dataTestId, iconSize, disabled }) => {
|
|
297
297
|
const getIconName = () => {
|
|
298
298
|
switch (type) {
|
|
299
299
|
case "PHONE_NUMBER":
|
|
@@ -319,7 +319,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize }) => {
|
|
|
319
319
|
return window.open(`tel:${value}`);
|
|
320
320
|
}
|
|
321
321
|
};
|
|
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 }) }));
|
|
322
|
+
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
323
|
};
|
|
324
324
|
const ActionContainer = tw.div `
|
|
325
325
|
tu-action-container
|
|
@@ -1268,12 +1268,29 @@ const Overlay = tw.div `
|
|
|
1268
1268
|
* For specific input types make sure to use the corresponding input component.
|
|
1269
1269
|
*/
|
|
1270
1270
|
const EmailInput = React.forwardRef((_a, ref) => {
|
|
1271
|
-
var { fieldSize = "medium",
|
|
1271
|
+
var { fieldSize = "medium", disabled = false, dataTestId } = _a, rest = __rest(_a, ["fieldSize", "disabled", "dataTestId"]);
|
|
1272
1272
|
const [email, setEmail] = React.useState("");
|
|
1273
1273
|
const sendEmail = () => {
|
|
1274
1274
|
return window.open(`mailto:${email}`);
|
|
1275
1275
|
};
|
|
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:
|
|
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: jsx(ActionButton, { disabled: disabled, value: email, type: "EMAIL", onClick: sendEmail, dataTestId: dataTestId && `${dataTestId}-emailIcon`, iconSize: fieldSize }) })));
|
|
1277
|
+
});
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* The EmailField component is used to enter email.
|
|
1281
|
+
* EmailField validates that user enters a valid email address.
|
|
1282
|
+
*
|
|
1283
|
+
*/
|
|
1284
|
+
const EmailField = forwardRef((_a, ref) => {
|
|
1285
|
+
var { label, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
|
|
1286
|
+
const [value, setValue] = useState(defaultValue);
|
|
1287
|
+
// Type guard to check if value is a string
|
|
1288
|
+
function isString(inputValue) {
|
|
1289
|
+
return typeof inputValue === "string";
|
|
1290
|
+
}
|
|
1291
|
+
// Check the regular expression only if value is a string
|
|
1292
|
+
const renderAsInvalid = !!errorMessage || (isString(value) && !/^\S+@\S+\.\S+$/.test(value));
|
|
1293
|
+
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
1294
|
});
|
|
1278
1295
|
|
|
1279
1296
|
/**
|
|
@@ -3162,4 +3179,4 @@ const Layout = tw.div `
|
|
|
3162
3179
|
tu-layout-TwoColumnLayout
|
|
3163
3180
|
`;
|
|
3164
3181
|
|
|
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 };
|
|
3182
|
+
export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, ContentGridArea, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, EmailField, 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,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.59",
|
|
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.
|
|
8
|
-
"@trackunit/tailwind-styled-components": "0.0.
|
|
7
|
+
"@trackunit/css-core": "0.0.73",
|
|
8
|
+
"@trackunit/tailwind-styled-components": "0.0.54",
|
|
9
9
|
"react": "18.2.0",
|
|
10
|
-
"@trackunit/ui-design-tokens": "0.0.
|
|
10
|
+
"@trackunit/ui-design-tokens": "0.0.60",
|
|
11
11
|
"echarts": "5.4.0",
|
|
12
12
|
"echarts-for-react": "3.0.2",
|
|
13
13
|
"react-use": "17.4.0",
|
|
14
14
|
"date-fns": "2.29.3",
|
|
15
15
|
"react-day-picker": "8.3.7",
|
|
16
16
|
"@floating-ui/react": "0.15.1",
|
|
17
|
-
"@trackunit/ui-icons": "0.0.
|
|
17
|
+
"@trackunit/ui-icons": "0.0.60",
|
|
18
18
|
"react-browser-hooks": "2.2.4",
|
|
19
19
|
"react-useportal": "1.0.17",
|
|
20
20
|
"react-router-dom": "6.4.5",
|
|
@@ -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,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<
|
|
13
|
+
export declare const EmailInput: React.ForwardRefExoticComponent<BaseInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -12,6 +12,7 @@ export * from "./DateField/DateField";
|
|
|
12
12
|
export * from "./DateInput/DateInput";
|
|
13
13
|
export * from "./DayPicker";
|
|
14
14
|
export * from "./Drawer/Drawer";
|
|
15
|
+
export * from "./EmailField/EmailField";
|
|
15
16
|
export * from "./EmailInput";
|
|
16
17
|
export * from "./ExternalLink/ExternalLink";
|
|
17
18
|
export * from "./FormGroup/FormGroup";
|