@trackunit/react-form-components 1.0.20 → 1.0.25
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 +6 -9
- package/index.esm.js +7 -10
- package/package.json +6 -6
package/index.cjs.js
CHANGED
|
@@ -581,8 +581,7 @@ const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", { className:
|
|
|
581
581
|
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) => {
|
|
582
582
|
const icon = indeterminate ? (jsxRuntime.jsx(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsxRuntime.jsx(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
583
583
|
const internalRef = React__namespace.useRef(null);
|
|
584
|
-
const labelRef =
|
|
585
|
-
const textIsCutOff = reactComponents.useIsTextCutOff(labelRef);
|
|
584
|
+
const { isTextTruncated: isLabelCutOff, ref: labelRef } = reactComponents.useIsTextTruncated();
|
|
586
585
|
const isReadonly = disabled || readOnly;
|
|
587
586
|
const onKeyPress = e => {
|
|
588
587
|
if ("Space" === e.code) {
|
|
@@ -598,7 +597,7 @@ const Checkbox = React__namespace.forwardRef(({ className, dataTestId = "checkbo
|
|
|
598
597
|
disabled: isReadonly,
|
|
599
598
|
invalid: isReadonly ? false : isInvalid,
|
|
600
599
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
601
|
-
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), jsxRuntime.jsx(reactComponents.Tooltip, { className: "w-full", disabled: !
|
|
600
|
+
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), jsxRuntime.jsx(reactComponents.Tooltip, { className: "w-full", disabled: !isLabelCutOff, label: label, placement: "top", children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
602
601
|
invalid: isReadonly ? false : isInvalid,
|
|
603
602
|
disabled: isReadonly,
|
|
604
603
|
}), id: `checkbox-label-${label}`, ref: labelRef, children: label }) }, "tooltip-" + rest.name), suffix] }));
|
|
@@ -1485,20 +1484,18 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
1485
1484
|
const RadioItem = ({ label, value, dataTestId, className, description, suffix, ...rest }) => {
|
|
1486
1485
|
const groupCtx = React.useContext(RadioGroupContext);
|
|
1487
1486
|
const isChecked = groupCtx?.value === value;
|
|
1488
|
-
const labelRef =
|
|
1489
|
-
const descriptionRef =
|
|
1490
|
-
const labelTextIsCutOff = reactComponents.useIsTextCutOff(labelRef);
|
|
1491
|
-
const descriptionTextIsCutOff = reactComponents.useIsTextCutOff(descriptionRef);
|
|
1487
|
+
const { ref: labelRef, isTextTruncated: isLabelTruncated } = reactComponents.useIsTextTruncated();
|
|
1488
|
+
const { ref: descriptionRef, isTextTruncated: isDescriptionTruncated } = reactComponents.useIsTextTruncated();
|
|
1492
1489
|
const descriptionId = description ? `${groupCtx?.id}-${value}-description` : undefined;
|
|
1493
1490
|
const inputId = `${groupCtx?.id}-${value}`;
|
|
1494
1491
|
return (jsxRuntime.jsxs("label", { className: cvaRadioItemWrapper({ className }), "data-testid": dataTestId ? `${dataTestId}-Wrapper` : undefined, htmlFor: inputId, children: [jsxRuntime.jsx("input", { "aria-describedby": descriptionId, checked: isChecked, className: cvaRadioItem({
|
|
1495
1492
|
checked: isChecked,
|
|
1496
1493
|
disabled: groupCtx?.disabled,
|
|
1497
1494
|
invalid: groupCtx?.isInvalid,
|
|
1498
|
-
}), "data-testid": dataTestId, id: inputId, onChange: groupCtx?.onChange, type: "radio", value: value, ...rest }), jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaLabelTooltip(), dataTestId: dataTestId ? `${dataTestId}-Label-Tooltip` : undefined, disabled: !
|
|
1495
|
+
}), "data-testid": dataTestId, id: inputId, onChange: groupCtx?.onChange, type: "radio", value: value, ...rest }), jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaLabelTooltip(), dataTestId: dataTestId ? `${dataTestId}-Label-Tooltip` : undefined, disabled: !isLabelTruncated, label: label, placement: "top", children: jsxRuntime.jsx("span", { className: cvaLabel({
|
|
1499
1496
|
invalid: groupCtx?.isInvalid,
|
|
1500
1497
|
disabled: groupCtx?.disabled,
|
|
1501
|
-
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, ref: labelRef, children: label }) }, "tooltip-" + rest.name), suffix ? (jsxRuntime.jsx("div", { className: cvaSuffixContainer(), "data-testid": dataTestId ? `${dataTestId}-suffix-container` : undefined, children: suffix })) : null, description ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaDescriptionTooltip(), dataTestId: dataTestId ? `${dataTestId}-Description-Tooltip` : undefined, disabled: !
|
|
1498
|
+
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, ref: labelRef, children: label }) }, "tooltip-" + rest.name), suffix ? (jsxRuntime.jsx("div", { className: cvaSuffixContainer(), "data-testid": dataTestId ? `${dataTestId}-suffix-container` : undefined, children: suffix })) : null, description ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: cvaDescriptionTooltip(), dataTestId: dataTestId ? `${dataTestId}-Description-Tooltip` : undefined, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsxRuntime.jsx("span", { className: cvaRadioItemDescription({ disabled: groupCtx?.disabled }), "data-testid": dataTestId ? `${dataTestId}-Description` : undefined, id: descriptionId, ref: descriptionRef, children: description }) }, "description-tooltip-" + rest.name)) : null] }));
|
|
1502
1499
|
};
|
|
1503
1500
|
|
|
1504
1501
|
const cvaTimeRange = cssClassVarianceUtilities.cvaMerge([
|
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,
|
|
3
|
+
import { IconButton, Icon, Tooltip, useIsTextTruncated, Heading, Text, Spinner, MenuItem, Tag, useIsFirstRender } from '@trackunit/react-components';
|
|
4
4
|
import { useCopyToClipboard } from 'usehooks-ts';
|
|
5
5
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
6
6
|
import * as React from 'react';
|
|
@@ -562,8 +562,7 @@ const IndeterminateIcon = ({ className }) => (jsx("svg", { className: className,
|
|
|
562
562
|
const Checkbox = React.forwardRef(({ className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, stopPropagation, ...rest }, ref) => {
|
|
563
563
|
const icon = indeterminate ? (jsx(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsx(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
564
564
|
const internalRef = React.useRef(null);
|
|
565
|
-
const labelRef =
|
|
566
|
-
const textIsCutOff = useIsTextCutOff(labelRef);
|
|
565
|
+
const { isTextTruncated: isLabelCutOff, ref: labelRef } = useIsTextTruncated();
|
|
567
566
|
const isReadonly = disabled || readOnly;
|
|
568
567
|
const onKeyPress = e => {
|
|
569
568
|
if ("Space" === e.code) {
|
|
@@ -579,7 +578,7 @@ const Checkbox = React.forwardRef(({ className, dataTestId = "checkbox", onChang
|
|
|
579
578
|
disabled: isReadonly,
|
|
580
579
|
invalid: isReadonly ? false : isInvalid,
|
|
581
580
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
582
|
-
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), jsx(Tooltip, { className: "w-full", disabled: !
|
|
581
|
+
}), id: uuid, tabIndex: isReadonly ? -1 : tabIndex, children: icon }), jsx(Tooltip, { className: "w-full", disabled: !isLabelCutOff, label: label, placement: "top", children: jsx("span", { className: cvaLabel({
|
|
583
582
|
invalid: isReadonly ? false : isInvalid,
|
|
584
583
|
disabled: isReadonly,
|
|
585
584
|
}), id: `checkbox-label-${label}`, ref: labelRef, children: label }) }, "tooltip-" + rest.name), suffix] }));
|
|
@@ -1466,20 +1465,18 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
1466
1465
|
const RadioItem = ({ label, value, dataTestId, className, description, suffix, ...rest }) => {
|
|
1467
1466
|
const groupCtx = useContext(RadioGroupContext);
|
|
1468
1467
|
const isChecked = groupCtx?.value === value;
|
|
1469
|
-
const labelRef =
|
|
1470
|
-
const descriptionRef =
|
|
1471
|
-
const labelTextIsCutOff = useIsTextCutOff(labelRef);
|
|
1472
|
-
const descriptionTextIsCutOff = useIsTextCutOff(descriptionRef);
|
|
1468
|
+
const { ref: labelRef, isTextTruncated: isLabelTruncated } = useIsTextTruncated();
|
|
1469
|
+
const { ref: descriptionRef, isTextTruncated: isDescriptionTruncated } = useIsTextTruncated();
|
|
1473
1470
|
const descriptionId = description ? `${groupCtx?.id}-${value}-description` : undefined;
|
|
1474
1471
|
const inputId = `${groupCtx?.id}-${value}`;
|
|
1475
1472
|
return (jsxs("label", { className: cvaRadioItemWrapper({ className }), "data-testid": dataTestId ? `${dataTestId}-Wrapper` : undefined, htmlFor: inputId, children: [jsx("input", { "aria-describedby": descriptionId, checked: isChecked, className: cvaRadioItem({
|
|
1476
1473
|
checked: isChecked,
|
|
1477
1474
|
disabled: groupCtx?.disabled,
|
|
1478
1475
|
invalid: groupCtx?.isInvalid,
|
|
1479
|
-
}), "data-testid": dataTestId, id: inputId, onChange: groupCtx?.onChange, type: "radio", value: value, ...rest }), jsx(Tooltip, { className: cvaLabelTooltip(), dataTestId: dataTestId ? `${dataTestId}-Label-Tooltip` : undefined, disabled: !
|
|
1476
|
+
}), "data-testid": dataTestId, id: inputId, onChange: groupCtx?.onChange, type: "radio", value: value, ...rest }), jsx(Tooltip, { className: cvaLabelTooltip(), dataTestId: dataTestId ? `${dataTestId}-Label-Tooltip` : undefined, disabled: !isLabelTruncated, label: label, placement: "top", children: jsx("span", { className: cvaLabel({
|
|
1480
1477
|
invalid: groupCtx?.isInvalid,
|
|
1481
1478
|
disabled: groupCtx?.disabled,
|
|
1482
|
-
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, ref: labelRef, children: label }) }, "tooltip-" + rest.name), suffix ? (jsx("div", { className: cvaSuffixContainer(), "data-testid": dataTestId ? `${dataTestId}-suffix-container` : undefined, children: suffix })) : null, description ? (jsx(Tooltip, { className: cvaDescriptionTooltip(), dataTestId: dataTestId ? `${dataTestId}-Description-Tooltip` : undefined, disabled: !
|
|
1479
|
+
}), "data-testid": dataTestId ? `${dataTestId}-Label` : undefined, ref: labelRef, children: label }) }, "tooltip-" + rest.name), suffix ? (jsx("div", { className: cvaSuffixContainer(), "data-testid": dataTestId ? `${dataTestId}-suffix-container` : undefined, children: suffix })) : null, description ? (jsx(Tooltip, { className: cvaDescriptionTooltip(), dataTestId: dataTestId ? `${dataTestId}-Description-Tooltip` : undefined, disabled: !isDescriptionTruncated, label: description, placement: "top", children: jsx("span", { className: cvaRadioItemDescription({ disabled: groupCtx?.disabled }), "data-testid": dataTestId ? `${dataTestId}-Description` : undefined, id: descriptionId, ref: descriptionRef, children: description }) }, "description-tooltip-" + rest.name)) : null] }));
|
|
1483
1480
|
};
|
|
1484
1481
|
|
|
1485
1482
|
const cvaTimeRange = cvaMerge([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"zod": "3.22.4",
|
|
18
18
|
"react-hook-form": "7.53.1",
|
|
19
19
|
"tailwind-merge": "^2.0.0",
|
|
20
|
-
"@trackunit/css-class-variance-utilities": "
|
|
21
|
-
"@trackunit/react-components": "
|
|
22
|
-
"@trackunit/ui-icons": "
|
|
23
|
-
"@trackunit/shared-utils": "
|
|
24
|
-
"@trackunit/i18n-library-translation": "
|
|
20
|
+
"@trackunit/css-class-variance-utilities": "1.0.4",
|
|
21
|
+
"@trackunit/react-components": "1.1.7",
|
|
22
|
+
"@trackunit/ui-icons": "1.0.7",
|
|
23
|
+
"@trackunit/shared-utils": "1.2.1",
|
|
24
|
+
"@trackunit/i18n-library-translation": "1.0.13"
|
|
25
25
|
},
|
|
26
26
|
"module": "./index.esm.js",
|
|
27
27
|
"main": "./index.cjs.js",
|