@bodynarf/react.components 1.2.2 → 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.
@@ -10,7 +10,7 @@ export const AnchorWithIcon = ({ href, className, onClick, caption, title, targe
10
10
  ? `${icon.className} app-icon--left`
11
11
  : `${icon.className} app-icon--right`;
12
12
  if (iconPosition === 'left') {
13
- return (_jsxs("a", { href: href, className: className, title: title, target: target, onClick: onClick, children: [_jsx(Icon, { ...icon, name: iconClassName }), caption] }));
13
+ return (_jsxs("a", { href: href, className: className, title: title, target: target, onClick: onClick, children: [_jsx(Icon, { ...icon, className: iconClassName }), caption] }));
14
14
  }
15
- return (_jsxs("a", { href: href, className: className, title: title, target: target, onClick: onClick, children: [caption, _jsx(Icon, { ...icon, name: iconClassName })] }));
15
+ return (_jsxs("a", { href: href, className: className, title: title, target: target, onClick: onClick, children: [caption, _jsx(Icon, { ...icon, className: iconClassName })] }));
16
16
  };
@@ -13,7 +13,7 @@ export const ButtonWithIcon = ({ className, disabled, onClick, caption, title, i
13
13
  ? `${className} button--icon-only`
14
14
  : className;
15
15
  if (iconPosition === 'left') {
16
- return (_jsxs("button", { className: className, disabled: disabled, onClick: onClick, title: title, children: [_jsx(Icon, { ...icon, name: iconClassName }), caption] }));
16
+ return (_jsxs("button", { className: className, disabled: disabled, onClick: onClick, title: title, children: [_jsx(Icon, { ...icon, className: iconClassName }), caption] }));
17
17
  }
18
- return (_jsxs("button", { className: className, disabled: disabled, onClick: onClick, title: title, children: [caption, _jsx(Icon, { ...icon, name: iconClassName })] }));
18
+ return (_jsxs("button", { className: className, disabled: disabled, onClick: onClick, title: title, children: [caption, _jsx(Icon, { ...icon, className: iconClassName })] }));
19
19
  };
@@ -17,5 +17,5 @@ export default function Icon({ size = 'medium', name, className }) {
17
17
  sizeToClassMap.has(size) ? sizeToClassMap.get(size) : "",
18
18
  className
19
19
  ]);
20
- return (_jsx("i", { className: className }));
20
+ return (_jsx("i", { className: classNames }));
21
21
  }
@@ -0,0 +1,4 @@
1
+ .is-checkradio[type="checkbox"].has-background-color.m-has-background-color:not(:checked) + label::before {
2
+ border-color: #dbdbdb !important;
3
+ background-color: transparent !important;
4
+ }
@@ -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,5 +1,6 @@
1
1
  export * from './date';
2
2
  export * from './multiline';
3
3
  export * from './text';
4
+ export * from './checkbox';
4
5
  export * from './types';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -1,4 +1,5 @@
1
1
  export * from './date';
2
2
  export * from './multiline';
3
3
  export * from './text';
4
+ export * from './checkbox';
4
5
  export * from './types';
@@ -17,10 +17,14 @@ export declare type IconPosition = 'left' | 'right';
17
17
  /** Icon for component */
18
18
  export declare type ElementIcon = {
19
19
  /**
20
- * Class name for icon.
21
- * Used to display icon from bootstrap-icons
20
+ * Icon name. Must be without `bi-`
21
+ * @example ["Arrow repeat", "arrow-repeat"]
22
+ * // Icon name to icon class name.
23
+ * // For class name check bootstrap icons website
22
24
  */
23
- className: string;
25
+ name: string;
26
+ /** Additional classname */
27
+ className?: string;
24
28
  /** Icon size */
25
29
  size?: ElementSize;
26
30
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,oBAAY,gBAAgB,GAAG;IAC3B,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8BAA8B;IAC9B,IAAI,CAAC,EAAE;QACH,8CAA8C;QAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;CACL,CAAC;AAEF,4BAA4B;AAC5B,oBAAY,WAAW,GACjB,OAAO,GACP,QAAQ,CAAC,mBAAmB,GAC5B,OAAO,CAAC;AAEd,4BAA4B;AAC5B,oBAAY,YAAY,GAClB,MAAM,GACN,OAAO,CAAC;AAEd,0BAA0B;AAC1B,oBAAY,WAAW,GAAG;IACtB;;;MAGE;IACF,SAAS,EAAE,MAAM,CAAC;IAElB,gBAAgB;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;;MAGE;IACF,QAAQ,CAAC,EAAE,YAAY,CAAC;CAC3B,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,oBAAY,gBAAgB,GAAG;IAC3B,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8BAA8B;IAC9B,IAAI,CAAC,EAAE;QACH,8CAA8C;QAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;CACL,CAAC;AAEF,4BAA4B;AAC5B,oBAAY,WAAW,GACjB,OAAO,GACP,QAAQ,CAAC,mBAAmB,GAC5B,OAAO,CAAC;AAEd,4BAA4B;AAC5B,oBAAY,YAAY,GAClB,MAAM,GACN,OAAO,CAAC;AAEd,0BAA0B;AAC1B,oBAAY,WAAW,GAAG;IACtB;;;;;MAKE;IACF,IAAI,EAAE,MAAM,CAAC;IAEb,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gBAAgB;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;;MAGE;IACF,QAAQ,CAAC,EAAE,YAAY,CAAC;CAC3B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodynarf/react.components",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "author": {
5
5
  "name": "Artem",
6
6
  "email": "bodynar@gmail.com"
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "npx tsc",
25
- "publish": "npx tsc && copy package.json dist && copy readme.md dist && cd dist && npm publish --access=public"
25
+ "publish_package": "npx tsc && copy package.json dist && copy readme.md dist && cd dist && npm publish --access=public"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/react": "^18.0.11",
package/readme.md CHANGED
@@ -12,6 +12,7 @@ Small library with react components based on Bulma CSS framework&nbsp; <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