@trackunit/react-components 0.0.129 → 0.0.130
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/components/ActionButton/ActionButton.d.ts +25 -0
- package/components/ActionButton/index.d.ts +1 -0
- package/components/index.d.ts +1 -0
- package/index.css +20 -3
- package/index.js +73 -2
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { CommonProps } from "../../common";
|
|
3
|
+
declare type ActionType = "PHONE_NUMBER" | "WEB_ADDRESS" | "EMAIL";
|
|
4
|
+
interface ActionButtonProps extends CommonProps {
|
|
5
|
+
/**
|
|
6
|
+
* The type of action performed when clicking the button.
|
|
7
|
+
*/
|
|
8
|
+
type: ActionType;
|
|
9
|
+
/**
|
|
10
|
+
* The value to be passed into the button.
|
|
11
|
+
*/
|
|
12
|
+
value?: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* The onClick event.
|
|
15
|
+
*/
|
|
16
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The ActionButton component is a wrapper over IconButton to perform an action when the onClick event is triggered.
|
|
20
|
+
*
|
|
21
|
+
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
22
|
+
* @returns {JSX.Element} ActionButton component
|
|
23
|
+
*/
|
|
24
|
+
export declare const ActionButton: ({ type, value }: ActionButtonProps) => JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ActionButton";
|
package/components/index.d.ts
CHANGED
package/index.css
CHANGED
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
rounded-lg
|
|
17
17
|
cursor-pointer
|
|
18
18
|
flex-none
|
|
19
|
-
|
|
20
|
-
px-3
|
|
19
|
+
p-2.5
|
|
21
20
|
h-min
|
|
22
21
|
drop-shadow
|
|
23
22
|
focus:ring
|
|
@@ -46,7 +45,7 @@
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
&--small {
|
|
49
|
-
@apply
|
|
48
|
+
@apply p-2;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
&--large {
|
|
@@ -161,6 +160,24 @@
|
|
|
161
160
|
hover:bg-slate-600/10
|
|
162
161
|
disabled:hover:bg-transparent;
|
|
163
162
|
}
|
|
163
|
+
|
|
164
|
+
&__container {
|
|
165
|
+
@apply w-5
|
|
166
|
+
h-5
|
|
167
|
+
flex
|
|
168
|
+
justify-center
|
|
169
|
+
items-center
|
|
170
|
+
box-border;
|
|
171
|
+
|
|
172
|
+
&--small {
|
|
173
|
+
@apply w-4
|
|
174
|
+
h-4
|
|
175
|
+
flex
|
|
176
|
+
justify-center
|
|
177
|
+
items-center
|
|
178
|
+
box-border;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
164
181
|
}
|
|
165
182
|
|
|
166
183
|
/* CSS related to the LAbel component */
|
package/index.js
CHANGED
|
@@ -287,12 +287,20 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
287
287
|
disabled: disabled || loading,
|
|
288
288
|
ref: ref
|
|
289
289
|
}, rest, {
|
|
290
|
-
children:
|
|
290
|
+
children: jsx(IconContainer$2, {
|
|
291
|
+
children: loading ? jsx(Spinner, {
|
|
292
|
+
size: size
|
|
293
|
+
}) : icon
|
|
294
|
+
})
|
|
291
295
|
}));
|
|
292
296
|
});
|
|
293
297
|
const StyledButton = tw(Button)`
|
|
294
298
|
${p => p.$circular ? tws`tu-button--rounded` : null}
|
|
295
299
|
`;
|
|
300
|
+
const IconContainer$2 = tw.div`
|
|
301
|
+
tu-button__container
|
|
302
|
+
${p => p.$size === "small" ? tws`tu-button__container--small` : null}
|
|
303
|
+
`;
|
|
296
304
|
|
|
297
305
|
/**
|
|
298
306
|
* ? A collection of all the types and tokens related to the named colors in the default theme.
|
|
@@ -465,6 +473,69 @@ const Root$3 = tw.span`
|
|
|
465
473
|
}}
|
|
466
474
|
`;
|
|
467
475
|
|
|
476
|
+
/**
|
|
477
|
+
* The ActionButton component is a wrapper over IconButton to perform an action when the onClick event is triggered.
|
|
478
|
+
*
|
|
479
|
+
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
480
|
+
* @returns {JSX.Element} ActionButton component
|
|
481
|
+
*/
|
|
482
|
+
|
|
483
|
+
const ActionButton = ({
|
|
484
|
+
type,
|
|
485
|
+
value
|
|
486
|
+
}) => {
|
|
487
|
+
const getIconName = () => {
|
|
488
|
+
switch (type) {
|
|
489
|
+
case "PHONE_NUMBER":
|
|
490
|
+
return "PhoneOutgoingIcon";
|
|
491
|
+
|
|
492
|
+
case "WEB_ADDRESS":
|
|
493
|
+
return "ExternalLinkIcon";
|
|
494
|
+
|
|
495
|
+
case "EMAIL":
|
|
496
|
+
default:
|
|
497
|
+
return "MailIcon";
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
const ButtonAction = () => {
|
|
502
|
+
switch (type) {
|
|
503
|
+
case "EMAIL":
|
|
504
|
+
return window.open(`mailto:${value}`);
|
|
505
|
+
|
|
506
|
+
case "WEB_ADDRESS":
|
|
507
|
+
if (value) {
|
|
508
|
+
return window.open(value, "_blank", "noopener,noreferrer");
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return null;
|
|
512
|
+
|
|
513
|
+
case "PHONE_NUMBER":
|
|
514
|
+
default:
|
|
515
|
+
return window.open(`tel:${value}`);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
return jsx(ActionContainer, {
|
|
520
|
+
children: jsx(StyledIconButton, {
|
|
521
|
+
dataTestId: "testIconButtonId",
|
|
522
|
+
size: "small",
|
|
523
|
+
intent: "tertiary",
|
|
524
|
+
icon: jsx(Icon$1, {
|
|
525
|
+
size: "small",
|
|
526
|
+
name: getIconName()
|
|
527
|
+
}),
|
|
528
|
+
onClick: ButtonAction
|
|
529
|
+
})
|
|
530
|
+
});
|
|
531
|
+
};
|
|
532
|
+
const ActionContainer = tw.div`
|
|
533
|
+
tu-action-container
|
|
534
|
+
`;
|
|
535
|
+
const StyledIconButton = tw(IconButton)`
|
|
536
|
+
tu-action-button
|
|
537
|
+
`;
|
|
538
|
+
|
|
468
539
|
/**
|
|
469
540
|
* The StarButton component is used for favorite actions or similar.
|
|
470
541
|
*
|
|
@@ -5131,4 +5202,4 @@ const Layout = tw.div`
|
|
|
5131
5202
|
tu-layout-TwoColumnLayout
|
|
5132
5203
|
`;
|
|
5133
5204
|
|
|
5134
|
-
export { 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, MenuButton, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, getOrderedOptions, intentColors, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
|
|
5205
|
+
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, MenuButton, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, getOrderedOptions, intentColors, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
|