@bodynarf/react.components 1.2.4 → 1.3.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/components/primitives/checkbox/checkbox.scss +4 -0
- package/components/primitives/checkbox/index.d.ts +18 -0
- package/components/primitives/checkbox/index.d.ts.map +1 -0
- package/components/primitives/checkbox/index.js +21 -0
- package/components/primitives/index.d.ts +1 -0
- package/components/primitives/index.d.ts.map +1 -1
- package/components/primitives/index.js +1 -0
- package/package.json +1 -1
- package/readme.md +2 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import './checkbox.scss';
|
|
2
|
+
import { BaseInputElementProps } from "../types";
|
|
3
|
+
export declare type CheckBoxProps = BaseInputElementProps<boolean> & {
|
|
4
|
+
/** Is full colored checkbox */
|
|
5
|
+
block?: boolean;
|
|
6
|
+
/** Remove the checkbox border */
|
|
7
|
+
withoutBorder?: boolean;
|
|
8
|
+
/** Checkbox has background color */
|
|
9
|
+
hasBackgroundColor?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Set unchecked background as transparent.
|
|
12
|
+
* Only used with `hasBackgroundColor`
|
|
13
|
+
*/
|
|
14
|
+
fixBackgroundColor?: boolean;
|
|
15
|
+
};
|
|
16
|
+
declare const CheckBox: ({ label, onValueChange, defaultValue, name, disabled, rounded, size, style, block, withoutBorder, hasBackgroundColor, fixBackgroundColor }: CheckBoxProps) => JSX.Element;
|
|
17
|
+
export default CheckBox;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/checkbox/index.tsx"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,oBAAY,aAAa,GAAG,qBAAqB,CAAC,OAAO,CAAC,GAAG;IACzD,+BAA+B;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,iCAAiC;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,oCAAoC;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;MAGE;IACF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,QAAA,MAAM,QAAQ,+IAKX,aAAa,KAAG,WAsClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { generateGuid, getClassName, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
|
+
import './checkbox.scss';
|
|
5
|
+
const CheckBox = ({ label, onValueChange, defaultValue, name, disabled, rounded, size, style, block, withoutBorder, hasBackgroundColor, fixBackgroundColor }) => {
|
|
6
|
+
const onChecked = useCallback((event) => onValueChange(event.target.checked), [onValueChange]);
|
|
7
|
+
const id = name || generateGuid();
|
|
8
|
+
const className = getClassName([
|
|
9
|
+
"m-check-radio",
|
|
10
|
+
"is-checkradio",
|
|
11
|
+
hasBackgroundColor == true ? "has-background-color" : "",
|
|
12
|
+
fixBackgroundColor === true && hasBackgroundColor == true ? "m-has-background-color" : "",
|
|
13
|
+
isNullOrUndefined(style) ? "" : size === 'normal' ? "" : `is-${size}`,
|
|
14
|
+
rounded === true ? "is-circle" : "",
|
|
15
|
+
isNullOrUndefined(style) ? "" : `is-${style}`,
|
|
16
|
+
block === true ? "is-block" : "",
|
|
17
|
+
withoutBorder === true ? "has-no-border" : "",
|
|
18
|
+
]);
|
|
19
|
+
return (_jsxs("div", { className: "field", children: [_jsx("input", { type: "checkbox", name: id, id: id, disabled: disabled, onChange: onChecked, className: className, defaultChecked: defaultValue }), _jsx("label", { htmlFor: id, children: label?.caption })] }));
|
|
20
|
+
};
|
|
21
|
+
export default CheckBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -12,6 +12,7 @@ Small library with react components based on Bulma CSS framework <a href="
|
|
|
12
12
|
2. Install [Bulma](https://bulma.io/)
|
|
13
13
|
3. Make sure you imported bulma styles in parent container
|
|
14
14
|
4. *(Optional)* To use **Icon** component - install [Bootstrap Icons](https://icons.getbootstrap.com/) and make sure you imported these styles in parent container
|
|
15
|
+
5. *(Optional)* To use **Checkbox** component - install [bulma-checkradio](https://www.npmjs.com/package/bulma-checkradio) and make sure you imported these styles in parent container
|
|
15
16
|
|
|
16
17
|
## Description
|
|
17
18
|
### Simple components
|
|
@@ -24,6 +25,7 @@ Simple react components based on html elements.
|
|
|
24
25
|
- **Button**
|
|
25
26
|
- **Icon** - *see p.4 of installation*
|
|
26
27
|
- **Dropdown** - custom dropdown component, based on html div elements & css. Allows to use icon in elements
|
|
28
|
+
- **Checkbox** - (*see p.5 of installation*) Checkbox component based on [bulma-checkradio](https://wikiki.github.io/form/checkradio/1)
|
|
27
29
|
|
|
28
30
|
### Complex components
|
|
29
31
|
Complex components is set of components built via combining simple components or represent complex logical component
|