@bolttech/atoms-checkbox 0.10.0 → 0.12.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.
- package/README.md +66 -4
- package/index.cjs +12 -9
- package/package.json +2 -2
- package/src/lib/atoms-checkbox.d.ts +3 -1
- package/src/lib/atoms-checkbox.styles.d.ts +2 -1
- package/src/lib/atoms-checkbox.type.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Checkbox Component
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A simple React checkbox component.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
+
Use the package manager [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) to install the component.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @edirect/frontend-foundations @bolttech/atoms-checkbox
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @edirect/frontend-foundations @bolttech/atoms-checkbox
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
The `Checkbox` component accepts the following properties:
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Description |
|
|
24
|
+
|--------------|---------------|---------------------------------------------------------------------------------------------------|
|
|
25
|
+
| id | `string` | The ID attribute for the checkbox element. |
|
|
26
|
+
| label | `string` | The label text for the checkbox. |
|
|
27
|
+
| disabled | `boolean` | Disables the checkbox when set to `true`. |
|
|
28
|
+
| errorMessage | `string` | An optional error message to be displayed. |
|
|
29
|
+
| ref | `object` | A reference object for the checkbox element. |
|
|
30
|
+
| checked | `boolean` | Determines whether the checkbox is checked or not. |
|
|
31
|
+
| onChange | `function` | Callback function to handle the checkbox change event. |
|
|
32
|
+
| onBlur | `function` | Callback function to handle the checkbox blur event. |
|
|
33
|
+
| onFocus | `function` | Callback function to handle the checkbox focus event. |
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import React, {useState} from 'react';
|
|
39
|
+
import {Checkbox} from '@bolttech/atoms-checkbox';
|
|
40
|
+
import {bolttechTheme, BolttechThemeProvider} from "@edirect/frontend-foundations";
|
|
41
|
+
|
|
42
|
+
const ExampleComponent = () => {
|
|
43
|
+
const [isChecked, setIsChecked] = useState(false);
|
|
44
|
+
|
|
45
|
+
const handleCheckboxChange = (event) => {
|
|
46
|
+
setIsChecked(event.target.checked);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<BolttechThemeProvider theme={bolttechTheme}>
|
|
51
|
+
<Checkbox
|
|
52
|
+
id="custom-checkbox"
|
|
53
|
+
label="Check me"
|
|
54
|
+
disabled={false}
|
|
55
|
+
errorMessage="This field is required"
|
|
56
|
+
checked={isChecked}
|
|
57
|
+
onChange={handleCheckboxChange}
|
|
58
|
+
/>
|
|
59
|
+
</BolttechThemeProvider>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ExampleComponent;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Contributing
|
|
67
|
+
|
|
68
|
+
Contributions are welcome! For any bug fixes, improvements, or new features, please open an [issue](link-to-issues) or submit a pull request.
|
|
69
|
+
|
|
70
|
+
Please make sure to follow the code standards and test your changes before submitting.
|
package/index.cjs
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var react = require('react');
|
|
7
8
|
var styled = require('styled-components');
|
|
9
|
+
var frontendFoundations = require('@edirect/frontend-foundations');
|
|
8
10
|
|
|
9
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
12
|
|
|
@@ -47,7 +49,7 @@ const Input = /*#__PURE__*/styled__default["default"].input.attrs({
|
|
|
47
49
|
}) => theme.components.checkbox.innerSquare.color.disableSelected, ({
|
|
48
50
|
theme
|
|
49
51
|
}) => theme.components.checkbox.checkmark.color.selectedDisable);
|
|
50
|
-
const Label = /*#__PURE__*/styled__default["default"].
|
|
52
|
+
const Label = /*#__PURE__*/styled__default["default"](frontendFoundations.Typography).withConfig({
|
|
51
53
|
displayName: "atoms-checkboxstyles__Label",
|
|
52
54
|
componentId: "sc-1gq944z-2"
|
|
53
55
|
})(["color:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";"], ({
|
|
@@ -81,33 +83,34 @@ const LabelError = /*#__PURE__*/styled__default["default"].label.withConfig({
|
|
|
81
83
|
theme
|
|
82
84
|
}) => theme.components.checkbox.errorLabel.letterSpacing);
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
const Checkbox = /*#__PURE__*/react.forwardRef(({
|
|
85
87
|
id,
|
|
86
88
|
label,
|
|
87
|
-
disabled = false,
|
|
89
|
+
disabled: _disabled = false,
|
|
88
90
|
errorMessage,
|
|
89
|
-
ref = null,
|
|
90
91
|
checked,
|
|
91
92
|
onChange,
|
|
92
93
|
onBlur,
|
|
93
94
|
onFocus
|
|
94
|
-
}) {
|
|
95
|
+
}, ref) => {
|
|
95
96
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
96
97
|
children: [jsxRuntime.jsxs(CheckboxContainer, {
|
|
98
|
+
ref: ref,
|
|
97
99
|
children: [jsxRuntime.jsx(Input, {
|
|
98
100
|
id: id,
|
|
99
|
-
disabled:
|
|
101
|
+
disabled: _disabled,
|
|
100
102
|
error: errorMessage,
|
|
101
103
|
checked: checked,
|
|
102
|
-
ref: ref,
|
|
103
104
|
type: "checkbox",
|
|
104
105
|
"data-testid": `${id}-test`,
|
|
105
106
|
onChange: onChange,
|
|
106
107
|
onBlur: onBlur,
|
|
107
108
|
onFocus: onFocus
|
|
108
109
|
}), jsxRuntime.jsx(Label, {
|
|
110
|
+
disabled: _disabled,
|
|
111
|
+
variant: "primary",
|
|
112
|
+
type: "label",
|
|
109
113
|
htmlFor: id,
|
|
110
|
-
disabled: disabled,
|
|
111
114
|
children: label
|
|
112
115
|
})]
|
|
113
116
|
}), errorMessage && jsxRuntime.jsx(CheckboxContainerError, {
|
|
@@ -116,6 +119,6 @@ function Checkbox({
|
|
|
116
119
|
})
|
|
117
120
|
})]
|
|
118
121
|
});
|
|
119
|
-
}
|
|
122
|
+
});
|
|
120
123
|
|
|
121
124
|
exports.Checkbox = Checkbox;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/atoms-checkbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"main": "./index.cjs",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@edirect/frontend-foundations": "0.0.
|
|
8
|
+
"@edirect/frontend-foundations": "0.0.67",
|
|
9
9
|
"react": "18.2.0",
|
|
10
10
|
"styled-components": "5.3.6"
|
|
11
11
|
},
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { CheckboxProps } from './atoms-checkbox.type';
|
|
2
|
-
export declare
|
|
3
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
4
|
+
export default Checkbox;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
interface LabelProps {
|
|
2
3
|
disabled?: boolean;
|
|
3
4
|
}
|
|
@@ -8,7 +9,7 @@ declare const CheckboxContainer: import("styled-components").StyledComponent<"se
|
|
|
8
9
|
declare const Input: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {
|
|
9
10
|
type: "checkbox";
|
|
10
11
|
} & InputProps, "type">;
|
|
11
|
-
declare const Label: import("styled-components").StyledComponent<"
|
|
12
|
+
declare const Label: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@edirect/frontend-foundations/dist/src/shared/types/typography.type").TypographyPropsType & import("react").RefAttributes<HTMLElement>>, import("styled-components").DefaultTheme, LabelProps, never>;
|
|
12
13
|
declare const CheckboxContainerError: import("styled-components").StyledComponent<"section", import("styled-components").DefaultTheme, {}, never>;
|
|
13
14
|
declare const LabelError: import("styled-components").StyledComponent<"label", import("styled-components").DefaultTheme, {}, never>;
|
|
14
15
|
export { CheckboxContainer, Input, Label, CheckboxContainerError, LabelError };
|
|
@@ -5,7 +5,6 @@ export interface CheckboxProps {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
errorMessage?: string;
|
|
7
7
|
checked?: boolean;
|
|
8
|
-
ref?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
|
|
9
8
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
10
9
|
onBlur?: ChangeEventHandler<HTMLInputElement>;
|
|
11
10
|
onFocus?: ChangeEventHandler<HTMLInputElement>;
|