@trackunit/react-components 0.1.66 → 0.1.68

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
@@ -1,12 +1,12 @@
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, useMemo, cloneElement, useCallback, useEffect, Children, useRef, memo, useContext } from 'react';
4
+ import React__default, { useState, forwardRef, useMemo, createContext, useContext, isValidElement, cloneElement, useCallback, useEffect, Children, useRef, memo } from 'react';
5
5
  import { HeroIconsArray, heroIconLookup, TrackunitSolidIconsArray, TrackunitOutlineIconsArray, trackunitIconLookup } from '@trackunit/ui-icons';
6
6
  import { useMeasure, useCopyToClipboard } from 'react-use';
7
+ import { v4 } from 'uuid';
7
8
  import { format, formatDistance } from 'date-fns';
8
- import { useFloating, offset, flip, size, shift, autoUpdate, useInteractions, useClick, useHover, useRole, useDismiss, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
9
- import { Link, UNSAFE_NavigationContext } from 'react-router-dom';
9
+ import { useFloating, autoUpdate, offset, flip, shift, size, useClick, useDismiss, useHover, useRole, useInteractions, useMergeRefs, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
10
10
  import { DayPicker as DayPicker$1 } from 'react-day-picker';
11
11
  import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
12
12
  import { useClickOutside } from 'react-browser-hooks';
@@ -17,6 +17,7 @@ import ReactAsyncCreatableSelect from 'react-select/async-creatable';
17
17
  import ReactCreatableSelect from 'react-select/creatable';
18
18
  import ReactAsyncSelect from 'react-select/async';
19
19
  import { getCountries, getCountryCallingCode } from 'libphonenumber-js';
20
+ import { UNSAFE_NavigationContext } from 'react-router-dom';
20
21
  import { HelmetProvider, Helmet } from 'react-helmet-async';
21
22
  import { color } from '@trackunit/ui-design-tokens';
22
23
 
@@ -362,7 +363,7 @@ const CustomIcon = twx(Icon) `
362
363
  * @returns {JSX.Element} Text component
363
364
  */
364
365
  const Text$1 = ({ children, type = "p", size = "medium", align = "left", weight = "normal", underline = false, inverted = false, subtle = false, italicize = false, uppercase = false, className, dataTestId, }) => {
365
- return (jsx(StyledText$4, Object.assign({ "$as": type, className: className, "$align": align, "$inverted": inverted, "$subtle": subtle, "$italicize": italicize, "$uppercase": uppercase, "$size": size, "$weight": weight, "$underline": underline, "data-testid": dataTestId }, { children: children })));
366
+ return (jsx(StyledText$3, Object.assign({ "$as": type, className: className, "$align": align, "$inverted": inverted, "$subtle": subtle, "$italicize": italicize, "$uppercase": uppercase, "$size": size, "$weight": weight, "$underline": underline, "data-testid": dataTestId }, { children: children })));
366
367
  };
367
368
  const getTextSize = () => ({ $size }) => {
368
369
  const sizes = {
@@ -393,7 +394,7 @@ const getTextAlignment = () => ({ $align }) => {
393
394
  };
394
395
  return alignments[$align];
395
396
  };
396
- const StyledText$4 = tw.text `
397
+ const StyledText$3 = tw.text `
397
398
  tu-text
398
399
  ${getFontColor$1()}
399
400
  ${p => (p.$italicize ? tws `tu-text--italic` : "")}
@@ -492,7 +493,7 @@ const Badge = (_a) => {
492
493
  return null;
493
494
  }
494
495
  const displayedCount = count && max ? (count > max ? `${max}+` : count) : count;
495
- return (jsx(StyledText$3, Object.assign({ className: className, "$color": color, "$subtle": subtle, "$count": count, "data-testid": dataTestId, "$as": "span" }, { children: displayedCount })));
496
+ return (jsx(StyledText$2, Object.assign({ className: className, "$color": color, "$subtle": subtle, "$count": count, "data-testid": dataTestId, "$as": "span" }, { children: displayedCount })));
496
497
  };
497
498
  const getBadgeModifierClass = () => ({ $color, $subtle }) => {
498
499
  const colorClasses = {
@@ -501,7 +502,7 @@ const getBadgeModifierClass = () => ({ $color, $subtle }) => {
501
502
  };
502
503
  return colorClasses[$color];
503
504
  };
504
- const StyledText$3 = tw.text `
505
+ const StyledText$2 = tw.text `
505
506
  tu-badge
506
507
  ${({ $count }) => ($count === null || $count === undefined) && tws `tu-badge--square`}
507
508
  ${getBadgeModifierClass()}
@@ -795,7 +796,7 @@ const CheckboxWrapper = tw.span `
795
796
  ? tws `tu-checkbox--selected`
796
797
  : tws `tu-checkbox--deselected`;
797
798
  }}
798
-
799
+
799
800
  ${({ $isInvalid }) => $isInvalid && tws `tu-checkbox--invalid`}
