@tecsinapse/cortex-react 1.5.10 → 1.6.0-beta.0
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.
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
const Checkbox = React.forwardRef((props, ref) => {
|
|
7
|
+
const localRef = React.useRef(null);
|
|
8
|
+
const { className, indeterminate, ...rest } = props;
|
|
9
|
+
const setIndeterminate = React.useCallback((value) => {
|
|
10
|
+
if (localRef?.current) {
|
|
11
|
+
localRef.current.indeterminate = value;
|
|
12
|
+
localRef.current.checked = false;
|
|
13
|
+
}
|
|
14
|
+
}, []);
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
setIndeterminate(Boolean(indeterminate));
|
|
17
|
+
}, [indeterminate]);
|
|
18
|
+
React.useImperativeHandle(ref, () => {
|
|
19
|
+
return {
|
|
20
|
+
...localRef.current,
|
|
21
|
+
setIndeterminate
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ React.createElement(
|
|
25
|
+
"input",
|
|
26
|
+
{
|
|
27
|
+
type: "checkbox",
|
|
28
|
+
className: cortexCore.checkbox({ className }),
|
|
29
|
+
ref: localRef,
|
|
30
|
+
...rest
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
exports.Checkbox = Checkbox;
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var Calendar = require('./components/Calendar/Calendar.js');
|
|
|
10
10
|
var RangeCalendar = require('./components/Calendar/RangeCalendar.js');
|
|
11
11
|
var Card = require('./components/Card.js');
|
|
12
12
|
var Carousel = require('./components/Carousel/Carousel.js');
|
|
13
|
+
var Checkbox = require('./components/Checkbox.js');
|
|
13
14
|
var DateField = require('./components/DatePicker/DateField.js');
|
|
14
15
|
var DatePickerInput = require('./components/DatePicker/DatePickerInput.js');
|
|
15
16
|
var DatePickerInputBase = require('./components/DatePicker/DatePickerInputBase.js');
|
|
@@ -72,6 +73,7 @@ exports.Calendar = Calendar.Calendar;
|
|
|
72
73
|
exports.RangeCalendar = RangeCalendar.RangeCalendar;
|
|
73
74
|
exports.Card = Card.Card;
|
|
74
75
|
exports.Carousel = Carousel.Carousel;
|
|
76
|
+
exports.Checkbox = Checkbox.Checkbox;
|
|
75
77
|
exports.DateField = DateField.DateField;
|
|
76
78
|
exports.DatePickerInput = DatePickerInput.DatePickerInput;
|
|
77
79
|
exports.DatePickerInputBase = DatePickerInputBase.DatePickerInputBase;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { checkbox } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React__default, { forwardRef, useRef, useCallback, useEffect, useImperativeHandle } from 'react';
|
|
3
|
+
|
|
4
|
+
const Checkbox = forwardRef((props, ref) => {
|
|
5
|
+
const localRef = useRef(null);
|
|
6
|
+
const { className, indeterminate, ...rest } = props;
|
|
7
|
+
const setIndeterminate = useCallback((value) => {
|
|
8
|
+
if (localRef?.current) {
|
|
9
|
+
localRef.current.indeterminate = value;
|
|
10
|
+
localRef.current.checked = false;
|
|
11
|
+
}
|
|
12
|
+
}, []);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setIndeterminate(Boolean(indeterminate));
|
|
15
|
+
}, [indeterminate]);
|
|
16
|
+
useImperativeHandle(ref, () => {
|
|
17
|
+
return {
|
|
18
|
+
...localRef.current,
|
|
19
|
+
setIndeterminate
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
23
|
+
"input",
|
|
24
|
+
{
|
|
25
|
+
type: "checkbox",
|
|
26
|
+
className: checkbox({ className }),
|
|
27
|
+
ref: localRef,
|
|
28
|
+
...rest
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { Checkbox };
|
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { Calendar } from './components/Calendar/Calendar.js';
|
|
|
8
8
|
export { RangeCalendar } from './components/Calendar/RangeCalendar.js';
|
|
9
9
|
export { Card } from './components/Card.js';
|
|
10
10
|
export { Carousel } from './components/Carousel/Carousel.js';
|
|
11
|
+
export { Checkbox } from './components/Checkbox.js';
|
|
11
12
|
export { DateField } from './components/DatePicker/DateField.js';
|
|
12
13
|
export { DatePickerInput } from './components/DatePicker/DatePickerInput.js';
|
|
13
14
|
export { DatePickerInputBase } from './components/DatePicker/DatePickerInputBase.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
export interface CheckboxProps extends HTMLAttributes<HTMLInputElement> {
|
|
3
|
+
indeterminate?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface CheckboxRef extends HTMLAttributes<HTMLInputElement> {
|
|
6
|
+
setIndeterminate: (value: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.HTMLAttributes<HTMLInputElement> & React.RefAttributes<CheckboxRef>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-beta.0",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react-dom": ">=18.0.0",
|
|
47
47
|
"tailwind": ">=3.3.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "8711f203ce482ae24424f7c0d370455772df6c81"
|
|
50
50
|
}
|