@trackunit/react-components 0.1.65-alpha-0b53b6cf53.0 → 0.1.66
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.cjs +300 -207
- package/index.js +300 -208
- package/package.json +5 -4
- package/src/components/ActionButton/ActionButton.d.ts +1 -5
- package/src/components/PhoneField/PhoneField.d.ts +28 -0
- package/src/components/PhoneInput/CountryCodeSelect.d.ts +16 -0
- package/src/components/PhoneInput/CountryCodes.d.ts +5 -0
- package/src/components/PhoneInput/PhoneInput.d.ts +17 -12
- package/src/components/index.d.ts +1 -0
package/index.cjs
CHANGED
|
@@ -14,11 +14,12 @@ var reactDayPicker = require('react-day-picker');
|
|
|
14
14
|
var locale = require('date-fns/locale');
|
|
15
15
|
var reactBrowserHooks = require('react-browser-hooks');
|
|
16
16
|
var usePortal = require('react-useportal');
|
|
17
|
-
var reactHelmetAsync = require('react-helmet-async');
|
|
18
17
|
var ReactSelect = require('react-select');
|
|
19
18
|
var ReactAsyncCreatableSelect = require('react-select/async-creatable');
|
|
20
19
|
var ReactCreatableSelect = require('react-select/creatable');
|
|
21
20
|
var ReactAsyncSelect = require('react-select/async');
|
|
21
|
+
var libphonenumberJs = require('libphonenumber-js');
|
|
22
|
+
var reactHelmetAsync = require('react-helmet-async');
|
|
22
23
|
var uiDesignTokens = require('@trackunit/ui-design-tokens');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -127,7 +128,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
127
128
|
* @returns {JSX.Element} Spinner component
|
|
128
129
|
*/
|
|
129
130
|
const Spinner = ({ mode = "light", size = "medium", centering = "centered", className, containerClassName, dataTestId, }) => {
|
|
130
|
-
return (jsxRuntime.jsx(Container$
|
|
131
|
+
return (jsxRuntime.jsx(Container$a, Object.assign({ "$mode": mode, "$centering": centering, className: containerClassName }, { children: jsxRuntime.jsx(StyledSpinner$1, { "$size": size, "$mode": mode, role: "spinbutton", className: className, "data-testid": dataTestId }) })));
|
|
131
132
|
};
|
|
132
133
|
const getSpinnerStyles = () => ({ $size }) => {
|
|
133
134
|
switch ($size) {
|
|
@@ -157,7 +158,7 @@ const StyledSpinner$1 = tailwindStyledComponents.tw.span `
|
|
|
157
158
|
${p => (p.$mode === "dark" ? tailwindStyledComponents.tws `tu-spinner--dark` : null)}
|
|
158
159
|
${getSpinnerStyles()}
|
|
159
160
|
`;
|
|
160
|
-
const Container$
|
|
161
|
+
const Container$a = tailwindStyledComponents.tw.div `
|
|
161
162
|
tu-spinner--container
|
|
162
163
|
${getCenteringStyles()}
|
|
163
164
|
|
|
@@ -469,7 +470,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
469
470
|
ref && ref.current && ref.current.scrollIntoView && ref.current.scrollIntoView();
|
|
470
471
|
}
|
|
471
472
|
}, [ref, autoScroll]);
|
|
472
|
-
return (jsxRuntime.jsxs(Container$
|
|
473
|
+
return (jsxRuntime.jsxs(Container$9, Object.assign({ "$color": color, className: className, "data-testid": dataTestId, "$inline": inline, ref: ref, role: "alert" }, { children: [jsxRuntime.jsx(IconContainer$1, Object.assign({ "$inline": inline }, { children: getIconFromColor() })), jsxRuntime.jsxs(Content$1, Object.assign({ "$inline": inline }, { children: [jsxRuntime.jsxs(ContentDetails, { children: [jsxRuntime.jsx(ContentBody, { children: body }), onClose && !inline ? (jsxRuntime.jsx(CloseButtonContainer, Object.assign({ "$inline": inline }, { children: jsxRuntime.jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }), title: "Close Alert", circular: true }) }))) : null] }), (primaryAction || secondaryAction || onClose) && (jsxRuntime.jsxs(RightAligned, Object.assign({ "$inline": inline }, { children: [secondaryAction && (jsxRuntime.jsx(Button, Object.assign({ size: "small", variant: "transparent", color: getButtonColor(), onClick: secondaryAction.onClick, loading: secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.loading }, { children: secondaryAction.label }))), primaryAction && (jsxRuntime.jsx(Button, Object.assign({ size: "small", color: getButtonColor(), onClick: primaryAction.onClick, loading: primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.loading }, { children: primaryAction.label }))), onClose && inline ? (jsxRuntime.jsx(CloseButtonContainer, Object.assign({ "$inline": inline }, { children: jsxRuntime.jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }), title: "Close Alert", circular: true }) }))) : null] })))] }))] })));
|
|
473
474
|
};
|
|
474
475
|
const CloseButtonContainer = tailwindStyledComponents.tw.div `
|
|
475
476
|
${p => (p.$inline ? tailwindStyledComponents.tws `tu-alert__close-button-container--inline` : tailwindStyledComponents.tws `tu-alert__close-button-container`)}
|
|
@@ -483,7 +484,7 @@ const getBackgroundColor = () => ({ $color }) => {
|
|
|
483
484
|
};
|
|
484
485
|
return colors[$color];
|
|
485
486
|
};
|
|
486
|
-
const Container$
|
|
487
|
+
const Container$9 = tailwindStyledComponents.tw.div `
|
|
487
488
|
tu-alert
|
|
488
489
|
${p => (p.$inline ? tailwindStyledComponents.tws `tu-alert--inline` : null)}
|
|
489
490
|
${getBackgroundColor()}
|
|
@@ -684,9 +685,9 @@ const StyledDensityContainer = tailwindStyledComponents.twx(DensityContainer) `
|
|
|
684
685
|
* @returns {JSX.Element} CardFooter component
|
|
685
686
|
*/
|
|
686
687
|
const CardFooter = ({ dataTestId, className, children, density, hideSeparator = false }) => {
|
|
687
|
-
return (jsxRuntime.jsx(Container$
|
|
688
|
+
return (jsxRuntime.jsx(Container$8, Object.assign({ dataTestId: dataTestId, className: className, "$hideSeparator": hideSeparator, density: density, direction: "row" }, { children: children })));
|
|
688
689
|
};
|
|
689
|
-
const Container$
|
|
690
|
+
const Container$8 = tailwindStyledComponents.twx(DensityContainer) `
|
|
690
691
|
tu-card__footer-density-container
|
|
691
692
|
${p => p.$hideSeparator && tailwindStyledComponents.tws `tu-card__footer-density-container--borderless`}
|
|
692
693
|
`;
|
|
@@ -733,13 +734,13 @@ const StyledHeading = tailwindStyledComponents.tw.div `
|
|
|
733
734
|
* @returns {JSX.Element} CardHeader component
|
|
734
735
|
*/
|
|
735
736
|
const CardHeader = ({ heading, headingVariant = "primary", subHeading, onClose, dataTestId, className, children, accessories, density, extraClassName, hideSeparator = false, }) => {
|
|
736
|
-
return (jsxRuntime.jsx(Root$8, Object.assign({ dataTestId: dataTestId, className: className, "$hideSeparator": hideSeparator, density: density }, { children: jsxRuntime.jsxs(Container$
|
|
737
|
+
return (jsxRuntime.jsx(Root$8, Object.assign({ dataTestId: dataTestId, className: className, "$hideSeparator": hideSeparator, density: density }, { children: jsxRuntime.jsxs(Container$7, { children: [jsxRuntime.jsxs("div", Object.assign({ className: extraClassName }, { children: [jsxRuntime.jsxs(HeadingContainer$1, { children: [jsxRuntime.jsx(Heading$1, Object.assign({ className: "self-center", variant: headingVariant }, { children: heading })), accessories] }), subHeading && (jsxRuntime.jsx(Heading$1, Object.assign({ subtle: true, variant: "subtitle" }, { children: subHeading }))), children] })), onClose && (jsxRuntime.jsx(IconButton, { dataTestId: "card-header-close-button", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }), className: "!h-min" }))] }) })));
|
|
737
738
|
};
|
|
738
739
|
const Root$8 = tailwindStyledComponents.twx(DensityContainer) `
|
|
739
740
|
tu-card__header-density-container
|
|
740
741
|
${p => p.$hideSeparator && tailwindStyledComponents.tws `tu-card__header-density-container--borderless`}
|
|
741
742
|
`;
|
|
742
|
-
const Container$
|
|
743
|
+
const Container$7 = tailwindStyledComponents.tw.div `
|
|
743
744
|
tu-card__header
|
|
744
745
|
`;
|
|
745
746
|
const HeadingContainer$1 = tailwindStyledComponents.tw.div `
|
|
@@ -1010,9 +1011,9 @@ const PopoverLink = tailwindStyledComponents.twx(reactRouterDom.Link) `
|
|
|
1010
1011
|
* @returns {JSX.Element} PopoverTitle component
|
|
1011
1012
|
*/
|
|
1012
1013
|
const PopoverTitle = ({ children, action, divider = false, className, dataTestId }) => {
|
|
1013
|
-
return (jsxRuntime.jsxs(Container$
|
|
1014
|
+
return (jsxRuntime.jsxs(Container$6, Object.assign({ "$divider": divider, className: className, "data-testid": dataTestId }, { children: [jsxRuntime.jsx(StyledText$1, Object.assign({ type: "div", subtle: true, size: "small", weight: "bold", uppercase: true }, { children: children })), action] })));
|
|
1014
1015
|
};
|
|
1015
|
-
const Container$
|
|
1016
|
+
const Container$6 = tailwindStyledComponents.tw.div `
|
|
1016
1017
|
tu-popover-title-container
|
|
1017
1018
|
${p => p.$divider && `tu-popover-title-container--divider`}
|
|
1018
1019
|
`;
|
|
@@ -1350,9 +1351,9 @@ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className,
|
|
|
1350
1351
|
*/
|
|
1351
1352
|
const Indicator = (_a) => {
|
|
1352
1353
|
var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping"]);
|
|
1353
|
-
return (jsxRuntime.jsxs(Container$
|
|
1354
|
+
return (jsxRuntime.jsxs(Container$5, Object.assign({ "$color": color, "data-testid": dataTestId }, rest, { title: !withLabel ? label : undefined }, { children: [jsxRuntime.jsxs(IconBackground, Object.assign({ "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", "$withBackground": withBackground }, { children: [ping && jsxRuntime.jsx(Ping, { "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" }), icon] })), label !== undefined && withLabel && (jsxRuntime.jsx(Label$1, Object.assign({ "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label" }, { children: label })))] })));
|
|
1354
1355
|
};
|
|
1355
|
-
const Container$
|
|
1356
|
+
const Container$5 = tailwindStyledComponents.tw.div `
|
|
1356
1357
|
tu-indicator
|
|
1357
1358
|
${({ $color }) => {
|
|
1358
1359
|
switch ($color) {
|
|
@@ -1435,12 +1436,12 @@ const Ping = tailwindStyledComponents.tw.span `
|
|
|
1435
1436
|
*/
|
|
1436
1437
|
const MenuItem = ({ className, dataTestId, label, children, selected, focused, prefix, suffix, disabled, onClick, }) => {
|
|
1437
1438
|
const containerProps = useContainerProps({ className, dataTestId });
|
|
1438
|
-
return (jsxRuntime.jsxs(Container$
|
|
1439
|
+
return (jsxRuntime.jsxs(Container$4, Object.assign({}, containerProps, { onClick: e => {
|
|
1439
1440
|
e.stopPropagation();
|
|
1440
1441
|
onClick && onClick(e);
|
|
1441
1442
|
}, "$selected": selected, "$focused": focused, tabIndex: 0, "$disabled": disabled }, { children: [prefix && (jsxRuntime.jsx(Prefix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-prefix` }, { children: prefix }))), children !== null && children !== void 0 ? children : jsxRuntime.jsx(Label, Object.assign({ "data-testid": dataTestId && `${dataTestId}-label` }, { children: label })), suffix && (jsxRuntime.jsx(Suffix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-suffix` }, { children: suffix })))] })));
|
|
1442
1443
|
};
|
|
1443
|
-
const Container$
|
|
1444
|
+
const Container$4 = tailwindStyledComponents.tw.div `
|
|
1444
1445
|
group tu-menu-item
|
|
1445
1446
|
${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item--selected ` : "tu-menu-item--unselected")}
|
|
1446
1447
|
${({ $focused }) => ($focused ? tailwindStyledComponents.tws `tu-menu-item--focused ` : "")}
|
|
@@ -1469,9 +1470,9 @@ const MenuList = (_a) => {
|
|
|
1469
1470
|
var { dataTestId, className, children, withStickyHeader = false, showDivider = false } = _a; __rest(_a, ["dataTestId", "className", "children", "withStickyHeader", "showDivider"]);
|
|
1470
1471
|
const childrenArr = React.Children.toArray(children);
|
|
1471
1472
|
const isLastItem = (index) => index === childrenArr.length - 1;
|
|
1472
|
-
return (jsxRuntime.jsx(Container$
|
|
1473
|
+
return (jsxRuntime.jsx(Container$3, Object.assign({ "$withStickyHeader": withStickyHeader, "data-testid": dataTestId, className: className, tabIndex: 0 }, { children: React.Children.map(childrenArr, (menuItem, index) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsxRuntime.jsx(Divider, {})] }))) })));
|
|
1473
1474
|
};
|
|
1474
|
-
const Container$
|
|
1475
|
+
const Container$3 = tailwindStyledComponents.tw.div `
|
|
1475
1476
|
tu-menu-list
|
|
1476
1477
|
${props => props.$withStickyHeader && tailwindStyledComponents.tws `tu-menu-list--sticky-header`}
|
|
1477
1478
|
`;
|
|
@@ -1781,192 +1782,6 @@ const TextStyled = tailwindStyledComponents.twx(Text$1) `
|
|
|
1781
1782
|
tu-pagination__text
|
|
1782
1783
|
`;
|
|
1783
1784
|
|
|
1784
|
-
/**
|
|
1785
|
-
* A Phone Input component is used for input of the type tel.
|
|
1786
|
-
*
|
|
1787
|
-
* It has an ActionButton which sends an phone call to the specified number using "tel:" link.
|
|
1788
|
-
*
|
|
1789
|
-
* Extends props of BaseInput.
|
|
1790
|
-
*
|
|
1791
|
-
* A reference to the input element is provided as the `ref` prop.
|
|
1792
|
-
* For specific input types make sure to use the corresponding input component.
|
|
1793
|
-
*/
|
|
1794
|
-
const PhoneInput = React__namespace.forwardRef((_a, ref) => {
|
|
1795
|
-
var { dataTestId, fieldSize = "medium", disableAction = false } = _a, rest = __rest(_a, ["dataTestId", "fieldSize", "disableAction"]);
|
|
1796
|
-
const [phoneNumber, setPhoneNumber] = React__namespace.useState("");
|
|
1797
|
-
const callNumber = () => {
|
|
1798
|
-
return window.open(`tel:${phoneNumber}`);
|
|
1799
|
-
};
|
|
1800
|
-
return (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, dataTestId: dataTestId, fieldSize: fieldSize, type: "tel", onChange: e => setPhoneNumber(e.target.value), actions: !disableAction && (jsxRuntime.jsx(ActionButton, { value: phoneNumber, type: "PHONE_NUMBER", onClick: callNumber, dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest)));
|
|
1801
|
-
});
|
|
1802
|
-
|
|
1803
|
-
function useConfirmExit(confirmExit, when = true) {
|
|
1804
|
-
const { navigator } = React.useContext(reactRouterDom.UNSAFE_NavigationContext);
|
|
1805
|
-
React.useEffect(() => {
|
|
1806
|
-
if (!when) {
|
|
1807
|
-
return;
|
|
1808
|
-
}
|
|
1809
|
-
const push = navigator.push;
|
|
1810
|
-
navigator.push = (...args) => {
|
|
1811
|
-
const result = confirmExit();
|
|
1812
|
-
if (result !== false) {
|
|
1813
|
-
push(...args);
|
|
1814
|
-
}
|
|
1815
|
-
};
|
|
1816
|
-
return () => {
|
|
1817
|
-
navigator.push = push;
|
|
1818
|
-
};
|
|
1819
|
-
}, [navigator, confirmExit, when]);
|
|
1820
|
-
}
|
|
1821
|
-
/**
|
|
1822
|
-
* The usePrompt hook.
|
|
1823
|
-
*
|
|
1824
|
-
* @param {string} message -
|
|
1825
|
-
* @param {boolean} when -
|
|
1826
|
-
* @returns {void} void
|
|
1827
|
-
*/
|
|
1828
|
-
const usePrompt = (message, when = true) => {
|
|
1829
|
-
React.useEffect(() => {
|
|
1830
|
-
if (when) {
|
|
1831
|
-
window.onbeforeunload = function () {
|
|
1832
|
-
return message;
|
|
1833
|
-
};
|
|
1834
|
-
}
|
|
1835
|
-
return () => {
|
|
1836
|
-
window.onbeforeunload = null;
|
|
1837
|
-
};
|
|
1838
|
-
}, [message, when]);
|
|
1839
|
-
const confirmExit = React.useCallback(() => {
|
|
1840
|
-
const confirm = window.confirm(message);
|
|
1841
|
-
return confirm;
|
|
1842
|
-
}, [message]);
|
|
1843
|
-
useConfirmExit(confirmExit, when);
|
|
1844
|
-
};
|
|
1845
|
-
/**
|
|
1846
|
-
* The Prompt function.
|
|
1847
|
-
*
|
|
1848
|
-
* @param {PromptProps} Props -
|
|
1849
|
-
* @returns {void} void
|
|
1850
|
-
*/
|
|
1851
|
-
const Prompt = ({ when, message }) => {
|
|
1852
|
-
usePrompt(message, when);
|
|
1853
|
-
return null;
|
|
1854
|
-
};
|
|
1855
|
-
|
|
1856
|
-
const RadioGroupContext = React__namespace.createContext(null);
|
|
1857
|
-
|
|
1858
|
-
/**
|
|
1859
|
-
* Use radio buttons when you have a group of mutually exclusive choices and only one selection from the group is allowed.
|
|
1860
|
-
*
|
|
1861
|
-
* Radio buttons are used for mutually exclusive choices, not for multiple choices. Only one radio button can be selected at a time. When a user chooses a new item, the previous choice is automatically deselected.
|
|
1862
|
-
*
|
|
1863
|
-
* _**Do use** Radio buttons in forms, settings, or selections in a list._
|
|
1864
|
-
*
|
|
1865
|
-
* _**Do not use** Radio buttons if a user can select many option from a list, use checkboxes instead of radio buttons._
|
|
1866
|
-
*
|
|
1867
|
-
* @param {RadioGroupProps} props - The props for the RadioGroup component
|
|
1868
|
-
* @returns {JSX.Element} RadioGroup component
|
|
1869
|
-
*/
|
|
1870
|
-
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
|
|
1871
|
-
return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(Flex, Object.assign({ "$inline": inline, className: className, "data-testid": dataTestId }, { children: jsxRuntime.jsx(RadioGroupContext.Provider, Object.assign({ value: {
|
|
1872
|
-
id,
|
|
1873
|
-
value,
|
|
1874
|
-
name: name || id,
|
|
1875
|
-
onChange,
|
|
1876
|
-
disabled,
|
|
1877
|
-
isInvalid,
|
|
1878
|
-
} }, { children: children })) })) })));
|
|
1879
|
-
};
|
|
1880
|
-
RadioGroup.displayName = "RadioGroup";
|
|
1881
|
-
const Flex = tailwindStyledComponents.tw.div `
|
|
1882
|
-
${({ $inline }) => ($inline ? tailwindStyledComponents.tws `tu-radiogroup--inline` : tailwindStyledComponents.tws `tu-radiogroup`)}
|
|
1883
|
-
`;
|
|
1884
|
-
|
|
1885
|
-
/**
|
|
1886
|
-
* The RadioItem component.
|
|
1887
|
-
*
|
|
1888
|
-
* @param {RadioItemProps} props - The props for the RadioItem component
|
|
1889
|
-
* @returns {JSX.Element} RadioItem component
|
|
1890
|
-
*/
|
|
1891
|
-
const RadioItem = ({ label, value, dataTestId, className, description }) => {
|
|
1892
|
-
const groupCtx = React__namespace.useContext(RadioGroupContext);
|
|
1893
|
-
const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
|
|
1894
|
-
return (jsxRuntime.jsxs(InputWrapper, Object.assign({ className: className, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, "data-testid": dataTestId && `${dataTestId}-Wrapper` }, { children: [jsxRuntime.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 }), jsxRuntime.jsxs(LabelContainer$1, { children: [jsxRuntime.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 && (jsxRuntime.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 })))] })] })));
|
|
1895
|
-
};
|
|
1896
|
-
const InputWrapper = tailwindStyledComponents.tw.label `tu-radioitem__wrapper`;
|
|
1897
|
-
const Input = tailwindStyledComponents.tw.input `
|
|
1898
|
-
tu-radioitem
|
|
1899
|
-
${({ $checked }) => $checked && tailwindStyledComponents.tws `tu-radioitem--checked`}
|
|
1900
|
-
${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem--disabled`}
|
|
1901
|
-
${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-radioitem--invalid`}
|
|
1902
|
-
`;
|
|
1903
|
-
const LabelContainer$1 = tailwindStyledComponents.tw.div `tu-radioitem__label-container`;
|
|
1904
|
-
const Description$1 = tailwindStyledComponents.tw.label `
|
|
1905
|
-
tu-radioitem__description
|
|
1906
|
-
${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem__description--disabled`}
|
|
1907
|
-
`;
|
|
1908
|
-
|
|
1909
|
-
/**
|
|
1910
|
-
* A thin wrapper around the `BaseInput` component for text input fields.
|
|
1911
|
-
*
|
|
1912
|
-
* NOTE: If shown with a label, please use the `TextField` component instead.
|
|
1913
|
-
*/
|
|
1914
|
-
const TextInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "text" }, props))));
|
|
1915
|
-
|
|
1916
|
-
/**
|
|
1917
|
-
* The Search component is used to render a search input field.
|
|
1918
|
-
*
|
|
1919
|
-
* @param {SearchProps} props - The props for the Search component
|
|
1920
|
-
* @returns {JSX.Element} Search component
|
|
1921
|
-
*/
|
|
1922
|
-
const Search = (_a) => {
|
|
1923
|
-
var { className, placeholder = "Search", value, widenInputOnFocus, showBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", ref } = _a, rest = __rest(_a, ["className", "placeholder", "value", "widenInputOnFocus", "showBorderWhenNotInFocus", "disabled", "onKeyUp", "onChange", "onFocus", "onBlur", "name", "onClear", "dataTestId", "autoComplete", "ref"]);
|
|
1924
|
-
return (jsxRuntime.jsx(StyledTextInput, Object.assign({}, rest, { ref: ref, dataTestId: dataTestId, name: name, className: className, "$widenOnFocus": widenInputOnFocus, "$showBorderWhenNotInFocus": showBorderWhenNotInFocus, placeholder: placeholder, prefix: jsxRuntime.jsx(Icon, { name: "MagnifyingGlassIcon", size: "medium" }), suffix: onClear ? (jsxRuntime.jsx("button", Object.assign({ "data-testid": dataTestId && `${dataTestId}_suffix_component`, onClick: () => {
|
|
1925
|
-
onClear();
|
|
1926
|
-
} }, { children: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }) }))) : undefined, value: value, disabled: disabled, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, autoComplete: autoComplete })));
|
|
1927
|
-
};
|
|
1928
|
-
const StyledTextInput = tailwindStyledComponents.twx(TextInput) `
|
|
1929
|
-
tu-search
|
|
1930
|
-
${({ $showBorderWhenNotInFocus }) => $showBorderWhenNotInFocus && tailwindStyledComponents.tws `tu-search--border`}
|
|
1931
|
-
${({ $widenOnFocus }) => $widenOnFocus && tailwindStyledComponents.tws `tu-search--widen-on-focus`}
|
|
1932
|
-
`;
|
|
1933
|
-
|
|
1934
|
-
/**
|
|
1935
|
-
* The Spacer component is used for adding a bit of space in the ui.
|
|
1936
|
-
*
|
|
1937
|
-
* @param {SpacerProps} props - The props for the Spacer component
|
|
1938
|
-
* @returns {JSX.Element} Spacer component
|
|
1939
|
-
*/
|
|
1940
|
-
const Spacer = ({ minHeight, border = false, dataTestId }) => {
|
|
1941
|
-
return jsxRuntime.jsx(Space, { "data-testid": dataTestId, "$minHeight": minHeight, "$border": border });
|
|
1942
|
-
};
|
|
1943
|
-
const GetSpacerHeight = () => ({ $minHeight }) => {
|
|
1944
|
-
switch ($minHeight) {
|
|
1945
|
-
case "normal":
|
|
1946
|
-
return tailwindStyledComponents.tws `tu-spacer--normal`;
|
|
1947
|
-
case "large":
|
|
1948
|
-
return tailwindStyledComponents.tws `tu-spacer--large`;
|
|
1949
|
-
default:
|
|
1950
|
-
return "";
|
|
1951
|
-
}
|
|
1952
|
-
};
|
|
1953
|
-
const Space = tailwindStyledComponents.tw.div `
|
|
1954
|
-
${p => `${p.$border ? `tu-spacer--border` : null}`}
|
|
1955
|
-
${GetSpacerHeight()}
|
|
1956
|
-
`;
|
|
1957
|
-
|
|
1958
|
-
/**
|
|
1959
|
-
* The SectionHeader component is used on sections to set the section title.
|
|
1960
|
-
*
|
|
1961
|
-
* @param {SectionHeaderProps} props - The props for the section header component
|
|
1962
|
-
* @returns {JSX.Element} SectionHeader component
|
|
1963
|
-
*/
|
|
1964
|
-
const SectionHeader = ({ title, subtitle, dataTestId, addon }) => {
|
|
1965
|
-
return (jsxRuntime.jsxs(SectionHeaderContainer, { children: [jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(reactHelmetAsync.Helmet, { title: title }) }), jsxRuntime.jsxs(StyledFlex, { children: [jsxRuntime.jsx(Heading$1, Object.assign({ variant: "secondary", dataTestId: dataTestId }, { children: title })), addon] }), subtitle && (jsxRuntime.jsx(Heading$1, Object.assign({ variant: "subtitle", subtle: true }, { children: subtitle }))), jsxRuntime.jsx(Spacer, { minHeight: "normal" })] }));
|
|
1966
|
-
};
|
|
1967
|
-
const SectionHeaderContainer = tailwindStyledComponents.tw.div `tu-section-header`;
|
|
1968
|
-
const StyledFlex = tailwindStyledComponents.tw.div `tu-section-header__flex`;
|
|
1969
|
-
|
|
1970
1785
|
/**
|
|
1971
1786
|
* The SelectContainer component.
|
|
1972
1787
|
*
|
|
@@ -1974,9 +1789,9 @@ const StyledFlex = tailwindStyledComponents.tw.div `tu-section-header__flex`;
|
|
|
1974
1789
|
* @returns {JSX.Element} SelectContainer component
|
|
1975
1790
|
*/
|
|
1976
1791
|
const SelectContainer$1 = ({ children, label, hideLabel, id, hasError, error, description, info, dataTestId, isDisabled, }) => {
|
|
1977
|
-
return (jsxRuntime.jsxs(Container$
|
|
1792
|
+
return (jsxRuntime.jsxs(Container$2, Object.assign({ "data-testid": dataTestId, "$hasError": hasError, "$isDisabled": isDisabled }, { children: [label && !hideLabel && jsxRuntime.jsx(Label$2, Object.assign({ htmlFor: id }, { children: label })), children, (hasError || info) && (jsxRuntime.jsx(InformativeText, Object.assign({ size: "small", "$hasError": hasError !== null && hasError !== void 0 ? hasError : false }, { children: hasError ? error : info })))] })));
|
|
1978
1793
|
};
|
|
1979
|
-
const Container$
|
|
1794
|
+
const Container$2 = tailwindStyledComponents.tw.label `
|
|
1980
1795
|
tu-select__container
|
|
1981
1796
|
tu-select
|
|
1982
1797
|
${({ $hasError }) => ($hasError ? tailwindStyledComponents.tws `tu-select--invalid` : null)}
|
|
@@ -2135,11 +1950,11 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix }) => {
|
|
|
2135
1950
|
return null;
|
|
2136
1951
|
})
|
|
2137
1952
|
.filter(element => element !== null);
|
|
2138
|
-
return (jsxRuntime.jsxs(Container, Object.assign({ style: {
|
|
1953
|
+
return (jsxRuntime.jsxs(Container$1, Object.assign({ style: {
|
|
2139
1954
|
width: `${width}`,
|
|
2140
1955
|
}, "$ready": isReady, ref: containerRef }, { children: [renderedElements, postFix] })));
|
|
2141
1956
|
};
|
|
2142
|
-
const Container = tailwindStyledComponents.tw.div `
|
|
1957
|
+
const Container$1 = tailwindStyledComponents.tw.div `
|
|
2143
1958
|
tu-select__dynamic-tag--container
|
|
2144
1959
|
${({ $ready }) => {
|
|
2145
1960
|
return $ready ? tailwindStyledComponents.tws `visible` : tailwindStyledComponents.tws `invisible`;
|
|
@@ -2410,6 +2225,283 @@ const SelectContainer = tailwindStyledComponents.tw.div `
|
|
|
2410
2225
|
`;
|
|
2411
2226
|
Select.displayName = "Select";
|
|
2412
2227
|
|
|
2228
|
+
const COUNTRY_CODES_NOT_SUPPORTED_BY_BACKEND = ["53", "98", "211", "247", "249", "383", "850", "963"];
|
|
2229
|
+
const ADDITIONAL_COUNTRY_CODES_SUPPORTED_BY_BACKEND = [
|
|
2230
|
+
"1242",
|
|
2231
|
+
"1246",
|
|
2232
|
+
"1264",
|
|
2233
|
+
"1268",
|
|
2234
|
+
"1284",
|
|
2235
|
+
"1340",
|
|
2236
|
+
"1345",
|
|
2237
|
+
"1441",
|
|
2238
|
+
"1473",
|
|
2239
|
+
"1649",
|
|
2240
|
+
"1664",
|
|
2241
|
+
"1670",
|
|
2242
|
+
"1671",
|
|
2243
|
+
"1684",
|
|
2244
|
+
"1721",
|
|
2245
|
+
"1758",
|
|
2246
|
+
"1767",
|
|
2247
|
+
"1784",
|
|
2248
|
+
"1809",
|
|
2249
|
+
"1868",
|
|
2250
|
+
"1869",
|
|
2251
|
+
"1876",
|
|
2252
|
+
"379",
|
|
2253
|
+
"5999",
|
|
2254
|
+
"881",
|
|
2255
|
+
"882",
|
|
2256
|
+
"883",
|
|
2257
|
+
];
|
|
2258
|
+
const countryCodesSet = [
|
|
2259
|
+
...new Set(libphonenumberJs.getCountries().map(code => libphonenumberJs.getCountryCallingCode(code))),
|
|
2260
|
+
...ADDITIONAL_COUNTRY_CODES_SUPPORTED_BY_BACKEND,
|
|
2261
|
+
]
|
|
2262
|
+
.filter(code => !COUNTRY_CODES_NOT_SUPPORTED_BY_BACKEND.includes(code))
|
|
2263
|
+
.sort((a, b) => Number(a) - Number(b));
|
|
2264
|
+
const countryCodes = countryCodesSet.map(code => ({ label: `+${code}`, value: code }));
|
|
2265
|
+
|
|
2266
|
+
/**
|
|
2267
|
+
* The CountryCodeSelect component is used to select a country code for a phone number.
|
|
2268
|
+
*
|
|
2269
|
+
* @param {CountryCodeSelectProps} props - The props for the CountryCodeSelect component
|
|
2270
|
+
* @returns {JSX.Element} CountryCodeSelect component
|
|
2271
|
+
*/
|
|
2272
|
+
const CountryCodeSelect = ({ excludedCountries, countryCode, isInvalid, setCountryCode, }) => {
|
|
2273
|
+
const [isCountryCodeMissing, setIsCountryCodeMissing] = React.useState(false);
|
|
2274
|
+
React.useEffect(() => {
|
|
2275
|
+
countryCode && setIsCountryCodeMissing(false);
|
|
2276
|
+
}, [countryCode]);
|
|
2277
|
+
const filteredCodes = countryCodes.filter(code => {
|
|
2278
|
+
return !(excludedCountries === null || excludedCountries === void 0 ? void 0 : excludedCountries.some(excludedCode => excludedCode.value === code.value));
|
|
2279
|
+
});
|
|
2280
|
+
return (jsxRuntime.jsx(Select, { className: "w-28", "aria-invalid": isCountryCodeMissing, options: filteredCodes.map(code => code), value: filteredCodes.find(({ value: currentValue }) => currentValue === countryCode), onChange: input => {
|
|
2281
|
+
setCountryCode(input === null || input === void 0 ? void 0 : input.value);
|
|
2282
|
+
}, placeholder: "+45", hasError: isCountryCodeMissing || isInvalid, maxMenuHeight: 200 }));
|
|
2283
|
+
};
|
|
2284
|
+
|
|
2285
|
+
/**
|
|
2286
|
+
* A component for inputting phone numbers with an optional action button for initiating a phone call.
|
|
2287
|
+
*
|
|
2288
|
+
* @param {string} [dataTestId] - The data test ID for the component.
|
|
2289
|
+
* @param {boolean} [disabled=false] - Whether the component is disabled or not.
|
|
2290
|
+
* @param {string} [fieldSize="medium"] - The size of the input field.
|
|
2291
|
+
* @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
|
|
2292
|
+
* @returns {JSX.Element} - The PhoneInput component.
|
|
2293
|
+
*/
|
|
2294
|
+
const PhoneInput = React.forwardRef((_a, ref) => {
|
|
2295
|
+
var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction"]);
|
|
2296
|
+
const [phoneNumber, setPhoneNumber] = React.useState();
|
|
2297
|
+
const [renderAsInvalid, setRenderAsInvalid] = React.useState(false);
|
|
2298
|
+
const [countryCode, setCountryCode] = React.useState(undefined);
|
|
2299
|
+
const [isPhoneNumberInvalid, setIsPhoneNumberInvalid] = React.useState(false);
|
|
2300
|
+
const handlePhoneNumberChange = (e) => {
|
|
2301
|
+
const input = e.target.value;
|
|
2302
|
+
setIsPhoneNumberInvalid(!Boolean(input));
|
|
2303
|
+
setPhoneNumber(input);
|
|
2304
|
+
};
|
|
2305
|
+
React.useEffect(() => {
|
|
2306
|
+
setRenderAsInvalid(isInvalid || isPhoneNumberInvalid);
|
|
2307
|
+
}, [isInvalid, isPhoneNumberInvalid]);
|
|
2308
|
+
return (jsxRuntime.jsxs(Container, { children: [jsxRuntime.jsx(CountryCodeSelect, { isInvalid: renderAsInvalid, countryCode: countryCode, setCountryCode: setCountryCode }), jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, dataTestId: dataTestId, isInvalid: renderAsInvalid, fieldSize: fieldSize, type: "tel", value: phoneNumber, onChange: handlePhoneNumberChange, disabled: disabled, actions: !disableAction && (jsxRuntime.jsx(ActionButton, { disabled: !countryCode || !phoneNumber || disabled || renderAsInvalid, value: `${countryCode}${phoneNumber}`, type: "PHONE_NUMBER", dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest))] }));
|
|
2309
|
+
});
|
|
2310
|
+
const Container = tailwindStyledComponents.tw.div `
|
|
2311
|
+
grid
|
|
2312
|
+
grid-cols-min-fr
|
|
2313
|
+
gap-2
|
|
2314
|
+
`;
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* The PhoneField component is used to enter phone number.
|
|
2318
|
+
* It is a wrapper around the PhoneInput component and the FormGroup component.
|
|
2319
|
+
* It is used to render a phone number field with a label, a tip, a help text, a help addon and an error message.
|
|
2320
|
+
*
|
|
2321
|
+
* @param {string} [label] - The label for the component.
|
|
2322
|
+
* @param {string} [tip] - The tip for the component.
|
|
2323
|
+
* @param {string} [helpText] - The help text for the component.
|
|
2324
|
+
* @param {string} [helpAddon] - The help addon for the component.
|
|
2325
|
+
* @param {string} [errorMessage] - The error message for the component.
|
|
2326
|
+
* @param {string} [defaultValue] - The default value for the component.
|
|
2327
|
+
* @param {boolean} [disabled=false] - Whether the component is disabled or not.
|
|
2328
|
+
* @param {string} [fieldSize="medium"] - The size of the input field.
|
|
2329
|
+
* @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
|
|
2330
|
+
* @returns {JSX.Element} - The PhoneField component.
|
|
2331
|
+
*/
|
|
2332
|
+
const PhoneField = React.forwardRef((_a, ref) => {
|
|
2333
|
+
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"]);
|
|
2334
|
+
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2335
|
+
return (jsxRuntime.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: jsxRuntime.jsx(PhoneInput, Object.assign({ value: value || defaultValue, isInvalid: renderAsInvalid }, rest)) })));
|
|
2336
|
+
});
|
|
2337
|
+
|
|
2338
|
+
function useConfirmExit(confirmExit, when = true) {
|
|
2339
|
+
const { navigator } = React.useContext(reactRouterDom.UNSAFE_NavigationContext);
|
|
2340
|
+
React.useEffect(() => {
|
|
2341
|
+
if (!when) {
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2344
|
+
const push = navigator.push;
|
|
2345
|
+
navigator.push = (...args) => {
|
|
2346
|
+
const result = confirmExit();
|
|
2347
|
+
if (result !== false) {
|
|
2348
|
+
push(...args);
|
|
2349
|
+
}
|
|
2350
|
+
};
|
|
2351
|
+
return () => {
|
|
2352
|
+
navigator.push = push;
|
|
2353
|
+
};
|
|
2354
|
+
}, [navigator, confirmExit, when]);
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* The usePrompt hook.
|
|
2358
|
+
*
|
|
2359
|
+
* @param {string} message -
|
|
2360
|
+
* @param {boolean} when -
|
|
2361
|
+
* @returns {void} void
|
|
2362
|
+
*/
|
|
2363
|
+
const usePrompt = (message, when = true) => {
|
|
2364
|
+
React.useEffect(() => {
|
|
2365
|
+
if (when) {
|
|
2366
|
+
window.onbeforeunload = function () {
|
|
2367
|
+
return message;
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
return () => {
|
|
2371
|
+
window.onbeforeunload = null;
|
|
2372
|
+
};
|
|
2373
|
+
}, [message, when]);
|
|
2374
|
+
const confirmExit = React.useCallback(() => {
|
|
2375
|
+
const confirm = window.confirm(message);
|
|
2376
|
+
return confirm;
|
|
2377
|
+
}, [message]);
|
|
2378
|
+
useConfirmExit(confirmExit, when);
|
|
2379
|
+
};
|
|
2380
|
+
/**
|
|
2381
|
+
* The Prompt function.
|
|
2382
|
+
*
|
|
2383
|
+
* @param {PromptProps} Props -
|
|
2384
|
+
* @returns {void} void
|
|
2385
|
+
*/
|
|
2386
|
+
const Prompt = ({ when, message }) => {
|
|
2387
|
+
usePrompt(message, when);
|
|
2388
|
+
return null;
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2391
|
+
const RadioGroupContext = React__namespace.createContext(null);
|
|
2392
|
+
|
|
2393
|
+
/**
|
|
2394
|
+
* Use radio buttons when you have a group of mutually exclusive choices and only one selection from the group is allowed.
|
|
2395
|
+
*
|
|
2396
|
+
* Radio buttons are used for mutually exclusive choices, not for multiple choices. Only one radio button can be selected at a time. When a user chooses a new item, the previous choice is automatically deselected.
|
|
2397
|
+
*
|
|
2398
|
+
* _**Do use** Radio buttons in forms, settings, or selections in a list._
|
|
2399
|
+
*
|
|
2400
|
+
* _**Do not use** Radio buttons if a user can select many option from a list, use checkboxes instead of radio buttons._
|
|
2401
|
+
*
|
|
2402
|
+
* @param {RadioGroupProps} props - The props for the RadioGroup component
|
|
2403
|
+
* @returns {JSX.Element} RadioGroup component
|
|
2404
|
+
*/
|
|
2405
|
+
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
|
|
2406
|
+
return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(Flex, Object.assign({ "$inline": inline, className: className, "data-testid": dataTestId }, { children: jsxRuntime.jsx(RadioGroupContext.Provider, Object.assign({ value: {
|
|
2407
|
+
id,
|
|
2408
|
+
value,
|
|
2409
|
+
name: name || id,
|
|
2410
|
+
onChange,
|
|
2411
|
+
disabled,
|
|
2412
|
+
isInvalid,
|
|
2413
|
+
} }, { children: children })) })) })));
|
|
2414
|
+
};
|
|
2415
|
+
RadioGroup.displayName = "RadioGroup";
|
|
2416
|
+
const Flex = tailwindStyledComponents.tw.div `
|
|
2417
|
+
${({ $inline }) => ($inline ? tailwindStyledComponents.tws `tu-radiogroup--inline` : tailwindStyledComponents.tws `tu-radiogroup`)}
|
|
2418
|
+
`;
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* The RadioItem component.
|
|
2422
|
+
*
|
|
2423
|
+
* @param {RadioItemProps} props - The props for the RadioItem component
|
|
2424
|
+
* @returns {JSX.Element} RadioItem component
|
|
2425
|
+
*/
|
|
2426
|
+
const RadioItem = ({ label, value, dataTestId, className, description }) => {
|
|
2427
|
+
const groupCtx = React__namespace.useContext(RadioGroupContext);
|
|
2428
|
+
const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
|
|
2429
|
+
return (jsxRuntime.jsxs(InputWrapper, Object.assign({ className: className, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, "data-testid": dataTestId && `${dataTestId}-Wrapper` }, { children: [jsxRuntime.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 }), jsxRuntime.jsxs(LabelContainer$1, { children: [jsxRuntime.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 && (jsxRuntime.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 })))] })] })));
|
|
2430
|
+
};
|
|
2431
|
+
const InputWrapper = tailwindStyledComponents.tw.label `tu-radioitem__wrapper`;
|
|
2432
|
+
const Input = tailwindStyledComponents.tw.input `
|
|
2433
|
+
tu-radioitem
|
|
2434
|
+
${({ $checked }) => $checked && tailwindStyledComponents.tws `tu-radioitem--checked`}
|
|
2435
|
+
${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem--disabled`}
|
|
2436
|
+
${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-radioitem--invalid`}
|
|
2437
|
+
`;
|
|
2438
|
+
const LabelContainer$1 = tailwindStyledComponents.tw.div `tu-radioitem__label-container`;
|
|
2439
|
+
const Description$1 = tailwindStyledComponents.tw.label `
|
|
2440
|
+
tu-radioitem__description
|
|
2441
|
+
${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem__description--disabled`}
|
|
2442
|
+
`;
|
|
2443
|
+
|
|
2444
|
+
/**
|
|
2445
|
+
* A thin wrapper around the `BaseInput` component for text input fields.
|
|
2446
|
+
*
|
|
2447
|
+
* NOTE: If shown with a label, please use the `TextField` component instead.
|
|
2448
|
+
*/
|
|
2449
|
+
const TextInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "text" }, props))));
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* The Search component is used to render a search input field.
|
|
2453
|
+
*
|
|
2454
|
+
* @param {SearchProps} props - The props for the Search component
|
|
2455
|
+
* @returns {JSX.Element} Search component
|
|
2456
|
+
*/
|
|
2457
|
+
const Search = (_a) => {
|
|
2458
|
+
var { className, placeholder = "Search", value, widenInputOnFocus, showBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", ref } = _a, rest = __rest(_a, ["className", "placeholder", "value", "widenInputOnFocus", "showBorderWhenNotInFocus", "disabled", "onKeyUp", "onChange", "onFocus", "onBlur", "name", "onClear", "dataTestId", "autoComplete", "ref"]);
|
|
2459
|
+
return (jsxRuntime.jsx(StyledTextInput, Object.assign({}, rest, { ref: ref, dataTestId: dataTestId, name: name, className: className, "$widenOnFocus": widenInputOnFocus, "$showBorderWhenNotInFocus": showBorderWhenNotInFocus, placeholder: placeholder, prefix: jsxRuntime.jsx(Icon, { name: "MagnifyingGlassIcon", size: "medium" }), suffix: onClear ? (jsxRuntime.jsx("button", Object.assign({ "data-testid": dataTestId && `${dataTestId}_suffix_component`, onClick: () => {
|
|
2460
|
+
onClear();
|
|
2461
|
+
} }, { children: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }) }))) : undefined, value: value, disabled: disabled, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, autoComplete: autoComplete })));
|
|
2462
|
+
};
|
|
2463
|
+
const StyledTextInput = tailwindStyledComponents.twx(TextInput) `
|
|
2464
|
+
tu-search
|
|
2465
|
+
${({ $showBorderWhenNotInFocus }) => $showBorderWhenNotInFocus && tailwindStyledComponents.tws `tu-search--border`}
|
|
2466
|
+
${({ $widenOnFocus }) => $widenOnFocus && tailwindStyledComponents.tws `tu-search--widen-on-focus`}
|
|
2467
|
+
`;
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* The Spacer component is used for adding a bit of space in the ui.
|
|
2471
|
+
*
|
|
2472
|
+
* @param {SpacerProps} props - The props for the Spacer component
|
|
2473
|
+
* @returns {JSX.Element} Spacer component
|
|
2474
|
+
*/
|
|
2475
|
+
const Spacer = ({ minHeight, border = false, dataTestId }) => {
|
|
2476
|
+
return jsxRuntime.jsx(Space, { "data-testid": dataTestId, "$minHeight": minHeight, "$border": border });
|
|
2477
|
+
};
|
|
2478
|
+
const GetSpacerHeight = () => ({ $minHeight }) => {
|
|
2479
|
+
switch ($minHeight) {
|
|
2480
|
+
case "normal":
|
|
2481
|
+
return tailwindStyledComponents.tws `tu-spacer--normal`;
|
|
2482
|
+
case "large":
|
|
2483
|
+
return tailwindStyledComponents.tws `tu-spacer--large`;
|
|
2484
|
+
default:
|
|
2485
|
+
return "";
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
const Space = tailwindStyledComponents.tw.div `
|
|
2489
|
+
${p => `${p.$border ? `tu-spacer--border` : null}`}
|
|
2490
|
+
${GetSpacerHeight()}
|
|
2491
|
+
`;
|
|
2492
|
+
|
|
2493
|
+
/**
|
|
2494
|
+
* The SectionHeader component is used on sections to set the section title.
|
|
2495
|
+
*
|
|
2496
|
+
* @param {SectionHeaderProps} props - The props for the section header component
|
|
2497
|
+
* @returns {JSX.Element} SectionHeader component
|
|
2498
|
+
*/
|
|
2499
|
+
const SectionHeader = ({ title, subtitle, dataTestId, addon }) => {
|
|
2500
|
+
return (jsxRuntime.jsxs(SectionHeaderContainer, { children: [jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(reactHelmetAsync.Helmet, { title: title }) }), jsxRuntime.jsxs(StyledFlex, { children: [jsxRuntime.jsx(Heading$1, Object.assign({ variant: "secondary", dataTestId: dataTestId }, { children: title })), addon] }), subtitle && (jsxRuntime.jsx(Heading$1, Object.assign({ variant: "subtitle", subtle: true }, { children: subtitle }))), jsxRuntime.jsx(Spacer, { minHeight: "normal" })] }));
|
|
2501
|
+
};
|
|
2502
|
+
const SectionHeaderContainer = tailwindStyledComponents.tw.div `tu-section-header`;
|
|
2503
|
+
const StyledFlex = tailwindStyledComponents.tw.div `tu-section-header__flex`;
|
|
2504
|
+
|
|
2413
2505
|
/**
|
|
2414
2506
|
* A hook used to detect what children are overflowing a container.
|
|
2415
2507
|
*
|
|
@@ -3171,6 +3263,7 @@ exports.NumberField = NumberField;
|
|
|
3171
3263
|
exports.NumberInput = NumberInput;
|
|
3172
3264
|
exports.PageHeader = PageHeader;
|
|
3173
3265
|
exports.Pagination = Pagination;
|
|
3266
|
+
exports.PhoneField = PhoneField;
|
|
3174
3267
|
exports.PhoneInput = PhoneInput;
|
|
3175
3268
|
exports.Popover = Popover;
|
|
3176
3269
|
exports.PopoverList = PopoverList;
|