800
801
  `;
801
802
 
@@ -877,17 +878,28 @@ const DateInput = forwardRef((_a, ref) => {
877
878
  });
878
879
 
879
880
  /**
880
- * @param {PopoverProps} props The children to render in the popover
881
- * @returns {ReactElement} Popover with specified content and placement
881
+ * The hook that powers the Popover component.
882
+ * It should not be used directly, but rather through the Popover component.
883
+ *
884
+ * @param {PopoverProps} options The options for the popover
885
+ * @returns {ReturnType<usePopover>} The data for the popover
882
886
  */
883
- const Popover = ({ children, render, placement, activation = { click: true, hover: false }, className, dataTestId, }) => {
884
- const [open, setOpen] = useState(false);
885
- const { x, y, reference, floating, strategy, context } = useFloating({
886
- open,
887
- onOpenChange: setOpen,
887
+ const usePopover = (_a) => {
888
+ var { initialOpen = false, placement = "bottom", isModal, isOpen: controlledIsOpen, activation = { click: true, hover: false }, onOpenStateChange: setControlledIsOpen } = _a, restOptions = __rest(_a, ["initialOpen", "placement", "isModal", "isOpen", "activation", "onOpenStateChange"]);
889
+ const [uncontrolledIsOpen, setUncontrolledIsOpen] = useState(initialOpen);
890
+ const [labelId, setLabelId] = useState();
891
+ const [descriptionId, setDescriptionId] = useState();
892
+ const isOpen = controlledIsOpen !== null && controlledIsOpen !== void 0 ? controlledIsOpen : uncontrolledIsOpen;
893
+ const setIsOpen = setControlledIsOpen !== null && setControlledIsOpen !== void 0 ? setControlledIsOpen : setUncontrolledIsOpen;
894
+ const popoverData = useFloating({
895
+ placement,
896
+ open: isOpen,
897
+ onOpenChange: setIsOpen,
898
+ whileElementsMounted: autoUpdate,
888
899
  middleware: [
889
900
  offset(8),
890
901
  flip({ fallbackPlacements: ["top", "bottom", "right", "left"] }),
902
+ shift(),
891
903
  size({
892
904
  apply({ availableWidth, availableHeight, elements }) {
893
905
  Object.assign(elements.floating.style, {
@@ -896,83 +908,68 @@ const Popover = ({ children, render, placement, activation = { click: true, hove
896
908
  });
897
909
  },
898
910
  }),
899
- shift(),
900
911
  ],
901
- placement,
902
- whileElementsMounted: autoUpdate,
903
912
  });
904
- const { getReferenceProps, getFloatingProps } = useInteractions([
905
- useClick(context, { enabled: activation.click, ignoreMouse: activation.hover }),
906
- useHover(context, { enabled: activation.hover }),
907
- useRole(context),
908
- useDismiss(context),
913
+ const popoverContext = popoverData.context;
914
+ const clickInteraction = useClick(popoverContext, { enabled: activation.click, ignoreMouse: activation.hover });
915
+ const dismissInteraction = useDismiss(popoverContext);
916
+ const hoverInteraction = useHover(popoverContext, { enabled: activation.hover });
917
+ const roleInteraction = useRole(popoverContext);
918
+ const combinedInteractions = useInteractions([
919
+ clickInteraction,
920
+ hoverInteraction,
921
+ dismissInteraction,
922
+ roleInteraction,
909
923
  ]);
910
- // Preserve the consumer's ref
911
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
912
- const ref = useMemo(() => mergeRefs([reference, children.ref]), [reference, children]);
913
- return (jsxs(Fragment, { children: [cloneElement(children, getReferenceProps(Object.assign({ ref }, children.props))), jsx(FloatingPortal, Object.assign({ id: "tu-floating-ui" }, { children: open && (jsx(FloatingFocusManager, Object.assign({ guards: false, context: context, modal: false, order: ["reference", "content"], returnFocus: false }, { children: jsx("div", Object.assign({ ref: floating, className: `tu-popover-container animate-fade-in-fast ${className !== null && className !== void 0 ? className : ""}`, "data-testid": dataTestId, style: {
914
- position: strategy,
915
- top: y !== null && y !== void 0 ? y : 0,
916
- left: x !== null && x !== void 0 ? x : 0,
917
- display: "flex",
918
- } }, getFloatingProps(), { children: render({
919
- close: () => {
920
- setOpen(false);
921
- },
922
- }) })) }))) }))] }));
923
- };
924
- // Utility to merge refs — Heavily inspired by https://github.com/gregberge/react-merge-refs
925
- function mergeRefs(refs) {
926
- return value => {
927
- refs.forEach(ref => {
928
- if (typeof ref === "function") {
929
- ref(value);
930
- }
931
- else if (ref !== null) {
932
- ref.current = value;
933
- }
934
- });
935
- };
936
- }
924
+ return useMemo(() => (Object.assign(Object.assign(Object.assign({ isOpen,
925
+ setIsOpen }, combinedInteractions), popoverData), { isModal,
926
+ labelId,
927
+ descriptionId,
928
+ setLabelId,
929
+ setDescriptionId, customProps: restOptions })), [isOpen, setIsOpen, combinedInteractions, popoverData, isModal, labelId, descriptionId, restOptions]);
930
+ };
937
931
 
932
+ const PopoverContext = createContext(null);
938
933
  /**
939
- * The PopoverList component.
934
+ * A hook to get the popover context.
935
+ * It should only be used by the Popover components.
940
936
  *
941
- * @param {PopoverListProps} props - The props for the PopoverList component
942
- * @returns {JSX.Element} PopoverList component
937
+ * @returns {ContextType} The popover context
943
938
  */
944
- const PopoverList = ({ className, children, dataTestId }) => {
945
- return (jsx(Card, Object.assign({ className: className, dataTestId: dataTestId }, { children: jsx(StyledCardBody, Object.assign({ density: "comfortable" }, { children: jsx(List, { children: children }) })) })));
939
+ const usePopoverContext = () => {
940
+ const context = useContext(PopoverContext);
941
+ if (context === null) {
942
+ throw new Error("Popover components must be wrapped in <Popover />");
943
+ }
944
+ return context;
946
945
  };
947
- const List = tw.ul `
948
- tu-popover-list
949
- `;
950
- const StyledCardBody = twx(CardBody) `
951
- tu-popover-list-body
952
- `;
953
-
954
946
  /**
955
- * The PopoverListItem component.
947
+ * The popover component.
948
+ * - This component should wrap all the popover components.
949
+ * - It returns a context that is used by the popover components.
950
+ * - The context is used to share the state of the popover, such as the open state and the reference element.
951
+ *
952
+ * To open the popover, use the `<PopoverTrigger />` component.
953
+ *
954
+ * To render the content of the popover, use the `<PopoverContent />` component.
956
955
  *
957
- * @param {PopoverListItemProps} props - The props for the PopoverListItem component
958
- * @returns {JSX.Element} PopoverListItem component
956
+ *
957
+ * @param {PopoverProps} props The props for the popover
958
+ * @returns {JSX.Element} A Popover Context Provider contining the children
959
959
  */
960
- const PopoverListItem = ({ selected, children, disabled, ariaLabel, url, onClick, prefix, suffix, dataTestId, className, }) => {
961
- const content = (jsxs("div", Object.assign({ className: "flex items-center gap-3" }, { children: [prefix && jsx("div", { children: prefix }), jsx(StyledText$2, Object.assign({ weight: selected ? "bold" : "normal", "$selected": selected }, { children: children })), suffix && jsx("div", { children: suffix })] })));
962
- return (jsx(ListItem, Object.assign({ "$selected": selected, disabled: disabled, onClick: onClick, "aria-label": ariaLabel, "data-testid": dataTestId, className: className }, { children: url ? jsx(PopoverLink, Object.assign({ to: url }, { children: content })) : content })));
963
- };
964
- const StyledText$2 = twx(Text$1) `
965
- tu-popover-list-item__text
966
- ${p => p.$selected && tws `tu-popover-list-item__text--selected`}
967
- `;
968
- const ListItem = tw.li `
969
- group
970
- tu-popover-list-item
971
- ${p => p.disabled && tws `tu-popover-list-item--disabled`}
972
- `;
973
- const PopoverLink = twx(Link) `
974
- tu-popover-list-item__anchor
975
- `;
960
+ const Popover = (_a) => {
961
+ var { children, isModal = false } = _a, restOptions = __rest(_a, ["children", "isModal"]);
962
+ const popover = usePopover(Object.assign({ isModal }, restOptions));
963
+ return jsx(PopoverContext.Provider, Object.assign({ value: popover }, { children: children }));
964
+ };
965
+
966
+ const PopoverContent = React__default.forwardRef(function PopoverContent(_a, propRef) {
967
+ var _b, _c, _d, _e;
968
+ var { className, dataTestId, children } = _a, props = __rest(_a, ["className", "dataTestId", "children"]);
969
+ const _f = usePopoverContext(), { context: floatingContext, customProps } = _f, context = __rest(_f, ["context", "customProps"]);
970
+ const ref = useMergeRefs([context.refs.setFloating, propRef]);
971
+ return (jsx(FloatingPortal, Object.assign({ id: "tu-floating-ui" }, { children: context.isOpen && (jsx(FloatingFocusManager, Object.assign({ guards: false, context: floatingContext, modal: context.isModal, order: ["reference", "content"] }, { children: jsx("div", Object.assign({ ref: ref, className: `tu-popover-container animate-fade-in-fast ${(_b = className !== null && className !== void 0 ? className : customProps.className) !== null && _b !== void 0 ? _b : ""}`, "data-testid": (_c = dataTestId !== null && dataTestId !== void 0 ? dataTestId : customProps.dataTestId) !== null && _c !== void 0 ? _c : "popover-content", style: Object.assign({ position: context.strategy, top: (_d = context.y) !== null && _d !== void 0 ? _d : 0, left: (_e = context.x) !== null && _e !== void 0 ? _e : 0, width: "max-content" }, props.style), "aria-labelledby": context.labelId, "aria-describedby": context.descriptionId }, context.getFloatingProps(props), { children: typeof children === "function" ? children(() => context.setIsOpen(false)) : children })) }))) })));
972
+ });
976
973
 
977
974
  /**
978
975
  * The PopoverTitle component.
@@ -991,6 +988,20 @@ const StyledText$1 = twx(Text$1) `
991
988
  tu-popover-title-text
