@ttoss/ui 4.1.13 → 4.1.14

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/dist/esm/index.js CHANGED
@@ -494,28 +494,32 @@ import { Slider } from "theme-ui";
494
494
  import * as React6 from "react";
495
495
  import { Checkbox as CheckBoxUi } from "theme-ui";
496
496
  import { jsx as jsx9 } from "react/jsx-runtime";
497
- var Checkbox = ({
497
+ var Checkbox = /*#__PURE__*/React6.forwardRef(({
498
498
  indeterminate = false,
499
499
  ...rest
500
- }) => {
501
- const ref = React6.useRef(null);
500
+ }, ref) => {
501
+ const innerRef = React6.useRef(null);
502
+ React6.useImperativeHandle(ref, () => {
503
+ return innerRef.current;
504
+ });
502
505
  React6.useEffect(() => {
503
- if (ref.current) {
504
- ref.current.indeterminate = indeterminate;
506
+ if (innerRef.current) {
507
+ innerRef.current.indeterminate = indeterminate;
505
508
  }
506
509
  }, [indeterminate]);
507
510
  if (indeterminate) {
508
511
  return /* @__PURE__ */jsx9("input", {
509
512
  type: "checkbox",
510
- ref,
513
+ ref: innerRef,
511
514
  ...rest
512
515
  });
513
516
  }
514
517
  return /* @__PURE__ */jsx9(CheckBoxUi, {
515
- ref,
518
+ ref: innerRef,
516
519
  ...rest
517
520
  });
518
- };
521
+ });
522
+ Checkbox.displayName = "Checkbox";
519
523
 
520
524
  // src/components/InfiniteLinearProgress.tsx
521
525
  import * as React7 from "react";
package/dist/index.d.mts CHANGED
@@ -92,7 +92,7 @@ declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps,
92
92
  interface CheckboxProps extends CheckboxProps$1 {
93
93
  indeterminate?: boolean;
94
94
  }
95
- declare const Checkbox: ({ indeterminate, ...rest }: CheckboxProps) => react_jsx_runtime.JSX.Element;
95
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
96
96
 
97
97
  declare const InfiniteLinearProgress: () => react_jsx_runtime.JSX.Element;
98
98
 
package/dist/index.d.ts CHANGED
@@ -92,7 +92,7 @@ declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps,
92
92
  interface CheckboxProps extends CheckboxProps$1 {
93
93
  indeterminate?: boolean;
94
94
  }
95
- declare const Checkbox: ({ indeterminate, ...rest }: CheckboxProps) => react_jsx_runtime.JSX.Element;
95
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
96
96
 
97
97
  declare const InfiniteLinearProgress: () => react_jsx_runtime.JSX.Element;
98
98
 
package/dist/index.js CHANGED
@@ -570,28 +570,32 @@ var import_theme_ui20 = require("theme-ui");
570
570
  var React6 = __toESM(require("react"));
571
571
  var import_theme_ui21 = require("theme-ui");
572
572
  var import_jsx_runtime9 = require("react/jsx-runtime");
573
- var Checkbox = ({
573
+ var Checkbox = React6.forwardRef(({
574
574
  indeterminate = false,
575
575
  ...rest
576
- }) => {
577
- const ref = React6.useRef(null);
576
+ }, ref) => {
577
+ const innerRef = React6.useRef(null);
578
+ React6.useImperativeHandle(ref, () => {
579
+ return innerRef.current;
580
+ });
578
581
  React6.useEffect(() => {
579
- if (ref.current) {
580
- ref.current.indeterminate = indeterminate;
582
+ if (innerRef.current) {
583
+ innerRef.current.indeterminate = indeterminate;
581
584
  }
582
585
  }, [indeterminate]);
583
586
  if (indeterminate) {
584
587
  return /* @__PURE__ */(0, import_jsx_runtime9.jsx)("input", {
585
588
  type: "checkbox",
586
- ref,
589
+ ref: innerRef,
587
590
  ...rest
588
591
  });
589
592
  }
590
593
  return /* @__PURE__ */(0, import_jsx_runtime9.jsx)(import_theme_ui21.Checkbox, {
591
- ref,
594
+ ref: innerRef,
592
595
  ...rest
593
596
  });
594
- };
597
+ });
598
+ Checkbox.displayName = "Checkbox";
595
599
 
596
600
  // src/components/InfiniteLinearProgress.tsx
597
601
  var React7 = __toESM(require("react"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/ui",
3
- "version": "4.1.13",
3
+ "version": "4.1.14",
4
4
  "description": "Primitive layout, typographic, and other components for styling applications.",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -43,8 +43,8 @@
43
43
  "react": "^18.3.1",
44
44
  "tsup": "^8.1.0",
45
45
  "@ttoss/config": "^1.32.6",
46
- "@ttoss/test-utils": "^2.1.10",
47
- "@ttoss/react-icons": "^0.3.10"
46
+ "@ttoss/react-icons": "^0.3.10",
47
+ "@ttoss/test-utils": "^2.1.10"
48
48
  },
49
49
  "keywords": [
50
50
  "React",
@@ -8,18 +8,29 @@ export interface CheckboxProps extends CheckboxPropsUi {
8
8
  indeterminate?: boolean;
9
9
  }
10
10
 
11
- export const Checkbox = ({ indeterminate = false, ...rest }: CheckboxProps) => {
12
- const ref = React.useRef<HTMLInputElement>(null);
11
+ export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
12
+ ({ indeterminate = false, ...rest }, ref) => {
13
+ const innerRef = React.useRef<HTMLInputElement>(null);
13
14
 
14
- React.useEffect(() => {
15
- if (ref.current) {
16
- ref.current.indeterminate = indeterminate;
15
+ /**
16
+ * https://stackoverflow.com/a/68163315/8786986
17
+ */
18
+ React.useImperativeHandle(ref, () => {
19
+ return innerRef.current as HTMLInputElement;
20
+ });
21
+
22
+ React.useEffect(() => {
23
+ if (innerRef.current) {
24
+ innerRef.current.indeterminate = indeterminate;
25
+ }
26
+ }, [indeterminate]);
27
+
28
+ if (indeterminate) {
29
+ return <input type="checkbox" ref={innerRef} {...rest} />;
17
30
  }
18
- }, [indeterminate]);
19
31
 
20
- if (indeterminate) {
21
- return <input type="checkbox" ref={ref} {...rest} />;
32
+ return <CheckBoxUi ref={innerRef} {...rest} />;
22
33
  }
34
+ );
23
35
 
24
- return <CheckBoxUi ref={ref} {...rest} />;
25
- };
36
+ Checkbox.displayName = 'Checkbox';