@trackunit/react-form-components 0.0.145 → 0.0.147
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 +11 -9
- package/index.esm.js +11 -9
- package/package.json +4 -4
- package/src/components/Checkbox/Checkbox.d.ts +4 -0
package/index.cjs.js
CHANGED
|
@@ -276,9 +276,7 @@ const BaseInput = React__namespace.forwardRef((_a, ref) => {
|
|
|
276
276
|
const cvaLabel = cssClassVarianceUtilities.cvaMerge([
|
|
277
277
|
"text-base",
|
|
278
278
|
"text-slate-700",
|
|
279
|
-
"
|
|
280
|
-
"whitespace-nowrap",
|
|
281
|
-
"text-ellipsis",
|
|
279
|
+
"truncate",
|
|
282
280
|
"hover:text-slate-800",
|
|
283
281
|
"group-hover:text-slate-800",
|
|
284
282
|
"active:text-slate-800",
|
|
@@ -457,7 +455,7 @@ const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", { xmlns: "ht
|
|
|
457
455
|
* @returns {JSX.Element} Checkbox component
|
|
458
456
|
*/
|
|
459
457
|
const Checkbox = React__namespace.forwardRef((_a, ref) => {
|
|
460
|
-
var { className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0 } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "suffix", "label", "tabIndex"]);
|
|
458
|
+
var { className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, onLabelRefChange } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "suffix", "label", "tabIndex", "onLabelRefChange"]);
|
|
461
459
|
const icon = indeterminate ? (jsxRuntime.jsx(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsxRuntime.jsx(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
462
460
|
const internalRef = React__namespace.useRef(null);
|
|
463
461
|
const isReadonly = disabled || readOnly;
|
|
@@ -471,16 +469,20 @@ const Checkbox = React__namespace.forwardRef((_a, ref) => {
|
|
|
471
469
|
(_b = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
472
470
|
}
|
|
473
471
|
};
|
|
472
|
+
const [labelRef, setLabelRef] = React__namespace.useState(null);
|
|
473
|
+
React__namespace.useEffect(() => {
|
|
474
|
+
onLabelRefChange && labelRef && onLabelRefChange(labelRef);
|
|
475
|
+
}, [labelRef, onLabelRefChange]);
|
|
474
476
|
const uuid = rest.id;
|
|
475
477
|
return (jsxRuntime.jsxs("label", { "data-testid": dataTestId && `${dataTestId}-container`, htmlFor: uuid, className: cvaCheckboxContainer({ className }), ref: internalRef, onKeyPress: onKeyPress, children: [jsxRuntime.jsx("input", Object.assign({ type: "checkbox", className: cvaCheckboxInput(), checked: !indeterminate && checked, onChange: onChange, disabled: disabled, "data-testid": dataTestId, readOnly: readOnly, "aria-checked": !indeterminate && checked, id: uuid }, rest, { ref: ref })), jsxRuntime.jsx("span", { id: uuid, tabIndex: isReadonly ? -1 : tabIndex, className: cvaCheckbox({
|
|
476
478
|
disabled: isReadonly,
|
|
477
479
|
invalid: isReadonly ? false : isInvalid,
|
|
478
480
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
479
|
-
}), children: icon }), label && (jsxRuntime.jsx("span", { className: cvaLabel({
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
481
|
+
}), children: icon }), label && (jsxRuntime.jsx("span", { className: "flex", children: jsxRuntime.jsx("span", { id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), className: cvaLabel({
|
|
482
|
+
invalid: isReadonly ? false : isInvalid,
|
|
483
|
+
disabled: isReadonly,
|
|
484
|
+
className: "cursor-pointer",
|
|
485
|
+
}), children: label }) })), suffix] }));
|
|
484
486
|
});
|
|
485
487
|
|
|
486
488
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
package/index.esm.js
CHANGED
|
@@ -250,9 +250,7 @@ const BaseInput = React.forwardRef((_a, ref) => {
|
|
|
250
250
|
const cvaLabel = cvaMerge([
|
|
251
251
|
"text-base",
|
|
252
252
|
"text-slate-700",
|
|
253
|
-
"
|
|
254
|
-
"whitespace-nowrap",
|
|
255
|
-
"text-ellipsis",
|
|
253
|
+
"truncate",
|
|
256
254
|
"hover:text-slate-800",
|
|
257
255
|
"group-hover:text-slate-800",
|
|
258
256
|
"active:text-slate-800",
|
|
@@ -431,7 +429,7 @@ const IndeterminateIcon = ({ className }) => (jsx$1("svg", { xmlns: "http://www.
|
|
|
431
429
|
* @returns {JSX.Element} Checkbox component
|
|
432
430
|
*/
|
|
433
431
|
const Checkbox = React.forwardRef((_a, ref) => {
|
|
434
|
-
var { className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0 } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "suffix", "label", "tabIndex"]);
|
|
432
|
+
var { className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, onLabelRefChange } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "suffix", "label", "tabIndex", "onLabelRefChange"]);
|
|
435
433
|
const icon = indeterminate ? (jsx$1(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsx$1(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
436
434
|
const internalRef = React.useRef(null);
|
|
437
435
|
const isReadonly = disabled || readOnly;
|
|
@@ -445,16 +443,20 @@ const Checkbox = React.forwardRef((_a, ref) => {
|
|
|
445
443
|
(_b = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _b === void 0 ? void 0 : _b.click();
|
|
446
444
|
}
|
|
447
445
|
};
|
|
446
|
+
const [labelRef, setLabelRef] = React.useState(null);
|
|
447
|
+
React.useEffect(() => {
|
|
448
|
+
onLabelRefChange && labelRef && onLabelRefChange(labelRef);
|
|
449
|
+
}, [labelRef, onLabelRefChange]);
|
|
448
450
|
const uuid = rest.id;
|
|
449
451
|
return (jsxs("label", { "data-testid": dataTestId && `${dataTestId}-container`, htmlFor: uuid, className: cvaCheckboxContainer({ className }), ref: internalRef, onKeyPress: onKeyPress, children: [jsx$1("input", Object.assign({ type: "checkbox", className: cvaCheckboxInput(), checked: !indeterminate && checked, onChange: onChange, disabled: disabled, "data-testid": dataTestId, readOnly: readOnly, "aria-checked": !indeterminate && checked, id: uuid }, rest, { ref: ref })), jsx$1("span", { id: uuid, tabIndex: isReadonly ? -1 : tabIndex, className: cvaCheckbox({
|
|
450
452
|
disabled: isReadonly,
|
|
451
453
|
invalid: isReadonly ? false : isInvalid,
|
|
452
454
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
453
|
-
}), children: icon }), label && (jsx$1("span", { className: cvaLabel({
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
455
|
+
}), children: icon }), label && (jsx$1("span", { className: "flex", children: jsx$1("span", { id: `checkbox-label-${label}`, ref: labelReference => setLabelRef(labelReference), className: cvaLabel({
|
|
456
|
+
invalid: isReadonly ? false : isInvalid,
|
|
457
|
+
disabled: isReadonly,
|
|
458
|
+
className: "cursor-pointer",
|
|
459
|
+
}), children: label }) })), suffix] }));
|
|
458
460
|
});
|
|
459
461
|
|
|
460
462
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.147",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@trackunit/css-class-variance-utilities": "0.0.14",
|
|
11
|
-
"@trackunit/i18n-library-translation": "0.0.
|
|
12
|
-
"@trackunit/react-components": "0.1.
|
|
13
|
-
"@trackunit/shared-utils": "0.0.
|
|
11
|
+
"@trackunit/i18n-library-translation": "0.0.79",
|
|
12
|
+
"@trackunit/react-components": "0.1.161",
|
|
13
|
+
"@trackunit/shared-utils": "0.0.8",
|
|
14
14
|
"@trackunit/ui-icons": "0.0.76",
|
|
15
15
|
"date-fns": "2.29.3",
|
|
16
16
|
"libphonenumber-js": "1.10.36",
|
|
@@ -30,6 +30,10 @@ export interface CheckboxProps extends CommonProps, React.InputHTMLAttributes<HT
|
|
|
30
30
|
* An boolean flag to set checkbox to intermediate state
|
|
31
31
|
*/
|
|
32
32
|
indeterminate?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* A function returning the label ref
|
|
35
|
+
*/
|
|
36
|
+
onLabelRefChange?: (label: HTMLElement) => void;
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Checkboxes are used when there are multiple items to select in a list. Users can select zero, one, or any number of items.
|