992
989
  `;
993
990
 
991
+ const PopoverTrigger = forwardRef(function PopoverTrigger(_a, propRef) {
992
+ var { children, renderButton } = _a, props = __rest(_a, ["children", "renderButton"]);
993
+ const context = usePopoverContext();
994
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
995
+ const childrenRef = children.ref;
996
+ const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
997
+ if (!renderButton && isValidElement(children)) {
998
+ return cloneElement(children, context.getReferenceProps(Object.assign(Object.assign(Object.assign({ ref }, props), children.props), { "data-state": context.isOpen ? "open" : "closed" })));
999
+ }
1000
+ else {
1001
+ return (jsx(Button, Object.assign({ ref: ref, type: "button", "data-state": context.isOpen ? "open" : "closed" }, context.getReferenceProps(props), { children: children })));
1002
+ }
1003
+ });
1004
+
994
1005
  /**
995
1006
  * The Tooltip component is used to show helpful tips or contextual information to the users.
996
1007
  *
@@ -1005,7 +1016,7 @@ const Tooltip = (_a) => {
1005
1016
  }
1006
1017
  return (jsx(TooltipContainer, Object.assign({ dataTestId: dataTestId }, rest, { children: wrappedChildren })));
1007
1018
  };
1008
- const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsx(StyledPopover, Object.assign({ className: "tu-tooltip__container", placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", render: () => (jsx(Content, Object.assign({ "$mode": mode }, { children: jsx(Text$1, Object.assign({ inverted: mode === "dark", type: contentTextType }, { children: label })) }))) }, { children: children })));
1019
+ const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsxs(StyledPopover, Object.assign({ className: "tu-tooltip__container", placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "" }, { children: [jsx(PopoverTrigger, { children: children }), jsx(PopoverContent, { children: jsx(Content, Object.assign({ "$mode": mode }, { children: jsx(Text$1, Object.assign({ inverted: mode === "dark", type: contentTextType }, { children: label })) })) })] })));
1009
1020
  const Flex$1 = tw.div `
