@trackunit/react-form-components 0.1.22 → 0.1.24
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.js
CHANGED
|
@@ -534,13 +534,12 @@ const cvaCheckbox = cssClassVarianceUtilities.cvaMerge([
|
|
|
534
534
|
},
|
|
535
535
|
});
|
|
536
536
|
const cvaCheckboxContainer = cssClassVarianceUtilities.cvaMerge([
|
|
537
|
-
"grid",
|
|
538
|
-
"outline-none",
|
|
539
|
-
"grid-cols-min-fr",
|
|
540
537
|
"items-center",
|
|
541
538
|
"gap-2",
|
|
542
|
-
"cursor-pointer",
|
|
543
539
|
"group",
|
|
540
|
+
"grid",
|
|
541
|
+
"grid-cols-min-fr",
|
|
542
|
+
"has-[:nth-child(3)]:grid-cols-min-fr-min", //if there's 3 children
|
|
544
543
|
]);
|
|
545
544
|
const cvaCheckboxInput = cssClassVarianceUtilities.cvaMerge(["absolute", "opacity-0", "m-0", "pointer-events-none", "hidden"]);
|
|
546
545
|
const cvaCheckboxIcon = cssClassVarianceUtilities.cvaMerge(["w-2.5", "h-2.5", "text-white"]);
|
|
@@ -567,9 +566,11 @@ const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", { className:
|
|
|
567
566
|
* @param {CheckboxProps} props - The props for the Checkbox component
|
|
568
567
|
* @returns {JSX.Element} Checkbox component
|
|
569
568
|
*/
|
|
570
|
-
const Checkbox = React__namespace.forwardRef(({ className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0,
|
|
569
|
+
const Checkbox = React__namespace.forwardRef(({ className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, stopPropagation, ...rest }, ref) => {
|
|
571
570
|
const icon = indeterminate ? (jsxRuntime.jsx(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsxRuntime.jsx(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
572
571
|
const internalRef = React__namespace.useRef(null);
|
|
572
|
+
const labelRef = React__namespace.useRef(null);
|
|
573
|
+
const textIsCutOff = reactComponents.useIsTextCutOff(labelRef.current);
|
|
573
574
|
const isReadonly = disabled || readOnly;
|
|
574
575
|
const onKeyPress = e => {
|
|
575
576
|
var _a, _b;
|
|
@@ -581,20 +582,15 @@ const Checkbox = React__namespace.forwardRef(({ className, dataTestId = "checkbo
|
|
|
581
582
|
(_b = internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
582
583
|
}
|
|
583
584
|
};
|
|
584
|
-
const [labelRef, setLabelRef] = React__namespace.useState(null);
|
|
585
|
-
React__namespace.useEffect(() => {
|
|
586
|
-
onLabelRefChange && labelRef && onLabelRefChange(labelRef);
|
|
587
|
-
}, [labelRef, onLabelRefChange]);
|
|
588
585
|
const uuid = rest.id;
|
|
589
586
|
return (jsxRuntime.jsxs("label", { className: cvaCheckboxContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-container` : null, htmlFor: uuid, onClick: e => stopPropagation && e.stopPropagation(), onKeyDown: onKeyPress, ref: internalRef, children: [jsxRuntime.jsx("input", { "aria-checked": !indeterminate && checked, checked: !indeterminate && checked, className: cvaCheckboxInput(), "data-testid": dataTestId, disabled: disabled, id: uuid, onChange: onChange, readOnly: readOnly, type: "checkbox", ...rest, ref: ref }), jsxRuntime.jsx("span", { className: cvaCheckbox({
|
|
590
587
|
disabled: isReadonly,
|
|
591
588
|
invalid: isReadonly ? false : isInvalid,
|
|
592
589
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
593
|
-
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label ? (jsxRuntime.jsx(
|
|
590
|
+
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: "w-full", disabled: !textIsCutOff, label: label, placement: "top", children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
594
591
|
invalid: isReadonly ? false : isInvalid,
|
|
595
592
|
disabled: isReadonly,
|
|
596
|
-
|
|
597
|
-
}), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })) : null, suffix] }));
|
|
593
|
+
}), id: `checkbox-label-${label}`, ref: labelRef, children: label }) }, "tooltip-" + rest.name)) : null, suffix] }));
|
|
598
594
|
});
|
|
599
595
|
Checkbox.displayName = "Checkbox";
|
|
600
596
|
|
|
@@ -1420,9 +1416,25 @@ const cvaRadioItem = cssClassVarianceUtilities.cvaMerge([
|
|
|
1420
1416
|
},
|
|
1421
1417
|
],
|
|
1422
1418
|
});
|
|
1423
|
-
const cvaRadioItemWrapper = cssClassVarianceUtilities.cvaMerge([
|
|
1424
|
-
|
|
1425
|
-
|
|
1419
|
+
const cvaRadioItemWrapper = cssClassVarianceUtilities.cvaMerge([
|
|
1420
|
+
"items-center",
|
|
1421
|
+
"gap-2",
|
|
1422
|
+
"group",
|
|
1423
|
+
"grid",
|
|
1424
|
+
"grid-cols-min-fr",
|
|
1425
|
+
"has-[:nth-child(3)]:grid-cols-min-fr-min", //if there's 3 children
|
|
1426
|
+
]);
|
|
1427
|
+
const cvaRadioItemLabelContainer = cssClassVarianceUtilities.cvaMerge(["grid", "flex-grow"]);
|
|
1428
|
+
const cvaRadioItemDescription = cssClassVarianceUtilities.cvaMerge([
|
|
1429
|
+
"-mt-1",
|
|
1430
|
+
"text-sm",
|
|
1431
|
+
"font-normal",
|
|
1432
|
+
"text-slate-500",
|
|
1433
|
+
"text-left",
|
|
1434
|
+
"whitespace-nowrap",
|
|
1435
|
+
"text-ellipsis",
|
|
1436
|
+
"overflow-hidden",
|
|
1437
|
+
], {
|
|
1426
1438
|
variants: {
|
|
1427
1439
|
disabled: {
|
|
1428
1440
|
true: ["text-slate-400", "hover:text-slate-400", "group-hover:text-slate-400"],
|
|
@@ -1463,14 +1475,21 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
1463
1475
|
* @param {RadioItemProps} props - The props for the RadioItem component
|
|
1464
1476
|
* @returns {JSX.Element} RadioItem component
|
|
1465
1477
|
*/
|
|
1466
|
-
const RadioItem = ({ label, value, dataTestId, className, description, }) => {
|
|
1478
|
+
const RadioItem = ({ label, value, dataTestId, className, description, suffix, ...rest }) => {
|
|
1467
1479
|
const groupCtx = React__namespace.useContext(RadioGroupContext);
|
|
1468
1480
|
const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
|
|
1481
|
+
const labelRef = React__namespace.useRef(null);
|
|
1482
|
+
const descriptionRef = React__namespace.useRef(null);
|
|
1483
|
+
const labelTextIsCutOff = reactComponents.useIsTextCutOff(labelRef.current);
|
|
1484
|
+
const descriptionTextIsCutOff = reactComponents.useIsTextCutOff(descriptionRef.current);
|
|
1469
1485
|
return (jsxRuntime.jsxs("label", { className: cvaRadioItemWrapper({ className }), "data-testid": dataTestId ? `${dataTestId}-Wrapper` : null, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: [jsxRuntime.jsx("input", { checked: isChecked, className: cvaRadioItem({
|
|
1470
1486
|
checked: isChecked,
|
|
1471
1487
|
disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
|
|
1472
1488
|
invalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid,
|
|
1473
|
-
}), "data-testid": dataTestId, id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, type: "radio", value: value }), jsxRuntime.jsxs("div", { className: cvaRadioItemLabelContainer(), children: [jsxRuntime.jsx(
|
|
1489
|
+
}), "data-testid": dataTestId, id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, type: "radio", value: value, ...rest }), jsxRuntime.jsxs("div", { className: cvaRadioItemLabelContainer(), children: [jsxRuntime.jsx(reactComponents.Tooltip, { className: "w-full", disabled: !labelTextIsCutOff, label: label, placement: "top", children: jsxRuntime.jsx("label", { className: cvaLabel({
|
|
1490
|
+
invalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid,
|
|
1491
|
+
disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
|
|
1492
|
+
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, ref: labelRef, children: label }) }, "tooltip-" + rest.name), description ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: "w-full", disabled: !descriptionTextIsCutOff, label: description, placement: "top", children: jsxRuntime.jsx("label", { className: cvaRadioItemDescription({ disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled }), "data-testid": dataTestId ? `${dataTestId}-Description` : null, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, ref: descriptionRef, children: description }) }, "description-tooltip-" + rest.name)) : null] }), suffix] }));
|
|
1474
1493
|
};
|
|
1475
1494
|
|
|
1476
1495
|
const cvaTimeRange = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1846,8 +1865,8 @@ const getOrderedOptions = (options, value) => {
|
|
|
1846
1865
|
* @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
|
|
1847
1866
|
* @returns {JSX.Element} SingleSelectMenuItem
|
|
1848
1867
|
*/
|
|
1849
|
-
const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId,
|
|
1850
|
-
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId, disabled: disabled,
|
|
1868
|
+
const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, disabled, }) => {
|
|
1869
|
+
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId, disabled: disabled, label: label, onClick: onClick, prefix: icon, selected: selected, suffix: selected ? jsxRuntime.jsx(reactComponents.Icon, { name: "Check", size: "small" }) : undefined }));
|
|
1851
1870
|
};
|
|
1852
1871
|
/**
|
|
1853
1872
|
* A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
|
|
@@ -1855,8 +1874,8 @@ const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focu
|
|
|
1855
1874
|
* @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
|
|
1856
1875
|
* @returns {JSX.Element} multi select menu item
|
|
1857
1876
|
*/
|
|
1858
|
-
const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId,
|
|
1859
|
-
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId, disabled: disabled,
|
|
1877
|
+
const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId, disabled }) => {
|
|
1878
|
+
return (jsxRuntime.jsx(reactComponents.MenuItem, { dataTestId: dataTestId, disabled: disabled, label: label, onClick: e => {
|
|
1860
1879
|
e.stopPropagation();
|
|
1861
1880
|
onClick && onClick(e);
|
|
1862
1881
|
}, prefix: jsxRuntime.jsx(Checkbox, { checked: selected, disabled: disabled, onChange: () => null, onClick: e => {
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useNamespaceTranslation, registerTranslations, NamespaceTrans } from '@trackunit/i18n-library-translation';
|
|
3
|
-
import { IconButton, Icon, Tooltip, Heading, Text, MenuItem, Tag, Spinner, useIsFirstRender } from '@trackunit/react-components';
|
|
3
|
+
import { IconButton, Icon, Tooltip, useIsTextCutOff, Heading, Text, MenuItem, Tag, Spinner, useIsFirstRender } from '@trackunit/react-components';
|
|
4
4
|
import { useCopyToClipboard } from 'react-use';
|
|
5
5
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
6
6
|
import * as React from 'react';
|
|
@@ -515,13 +515,12 @@ const cvaCheckbox = cvaMerge([
|
|
|
515
515
|
},
|
|
516
516
|
});
|
|
517
517
|
const cvaCheckboxContainer = cvaMerge([
|
|
518
|
-
"grid",
|
|
519
|
-
"outline-none",
|
|
520
|
-
"grid-cols-min-fr",
|
|
521
518
|
"items-center",
|
|
522
519
|
"gap-2",
|
|
523
|
-
"cursor-pointer",
|
|
524
520
|
"group",
|
|
521
|
+
"grid",
|
|
522
|
+
"grid-cols-min-fr",
|
|
523
|
+
"has-[:nth-child(3)]:grid-cols-min-fr-min", //if there's 3 children
|
|
525
524
|
]);
|
|
526
525
|
const cvaCheckboxInput = cvaMerge(["absolute", "opacity-0", "m-0", "pointer-events-none", "hidden"]);
|
|
527
526
|
const cvaCheckboxIcon = cvaMerge(["w-2.5", "h-2.5", "text-white"]);
|
|
@@ -548,9 +547,11 @@ const IndeterminateIcon = ({ className }) => (jsx("svg", { className: className,
|
|
|
548
547
|
* @param {CheckboxProps} props - The props for the Checkbox component
|
|
549
548
|
* @returns {JSX.Element} Checkbox component
|
|
550
549
|
*/
|
|
551
|
-
const Checkbox = React.forwardRef(({ className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0,
|
|
550
|
+
const Checkbox = React.forwardRef(({ className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, stopPropagation, ...rest }, ref) => {
|
|
552
551
|
const icon = indeterminate ? (jsx(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsx(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
553
552
|
const internalRef = React.useRef(null);
|
|
553
|
+
const labelRef = React.useRef(null);
|
|
554
|
+
const textIsCutOff = useIsTextCutOff(labelRef.current);
|
|
554
555
|
const isReadonly = disabled || readOnly;
|
|
555
556
|
const onKeyPress = e => {
|
|
556
557
|
var _a, _b;
|
|
@@ -562,20 +563,15 @@ const Checkbox = React.forwardRef(({ className, dataTestId = "checkbox", onChang
|
|
|
562
563
|
(_b = internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
563
564
|
}
|
|
564
565
|
};
|
|
565
|
-
const [labelRef, setLabelRef] = React.useState(null);
|
|
566
|
-
React.useEffect(() => {
|
|
567
|
-
onLabelRefChange && labelRef && onLabelRefChange(labelRef);
|
|
568
|
-
}, [labelRef, onLabelRefChange]);
|
|
569
566
|
const uuid = rest.id;
|
|
570
567
|
return (jsxs("label", { className: cvaCheckboxContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-container` : null, htmlFor: uuid, onClick: e => stopPropagation && e.stopPropagation(), onKeyDown: onKeyPress, ref: internalRef, children: [jsx("input", { "aria-checked": !indeterminate && checked, checked: !indeterminate && checked, className: cvaCheckboxInput(), "data-testid": dataTestId, disabled: disabled, id: uuid, onChange: onChange, readOnly: readOnly, type: "checkbox", ...rest, ref: ref }), jsx("span", { className: cvaCheckbox({
|
|
571
568
|
disabled: isReadonly,
|
|
572
569
|
invalid: isReadonly ? false : isInvalid,
|
|
573
570
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
574
|
-
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label ? (jsx(
|
|
571
|
+
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), label ? (jsx(Tooltip, { className: "w-full", disabled: !textIsCutOff, label: label, placement: "top", children: jsx("span", { className: cvaLabel({
|
|
575
572
|
invalid: isReadonly ? false : isInvalid,
|
|
576
573
|
disabled: isReadonly,
|
|
577
|
-
|
|
578
|
-
}), id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), children: label }) })) : null, suffix] }));
|
|
574
|
+
}), id: `checkbox-label-${label}`, ref: labelRef, children: label }) }, "tooltip-" + rest.name)) : null, suffix] }));
|
|
579
575
|
});
|
|
580
576
|
Checkbox.displayName = "Checkbox";
|
|
581
577
|
|
|
@@ -1401,9 +1397,25 @@ const cvaRadioItem = cvaMerge([
|
|
|
1401
1397
|
},
|
|
1402
1398
|
],
|
|
1403
1399
|
});
|
|
1404
|
-
const cvaRadioItemWrapper = cvaMerge([
|
|
1405
|
-
|
|
1406
|
-
|
|
1400
|
+
const cvaRadioItemWrapper = cvaMerge([
|
|
1401
|
+
"items-center",
|
|
1402
|
+
"gap-2",
|
|
1403
|
+
"group",
|
|
1404
|
+
"grid",
|
|
1405
|
+
"grid-cols-min-fr",
|
|
1406
|
+
"has-[:nth-child(3)]:grid-cols-min-fr-min", //if there's 3 children
|
|
1407
|
+
]);
|
|
1408
|
+
const cvaRadioItemLabelContainer = cvaMerge(["grid", "flex-grow"]);
|
|
1409
|
+
const cvaRadioItemDescription = cvaMerge([
|
|
1410
|
+
"-mt-1",
|
|
1411
|
+
"text-sm",
|
|
1412
|
+
"font-normal",
|
|
1413
|
+
"text-slate-500",
|
|
1414
|
+
"text-left",
|
|
1415
|
+
"whitespace-nowrap",
|
|
1416
|
+
"text-ellipsis",
|
|
1417
|
+
"overflow-hidden",
|
|
1418
|
+
], {
|
|
1407
1419
|
variants: {
|
|
1408
1420
|
disabled: {
|
|
1409
1421
|
true: ["text-slate-400", "hover:text-slate-400", "group-hover:text-slate-400"],
|
|
@@ -1444,14 +1456,21 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
1444
1456
|
* @param {RadioItemProps} props - The props for the RadioItem component
|
|
1445
1457
|
* @returns {JSX.Element} RadioItem component
|
|
1446
1458
|
*/
|
|
1447
|
-
const RadioItem = ({ label, value, dataTestId, className, description, }) => {
|
|
1459
|
+
const RadioItem = ({ label, value, dataTestId, className, description, suffix, ...rest }) => {
|
|
1448
1460
|
const groupCtx = React.useContext(RadioGroupContext);
|
|
1449
1461
|
const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
|
|
1462
|
+
const labelRef = React.useRef(null);
|
|
1463
|
+
const descriptionRef = React.useRef(null);
|
|
1464
|
+
const labelTextIsCutOff = useIsTextCutOff(labelRef.current);
|
|
1465
|
+
const descriptionTextIsCutOff = useIsTextCutOff(descriptionRef.current);
|
|
1450
1466
|
return (jsxs("label", { className: cvaRadioItemWrapper({ className }), "data-testid": dataTestId ? `${dataTestId}-Wrapper` : null, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, children: [jsx("input", { checked: isChecked, className: cvaRadioItem({
|
|
1451
1467
|
checked: isChecked,
|
|
1452
1468
|
disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
|
|
1453
1469
|
invalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid,
|
|
1454
|
-
}), "data-testid": dataTestId, id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, type: "radio", value: value }), jsxs("div", { className: cvaRadioItemLabelContainer(), children: [jsx(
|
|
1470
|
+
}), "data-testid": dataTestId, id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, type: "radio", value: value, ...rest }), jsxs("div", { className: cvaRadioItemLabelContainer(), children: [jsx(Tooltip, { className: "w-full", disabled: !labelTextIsCutOff, label: label, placement: "top", children: jsx("label", { className: cvaLabel({
|
|
1471
|
+
invalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid,
|
|
1472
|
+
disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
|
|
1473
|
+
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, ref: labelRef, children: label }) }, "tooltip-" + rest.name), description ? (jsx(Tooltip, { className: "w-full", disabled: !descriptionTextIsCutOff, label: description, placement: "top", children: jsx("label", { className: cvaRadioItemDescription({ disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled }), "data-testid": dataTestId ? `${dataTestId}-Description` : null, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id}-${value}`, ref: descriptionRef, children: description }) }, "description-tooltip-" + rest.name)) : null] }), suffix] }));
|
|
1455
1474
|
};
|
|
1456
1475
|
|
|
1457
1476
|
const cvaTimeRange = cvaMerge([
|
|
@@ -1827,8 +1846,8 @@ const getOrderedOptions = (options, value) => {
|
|
|
1827
1846
|
* @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
|
|
1828
1847
|
* @returns {JSX.Element} SingleSelectMenuItem
|
|
1829
1848
|
*/
|
|
1830
|
-
const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId,
|
|
1831
|
-
return (jsx(MenuItem, { dataTestId: dataTestId, disabled: disabled,
|
|
1849
|
+
const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, disabled, }) => {
|
|
1850
|
+
return (jsx(MenuItem, { dataTestId: dataTestId, disabled: disabled, label: label, onClick: onClick, prefix: icon, selected: selected, suffix: selected ? jsx(Icon, { name: "Check", size: "small" }) : undefined }));
|
|
1832
1851
|
};
|
|
1833
1852
|
/**
|
|
1834
1853
|
* A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
|
|
@@ -1836,8 +1855,8 @@ const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focu
|
|
|
1836
1855
|
* @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
|
|
1837
1856
|
* @returns {JSX.Element} multi select menu item
|
|
1838
1857
|
*/
|
|
1839
|
-
const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId,
|
|
1840
|
-
return (jsx(MenuItem, { dataTestId: dataTestId, disabled: disabled,
|
|
1858
|
+
const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId, disabled }) => {
|
|
1859
|
+
return (jsx(MenuItem, { dataTestId: dataTestId, disabled: disabled, label: label, onClick: e => {
|
|
1841
1860
|
e.stopPropagation();
|
|
1842
1861
|
onClick && onClick(e);
|
|
1843
1862
|
}, prefix: jsx(Checkbox, { checked: selected, disabled: disabled, onChange: () => null, onClick: e => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import { MappedOmit } from "@trackunit/shared-utils";
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
export interface CheckboxProps extends CommonProps, React.InputHTMLAttributes<HTMLInputElement> {
|
|
4
|
+
export interface CheckboxProps extends CommonProps, MappedOmit<React.InputHTMLAttributes<HTMLInputElement>, "prefix"> {
|
|
4
5
|
/**
|
|
5
6
|
* A string element to be displayed as a label
|
|
6
7
|
*/
|
|
@@ -30,10 +31,6 @@ export interface CheckboxProps extends CommonProps, React.InputHTMLAttributes<HT
|
|
|
30
31
|
* An boolean flag to set checkbox to intermediate state
|
|
31
32
|
*/
|
|
32
33
|
indeterminate?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* A function returning the label ref
|
|
35
|
-
*/
|
|
36
|
-
onLabelRefChange?: (label: HTMLElement) => void;
|
|
37
34
|
/**
|
|
38
35
|
* An boolean flag to stop propagation of the click event
|
|
39
36
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import { MappedOmit } from "@trackunit/shared-utils";
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
export interface RadioItemProps<V extends string | number = string> extends CommonProps {
|
|
4
|
+
export interface RadioItemProps<V extends string | number = string> extends CommonProps, MappedOmit<React.InputHTMLAttributes<HTMLInputElement>, "prefix"> {
|
|
4
5
|
/**
|
|
5
6
|
* The label of the radio item.
|
|
6
7
|
*/
|
|
@@ -13,6 +14,10 @@ export interface RadioItemProps<V extends string | number = string> extends Comm
|
|
|
13
14
|
* The description of the radio item.
|
|
14
15
|
*/
|
|
15
16
|
description?: string;
|
|
17
|
+
/**
|
|
18
|
+
* An element to display after the label
|
|
19
|
+
*/
|
|
20
|
+
suffix?: React.ReactNode;
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* The RadioItem component.
|
|
@@ -20,4 +25,4 @@ export interface RadioItemProps<V extends string | number = string> extends Comm
|
|
|
20
25
|
* @param {RadioItemProps} props - The props for the RadioItem component
|
|
21
26
|
* @returns {JSX.Element} RadioItem component
|
|
22
27
|
*/
|
|
23
|
-
export declare const RadioItem: <V extends string | number>({ label, value, dataTestId, className, description, }: RadioItemProps<V>) => JSX.Element;
|
|
28
|
+
export declare const RadioItem: <V extends string | number>({ label, value, dataTestId, className, description, suffix, ...rest }: RadioItemProps<V>) => JSX.Element;
|
|
@@ -14,11 +14,6 @@ interface SelectMenuItemProps extends CommonProps {
|
|
|
14
14
|
* A boolean prop to set menu item to selected state
|
|
15
15
|
*/
|
|
16
16
|
selected?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* A boolean prop to allow menu item to have focus ring
|
|
19
|
-
* used for keyboard navigation
|
|
20
|
-
*/
|
|
21
|
-
focusRing?: boolean;
|
|
22
17
|
/**
|
|
23
18
|
* A boolean prop to set menu item to disabled state
|
|
24
19
|
* used in disabled select options
|
|
@@ -38,12 +33,12 @@ export interface SingleSelectMenuItemProps extends SelectMenuItemProps {
|
|
|
38
33
|
* @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
|
|
39
34
|
* @returns {JSX.Element} SingleSelectMenuItem
|
|
40
35
|
*/
|
|
41
|
-
export declare const SingleSelectMenuItem: ({ label, icon, onClick, selected, dataTestId,
|
|
36
|
+
export declare const SingleSelectMenuItem: ({ label, icon, onClick, selected, dataTestId, disabled, }: SingleSelectMenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
42
37
|
/**
|
|
43
38
|
* A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
|
|
44
39
|
*
|
|
45
40
|
* @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
|
|
46
41
|
* @returns {JSX.Element} multi select menu item
|
|
47
42
|
*/
|
|
48
|
-
export declare const MultiSelectMenuItem: ({ label, onClick, selected, dataTestId,
|
|
43
|
+
export declare const MultiSelectMenuItem: ({ label, onClick, selected, dataTestId, disabled }: SelectMenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
44
|
export {};
|