1010
1021
  inline-flex
1011
1022
  `;
@@ -1039,13 +1050,13 @@ const TipContainer = tw.text `
1039
1050
  * @param {FormGroupProps} props - The props for the FormGroup component
1040
1051
  * @returns {JSX.Element} FormGroup component
1041
1052
  */
1042
- const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, children, disabled = false, }) => {
1043
- return (jsxs(FormGroupRoot, Object.assign({ className: className, "data-testid": dataTestId, "$disabled": disabled }, { children: [jsxs(ContainerBefore, { children: [jsx(FormGroupLabel, Object.assign({ dataTestId: dataTestId && `${dataTestId}-label` }, { children: label })), tip && jsx(Tip, Object.assign({ dataTestId: dataTestId && `${dataTestId}-tip` }, { children: tip }))] }), children, jsxs(ContainerAfter, Object.assign({ "$isInvalid": isInvalid }, { children: [helpText && jsx("span", Object.assign({ "data-testid": dataTestId && `${dataTestId}-helpText` }, { children: helpText })), helpAddon && jsx(HelpAddon, Object.assign({ "data-testid": dataTestId && `${dataTestId}-helpAddon` }, { children: helpAddon }))] }))] })));
1053
+ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, htmlFor, children, disabled = false, }) => {
1054
+ return (jsxs(FormGroupRoot, Object.assign({ className: className, "data-testid": dataTestId, "$disabled": disabled }, { children: [jsxs(ContainerBefore, { children: [jsx(FormGroupLabel, Object.assign({ dataTestId: dataTestId && `${dataTestId}-label`, htmlFor: htmlFor, id: htmlFor + "-label" }, { children: label })), tip && jsx(Tip, Object.assign({ dataTestId: dataTestId && `${dataTestId}-tip` }, { children: tip }))] }), children, jsxs(ContainerAfter, Object.assign({ "$isInvalid": isInvalid }, { children: [helpText && jsx("span", Object.assign({ "data-testid": dataTestId && `${dataTestId}-helpText` }, { children: helpText })), helpAddon && jsx(HelpAddon, Object.assign({ "data-testid": dataTestId && `${dataTestId}-helpAddon` }, { children: helpAddon }))] }))] })));
1044
1055
  };
1045
- const FormGroupRoot = tw.label `
1056
+ const FormGroupRoot = tw.div `
1046
1057
  tu-form-group
1047
1058
  ${({ $disabled }) => {
1048
- return $disabled ? "pointer-events-none " : null;
1059
+ return $disabled ? "pointer-events-none" : null;
1049
1060
  }}
1050
1061
  `;
1051
1062
  const ContainerBefore = tw.div `
@@ -1059,7 +1070,7 @@ const ContainerAfter = tw.div `
1059
1070
  ${({ $isInvalid }) => ($isInvalid ? tws `tu-form-group__container-after--invalid` : null)}
1060
1071
  `;
1061
1072
  const HelpAddon = tw.span `
1062
- tu-form-group__help-addon
1073
+ tu-form-group__help-addon
1063
1074
  `;
1064
1075
 
1065
1076
  /**
@@ -1070,9 +1081,10 @@ const HelpAddon = tw.span `
1070
1081
  * _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
1071
1082
  */
1072
1083
  const DateField = forwardRef((_a, ref) => {
1073
- var { label, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
1084
+ var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
1074
1085
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
1075
- 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(DateInput, Object.assign({ ref: ref, defaultValue: defaultValue, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1086
+ const htmlForId = id ? id : "dateField-" + v4();
1087
+ return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(DateInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, defaultValue: defaultValue, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1076
1088
  });
1077
1089
 
1078
1090
  const localeLookup = {
@@ -1125,7 +1137,7 @@ const DayPicker = ({ onDaySelect, disabledDays, selectedDays, language, classNam
1125
1137
  * @returns {JSX.Element} DayPickerPopover component
1126
1138
  */
1127
1139
  const DayPickerPopover = ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color = "secondary", placement, size = "small", buttonContent, language, }) => {
1128
- return (jsx(Popover, Object.assign({ placement: placement, render: () => (jsx(PopoverList, { children: jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) })) }, { children: jsx(Button, Object.assign({ color: color, size: size, className: className, prefix: jsx(Icon, { name: "CalendarIcon", size: "small" }), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker" }, { children: buttonContent })) })));
1140
+ return (jsxs(Popover, Object.assign({ placement: placement }, { children: [jsx(PopoverTrigger, { children: jsx(Button, Object.assign({ color: color, size: size, className: className, prefix: jsx(Icon, { name: "CalendarIcon", size: "small" }), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker" }, { children: buttonContent })) }), jsx(PopoverContent, { children: jsx(Card, { children: jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) }) })] })));
1129
1141
  };
1130
1142
 
1131
1143
  /**
@@ -1286,15 +1298,16 @@ const EmailInput = React.forwardRef((_a, ref) => {
1286
1298
  *
1287
1299
  */
1288
1300
  const EmailField = forwardRef((_a, ref) => {
1289
- var { label, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
1301
+ var { label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
1290
1302
  const [value, setValue] = useState(defaultValue);
1303
+ const htmlForId = id ? id : "emailField-" + v4();
1291
1304
  // Type guard to check if value is a string
1292
1305
  function isString(inputValue) {
1293
1306
  return typeof inputValue === "string";
1294
1307
  }
1295
1308
  // Check the regular expression only if value is a string
1296
1309
  const renderAsInvalid = !!errorMessage || (isString(value) && !/^\S+@\S+\.\S+$/.test(value));
1297
- 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 })) })));
1310
+ return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(EmailInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, value: value, onChange: e => setValue(e.target.value), isInvalid: renderAsInvalid, disabled: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1298
1311
  });
1299
1312
 
1300
1313
  /**
@@ -1409,7 +1422,7 @@ const MenuItem = ({ className, dataTestId, label, children, selected, focused, p
1409
1422
  return (jsxs(Container$4, Object.assign({}, containerProps, { onClick: e => {
1410
1423
  e.stopPropagation();
1411
1424
  onClick && onClick(e);
1412
- }, "$selected": selected, "$focused": focused, tabIndex: 0, "$disabled": disabled }, { children: [prefix && (jsx(Prefix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-prefix` }, { children: prefix }))), children !== null && children !== void 0 ? children : jsx(Label, Object.assign({ "data-testid": dataTestId && `${dataTestId}-label` }, { children: label })), suffix && (jsx(Suffix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-suffix` }, { children: suffix })))] })));
1425
+ }, "$selected": selected, "$focused": focused, tabIndex: 0, "$disabled": disabled }, { children: [prefix && (jsx(Prefix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-prefix` }, { children: prefix }))), children && typeof children !== "string" ? (children) : (jsx(Label, Object.assign({ "data-testid": dataTestId && `${dataTestId}-label` }, { children: children !== null && children !== void 0 ? children : label }))), suffix && (jsx(Suffix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-suffix` }, { children: suffix })))] })));
1413
1426
  };
1414
1427
  const Container$4 = tw.div `
1415
1428
  group tu-menu-item
@@ -1440,7 +1453,7 @@ const MenuList = (_a) => {
1440
1453
  var { dataTestId, className, children, withStickyHeader = false, showDivider = false } = _a; __rest(_a, ["dataTestId", "className", "children", "withStickyHeader", "showDivider"]);
1441
1454
  const childrenArr = Children.toArray(children);
1442
1455
  const isLastItem = (index) => index === childrenArr.length - 1;
1443
- return (jsx(Container$3, Object.assign({ "$withStickyHeader": withStickyHeader, "data-testid": dataTestId, className: className, tabIndex: 0 }, { children: Children.map(childrenArr, (menuItem, index) => (jsxs(Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsx(Divider, {})] }))) })));
1456
+ return (jsx(Container$3, Object.assign({ "$withStickyHeader": withStickyHeader, "data-testid": dataTestId, className: className, tabIndex: 0, role: "list" }, { children: Children.map(childrenArr, (menuItem, index) => (jsxs(Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsx(Divider, {})] }))) })));
1444
1457
  };
1445
1458
  const Container$3 = tw.div `
1446
1459
  tu-menu-list
@@ -1471,9 +1484,9 @@ const MoreMenu = ({ className, dataTestId, dotsDirection = "horizontal", menuPla
1471
1484
  useClickOutside(actionMenuRef, () => {
1472
1485
  setActionMenuIsOpen(false);
1473
1486
  });
1474
- return (jsx(Root$4, Object.assign({ ref: actionMenuRef, className: className, "data-testid": dataTestId }, { children: jsx(Popover, Object.assign({ render: () => children, placement: menuPlacement }, { children: jsx(IconButton, Object.assign({}, iconButtonProps, { icon: jsx(Icon, Object.assign({ name: dotsName }, iconProps)), onClick: () => {
1475
- setActionMenuIsOpen(!actionMenuIsOpen);
1476
- } })) })) })));
1487
+ return (jsx(Root$4, Object.assign({ ref: actionMenuRef, className: className, "data-testid": dataTestId }, { children: jsxs(Popover, Object.assign({ placement: menuPlacement }, { children: [jsx(PopoverTrigger, { children: jsx(IconButton, Object.assign({}, iconButtonProps, { icon: jsx(Icon, Object.assign({ name: dotsName }, iconProps)), onClick: () => {
1488
+ setActionMenuIsOpen(!actionMenuIsOpen);
1489
+ } })) }), jsx(PopoverContent, { children: children })] })) })));
1477
1490
  };
1478
1491
  const Root$4 = tw.div `
1479
1492
  tu-more-menu
@@ -1569,9 +1582,10 @@ const NumberInput = forwardRef((props, ref) => (jsx(BaseInput, Object.assign({ r
1569
1582
  * _**Do not use**_ this fields for non-serialized numbers. Use TextField instead.
1570
1583
  */
1571
1584
  const NumberField = forwardRef((_a, ref) => {
1572
- var { label, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
1585
+ var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
1573
1586
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
1574
- return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(NumberInput, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1587
+ const htmlForId = id ? id : "numberField-" + v4();
1588
+ return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(NumberInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1575
1589
  });
1576
1590
 
1577
1591
  /**
@@ -2300,9 +2314,10 @@ const Container = tw.div `
2300
2314
  * @returns {JSX.Element} - The PhoneField component.
2301
2315
  */
2302
2316
  const PhoneField = forwardRef((_a, ref) => {
2303
- var { label, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "isInvalid", "errorMessage", "value", "helpAddon", "className", "defaultValue", "dataTestId"]);
2317
+ var { label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "isInvalid", "errorMessage", "value", "helpAddon", "className", "defaultValue", "dataTestId"]);
2304
2318
  const renderAsInvalid = isInvalid || Boolean(errorMessage);
2305
- return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(PhoneInput, Object.assign({ value: value || defaultValue, isInvalid: renderAsInvalid }, rest)) })));
2319
+ const htmlForId = id ? id : "phoneField-" + v4();
2320
+ return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(PhoneInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", value: value || defaultValue, isInvalid: renderAsInvalid }, rest)) })));
2306
2321
  });
2307
2322
 
2308
2323
  function useConfirmExit(confirmExit, when = true) {
@@ -2396,7 +2411,7 @@ ${({ $inline }) => ($inline ? tws `tu-radiogroup--inline` : tws `tu-radiogroup`)
2396
2411
  const RadioItem = ({ label, value, dataTestId, className, description }) => {
2397
2412
  const groupCtx = React.useContext(RadioGroupContext);
2398
2413
  const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
2399
- return (jsxs(InputWrapper, Object.assign({ className: className, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, "data-testid": dataTestId && `${dataTestId}-Wrapper` }, { children: [jsx(Input, { id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, type: "radio", value: value, checked: isChecked, "$disabled": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, "$isInvalid": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, "data-testid": dataTestId, "$checked": isChecked }), jsxs(LabelContainer$1, { children: [jsx(Label$2, Object.assign({ htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, dataTestId: dataTestId && `${dataTestId}-Label`, disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, isInvalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid }, { children: label })), description && (jsx(Description$1, Object.assign({ htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, "data-testid": dataTestId && `${dataTestId}-Description`, "$disabled": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled }, { children: description })))] })] })));
2414
+ return (jsxs(InputWrapper, Object.assign({ className: className, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, "data-testid": dataTestId && `${dataTestId}-Wrapper` }, { children: [jsx(Input, { id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, type: "radio", role: "radio", value: value, checked: isChecked, "$disabled": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, "$isInvalid": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, "data-testid": dataTestId, "$checked": isChecked }), jsxs(LabelContainer$1, { children: [jsx(Label$2, Object.assign({ htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, dataTestId: dataTestId && `${dataTestId}-Label`, disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, isInvalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid }, { children: label })), description && (jsx(Description$1, Object.assign({ htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, "data-testid": dataTestId && `${dataTestId}-Description`, "$disabled": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled }, { children: description })))] })] })));
2400
2415
  };
2401
2416
  const InputWrapper = tw.label `tu-radioitem__wrapper`;
2402
2417
  const Input = tw.input `
@@ -2556,9 +2571,17 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
2556
2571
  circular: false,
2557
2572
  variant: "transparent",
2558
2573
  color: "secondary",
2559
- }, menuPlacement: "bottom-end" }, moreMenuProps, { className: `${(moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className) || ""} !p-0`, dataTestId: dataTestId && `${dataTestId}-more-menu` }, { children: jsx(MenuList, Object.assign({}, menuListProps, { dataTestId: dataTestId && `${dataTestId}-menu-list` }, { children: React__default.Children.map(children, child => {
2560
- return itemOverflowMap[child.props.id] ? child : null;
2561
- }) })) }))) : null] })));
2574
+ }, menuPlacement: "bottom-end" }, moreMenuProps, { className: `${(moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className) || ""} !p-0`, dataTestId: dataTestId && `${dataTestId}-more-menu` }, { children: close => (jsx(MenuList, Object.assign({}, menuListProps, { dataTestId: dataTestId && `${dataTestId}-menu-list` }, { children: React__default.Children.map(children, child => {
2575
+ return itemOverflowMap[child.props.id]
2576
+ ? React__default.cloneElement(child, {
2577
+ onClick: () => {
2578
+ var _a, _b;
2579
+ (_b = (_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
2580
+ close();
2581
+ },
2582
+ })
2583
+ : null;
2584
+ }) }))) }))) : null] })));
2562
2585
  };
2563
2586
  const Root$2 = tw.div `
2564
2587
  tu-sidebar
@@ -2583,7 +2606,7 @@ const ChildContainer = tw.div `
2583
2606
  */
2584
2607
  const TextArea = React.forwardRef((_a, ref) => {
2585
2608
  var { id, name, value, rows, disabled, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, className, required, dataTestId, isInvalid } = _a, rest = __rest(_a, ["id", "name", "value", "rows", "disabled", "placeholder", "readOnly", "tabIndex", "onChange", "onFocus", "onBlur", "maxLength", "resize", "defaultValue", "className", "required", "dataTestId", "isInvalid"]);
2586
- return (jsx(StyledTextArea, Object.assign({ name: name, value: value, rows: rows, disabled: disabled, placeholder: placeholder, readOnly: readOnly, tabIndex: tabIndex, onFocus: onFocus, onBlur: onBlur, maxLength: maxLength, "$resize": resize, "$invalid": isInvalid, ref: ref, defaultValue: defaultValue, required: required }, rest, { onChange: onChange, "data-testid": dataTestId })));
2609
+ return (jsx(StyledTextArea, Object.assign({ id: id, name: name, value: value, rows: rows, disabled: disabled, placeholder: placeholder, readOnly: readOnly, tabIndex: tabIndex, onFocus: onFocus, onBlur: onBlur, maxLength: maxLength, "$resize": resize, "$invalid": isInvalid, ref: ref, defaultValue: defaultValue, required: required }, rest, { onChange: onChange, "data-testid": dataTestId })));
2587
2610
  });
2588
2611
  const StyledTextArea = tw.textarea `
2589
2612
  tu-textarea
@@ -2620,17 +2643,18 @@ const Root$1 = tw.span `
2620
2643
  `;
2621
2644
 
2622
2645
  const TextAreaField = React.forwardRef((_a, ref) => {
2623
- var { label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
2646
+ var { id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["id", "label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
2624
2647
  const [valueLength, setValueLength] = React.useState(value ? `${value}`.length : 0);
2625
2648
  const renderAsInvalid = isInvalid || Boolean(errorMessage);
2649
+ const htmlForId = id ? id : "textAreaField-" + v4();
2626
2650
  const handleChange = React.useCallback((event) => {
2627
2651
  setValueLength(event.target.value.length);
2628
2652
  if (onChange) {
2629
2653
  onChange(event);
2630
2654
  }
2631
2655
  }, [onChange]);
2632
- return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon ||
2633
- (maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(TextArea, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, onChange: handleChange, dataTestId: dataTestId })) })));
2656
+ return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon ||
2657
+ (maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(TextArea, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, onChange: handleChange, dataTestId: dataTestId })) })));
2634
2658
  });
2635
2659
 
2636
2660
  /**
@@ -2641,17 +2665,18 @@ const TextAreaField = React.forwardRef((_a, ref) => {
2641
2665
  * _**Do not use** to confirm user actions, such as deleting. Use a checkbox for such flows._
2642
2666
  */
2643
2667
  const TextField = React.forwardRef((_a, ref) => {
2644
- var { label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
2668
+ var { id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["id", "label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
2645
2669
  const [valueLength, setValueLength] = React.useState(value ? `${value}`.length : 0);
2646
2670
  const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
2671
+ const htmlFor = id ? id : "textField-" + v4();
2647
2672
  const handleChange = React.useCallback((event) => {
2648
2673
  setValueLength(event.target.value.length);
2649
2674
  if (onChange) {
2650
2675
  onChange(event);
2651
2676
  }
2652
2677
  }, [onChange]);
2653
- return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon ||
2654
- (maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.readOnly }, { children: jsx(TextInput, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, onChange: handleChange, dataTestId: dataTestId })) })));
2678
+ return (jsx(FormGroup, Object.assign({ htmlFor: htmlFor, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon ||
2679
+ (maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.readOnly }, { children: jsx(TextInput, Object.assign({ id: htmlFor, "aria-labelledby": htmlFor + "-label", ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, onChange: handleChange, dataTestId: dataTestId })) })));
2655
2680
  });
2656
2681
 
2657
2682
  /**
@@ -2739,9 +2764,10 @@ tu-upload-input`;
2739
2764
  * Upload fields enable the user to upload Files.
2740
2765
  */
2741
2766
  const UploadField = forwardRef((_a, ref) => {
2742
- var { label, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
2767
+ var { label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
2743
2768
  const renderAsInvalid = isInvalid || Boolean(errorMessage);
2744
- 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 })) })));
2769
+ const htmlForId = id ? id : "uploadField-" + v4();
2770
+ return (jsx(FormGroup, Object.assign({ htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, dataTestId: `${dataTestId}-FormGroup` }, { children: jsx(UploadInput, Object.assign({ ref: ref, id: htmlForId, "aria-labelledby": htmlForId + "-label", isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
2745
2771
  });
2746
2772
 
2747
2773
  /**
@@ -3182,4 +3208,4 @@ const Layout = tw.div `
3182
3208
  tu-layout-TwoColumnLayout
3183
3209
  `;
3184
3210
 
3185
- 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, PhoneField, 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 };
3211
+ 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, PhoneField, PhoneInput, Popover, PopoverContent, PopoverTitle, PopoverTrigger, 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, usePopoverContext, usePrompt, useTimeout };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
@@ -9,9 +9,10 @@
9
9
  "@trackunit/ui-design-tokens": "0.0.61",
10
10
  "react": "18.2.0",
11
11
  "react-use": "17.4.0",
12
+ "uuid": "8.3.2",
12
13
  "date-fns": "2.29.3",
13
14
  "react-day-picker": "8.3.7",
14
- "@floating-ui/react": "0.15.1",
15
+ "@floating-ui/react": "0.22.2",
15
16
  "@trackunit/ui-icons": "0.0.61",
16
17
  "react-browser-hooks": "2.2.4",
17
18
  "react-useportal": "1.0.17",
@@ -9,6 +9,7 @@ export interface FormGroupProps extends CommonProps {
9
9
  * Content to display in the tooltip when hovering the ? icon next to the label.
10
10
  */
11
11
  tip?: string | React.ReactNode;
12
+ htmlFor?: string;
12
13
  /**
13
14
  * A string to display under the input element to help the user understand the input.
14
15
  */
@@ -35,4 +36,4 @@ export interface FormGroupProps extends CommonProps {
35
36
  * @param {FormGroupProps} props - The props for the FormGroup component
36
37
  * @returns {JSX.Element} FormGroup component
37
38
  */
38
- export declare const FormGroup: ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, children, disabled, }: FormGroupProps) => JSX.Element;
39
+ export declare const FormGroup: ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, htmlFor, children, disabled, }: FormGroupProps) => JSX.Element;
@@ -9,7 +9,7 @@ export interface MenuItemProps extends CommonProps {
9
9
  * The children element is a custom element that can be used to override the label.
10
10
  * If you use this prop, the label prop will be ignored.
11
11
  */
12
- children?: JSX.Element;
12
+ children?: React.ReactNode;
13
13
  /**
14
14
  * Additional tailwind classes to be applied to the component.
15
15
  */
@@ -2,13 +2,13 @@
2
2
  import { CommonProps } from "../../../common/CommonProps";
3
3
  import { IconButtonProps } from "../../buttons";
4
4
  import { IconProps } from "../../Icon/Icon";
5
- import { PopoverPlacement } from "../../Popover";
5
+ import { PopoverContentChildren, PopoverPlacement } from "../../Popover";
6
6
  export type DotsDirection = "horizontal" | "vertical";
7
7
  export type MenuPlacement = "above" | "below";
8
8
  type FilteredIconProps = Omit<IconProps, "name">;
9
9
  type FilteredIconButtonProps = Omit<IconButtonProps, "icon" | "onClick">;
10
10
  export interface MoreMenuProps extends CommonProps {
11
- children: JSX.Element;
11
+ children: PopoverContentChildren;
12
12
  dotsDirection?: DotsDirection;
13
13
  menuPlacement?: PopoverPlacement;
14
14
  iconProps?: FilteredIconProps;