@bodynarf/react.components 1.1.4 → 1.1.5

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.
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import utils from '@bodynarf/utils';
2
+ import { isNullOrEmpty } from '@bodynarf/utils';
3
3
  import Icon from '../../../icon';
4
4
  /** Anchor with icon component */
5
5
  export const AnchorWithIcon = ({ href, className, onClick, caption, title, target, icon }) => {
6
6
  const iconPosition = icon.position || 'left';
7
- const iconClassName = utils.isNullOrEmpty(caption)
7
+ const iconClassName = isNullOrEmpty(caption)
8
8
  ? icon.className
9
9
  : iconPosition === 'left'
10
10
  ? `${icon.className} app-icon--left`
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import utils from '@bodynarf/utils';
2
+ import { isNullOrUndefined, isNullOrEmpty } from '@bodynarf/utils';
3
3
  import './anchor.scss';
4
4
  import { SimpleAnchor } from './components/simpleAnchor';
5
5
  import { AnchorWithIcon } from './components/anchorWithIcon';
6
6
  /** Anchor component */
7
7
  export default function Anchor(props) {
8
- if (utils.isNullOrUndefined(props.caption) && utils.isNullOrUndefined(props.icon)) {
8
+ if (isNullOrUndefined(props.caption) && isNullOrUndefined(props.icon)) {
9
9
  throw new Error("No anchor content provided");
10
10
  }
11
11
  const className = 'app-anchor'
12
- + (!utils.isNullOrEmpty(props.className) ? ` ${props.className}` : '')
12
+ + (!isNullOrEmpty(props.className) ? ` ${props.className}` : '')
13
13
  + (props.disableHovering === true ? ' app-anchor--unhoverable' : '');
14
- if (utils.isNullOrUndefined(props.icon)) {
14
+ if (isNullOrUndefined(props.icon)) {
15
15
  return (_jsx(SimpleAnchor, { ...props, className: className, onClick: props.onClick }));
16
16
  }
17
17
  return (_jsx(AnchorWithIcon, { ...props, className: className, onClick: props.onClick, icon: props.icon }));
@@ -1,15 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import utils from '@bodynarf/utils';
2
+ import { isNullOrEmpty } from '@bodynarf/utils';
3
3
  import Icon from '../../../icon';
4
4
  /** Button with icon component */
5
5
  export const ButtonWithIcon = ({ className, disabled, onClick, caption, title, icon }) => {
6
6
  const iconPosition = icon.position || 'left';
7
- const iconClassName = utils.isNullOrEmpty(caption)
7
+ const iconClassName = isNullOrEmpty(caption)
8
8
  ? icon.className
9
9
  : iconPosition === 'left'
10
10
  ? `${icon.className} app-icon--left`
11
11
  : `${icon.className} app-icon--right`;
12
- className = utils.isNullOrEmpty(caption)
12
+ className = isNullOrEmpty(caption)
13
13
  ? `${className} button--icon-only`
14
14
  : className;
15
15
  if (iconPosition === 'left') {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/button/index.tsx"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,oBAAY,WAAW,GAAG;IACtB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,8BAA8B;IAC9B,IAAI,EAAE,UAAU,CAAC;IAEjB,kCAAkC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mBAAmB;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAiC9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/button/index.tsx"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,oBAAY,WAAW,GAAG;IACtB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,8BAA8B;IAC9B,IAAI,EAAE,UAAU,CAAC;IAEjB,kCAAkC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mBAAmB;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAkC9D"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import utils from '@bodynarf/utils';
2
+ import { isNullOrEmpty, isStringEmpty, isNullOrUndefined, getClassName } from '@bodynarf/utils';
3
3
  import './button.scss';
4
4
  import { ButtonWithIcon } from './components/buttonWithIcon';
5
5
  import { SimpleButton } from './components/simpleButton';
@@ -8,17 +8,19 @@ import { SimpleButton } from './components/simpleButton';
8
8
  * @throws Caption is not defined and icon configuration is not defined at the same time
9
9
  */
10
10
  export default function Button(props) {
11
- if ((utils.isNullOrEmpty(props.caption))
12
- && (utils.isNullOrUndefined(props.icon) || utils.isStringEmpty(props.icon?.className))) {
11
+ if ((isNullOrEmpty(props.caption))
12
+ && (isNullOrUndefined(props.icon) || isStringEmpty(props.icon?.className))) {
13
13
  throw new Error("No button content provided.");
14
14
  }
15
- const className = `button is-${props.type}`
16
- + (props.light === true ? ' is-light' : '')
17
- + (!utils.isNullOrUndefined(props.size) ? ` is-${props.size}` : '')
18
- + (props.outlined === true ? ' is-outlined' : '')
19
- + (props.rounded === true ? ' is-rounded' : '')
20
- + (props.isLoading === true ? ' is-loading' : '');
21
- if (!utils.isNullOrUndefined(props.icon)) {
15
+ const className = getClassName([
16
+ `button is-${props.type}`,
17
+ props.light === true ? 'is-light' : '',
18
+ !isNullOrUndefined(props.size) ? `is-${props.size}` : '',
19
+ props.outlined === true ? 'is-outlined' : '',
20
+ props.rounded === true ? 'is-rounded' : '',
21
+ props.isLoading === true ? 'is-loading' : '',
22
+ ]);
23
+ if (!isNullOrUndefined(props.icon)) {
22
24
  return (_jsx(ButtonWithIcon, { ...props, className: className, onClick: props.onClick, icon: props.icon }));
23
25
  }
24
26
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/dropdownLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMnC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,UAAU,kBAAkB;IACxB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAEhB,wBAAwB;IACxB,YAAY,EAAE,OAAO,CAAC;IAEtB,oBAAoB;IACpB,YAAY,CAAC,EAAE,cAAc,CAAC;IAE9B,mBAAmB;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC1D;AAED,sBAAsB;AACtB,QAAA,MAAM,aAAa,qDAAsD,kBAAkB,KAAG,WAkC7F,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/dropdownLabel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMnC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,UAAU,kBAAkB;IACxB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAEhB,wBAAwB;IACxB,YAAY,EAAE,OAAO,CAAC;IAEtB,oBAAoB;IACpB,YAAY,CAAC,EAAE,cAAc,CAAC;IAE9B,mBAAmB;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC1D;AAED,sBAAsB;AACtB,QAAA,MAAM,aAAa,qDAAsD,kBAAkB,KAAG,WAiC7F,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,20 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import utils from "@bodynarf/utils";
2
+ import { getClassName, isNullOrUndefined } from "@bodynarf/utils";
3
3
  import Icon from '../../../icon';
4
4
  /** Label component */
5
5
  const DropdownLabel = ({ caption, selectedItem, onClick, deselectable }) => {
6
- const itemSelected = !utils.isNullOrUndefined(selectedItem);
6
+ const itemSelected = !isNullOrUndefined(selectedItem);
7
7
  const text = itemSelected
8
8
  ? selectedItem?.displayValue
9
9
  : caption;
10
10
  const deselectVisible = deselectable && itemSelected;
11
- const className = [
11
+ const className = getClassName([
12
12
  "dropdown-trigger",
13
13
  "app-dropdown__label",
14
14
  itemSelected ? "" : "app-dropdown__label--default",
15
15
  "button"
16
- ].filter(x => !utils.isNullOrEmpty(x))
17
- .join(" ");
16
+ ]);
18
17
  return (_jsxs("label", { className: className, onClick: onClick, children: [deselectVisible &&
19
18
  _jsx(Icon, { className: "plus-lg" }), _jsx("span", { className: deselectVisible ? "mx-2" : "mr-2", title: itemSelected ? text : undefined, children: text }), _jsx(Icon, { className: "arrow-up" })] }));
20
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/index.tsx"],"names":[],"mappings":";AAIA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK5C,oBAAY,aAAa,GAAG,gBAAgB,GAAG;IAC3C,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B;;;MAGE;IACF,KAAK,CAAC,EAAE,cAAc,CAAC;IAEvB;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAA;AAED,yBAAyB;AACzB,QAAA,MAAM,QAAQ,mFAAoF,aAAa,KAAG,WA6FjH,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/index.tsx"],"names":[],"mappings":";AAIA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK5C,oBAAY,aAAa,GAAG,gBAAgB,GAAG;IAC3C,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B;;;MAGE;IACF,KAAK,CAAC,EAAE,cAAc,CAAC;IAEvB;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAA;AAED,yBAAyB;AACzB,QAAA,MAAM,QAAQ,mFAAoF,aAAa,KAAG,WA2FjH,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useId, useState } from 'react';
3
- import utils from '@bodynarf/utils';
3
+ import { isNullOrUndefined, isNullOrEmpty, getClassName } from '@bodynarf/utils';
4
4
  import './dropdown.scss';
5
5
  import { useComponentOutsideClick } from '../../hooks/useComponentOutsideClick';
6
6
  import DropdownItem from './components/dropdownItem';
@@ -11,15 +11,15 @@ const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hi
11
11
  const [isListVisible, setListVisible] = useState(false);
12
12
  const onItemClick = useCallback((event) => {
13
13
  const target = event.target;
14
- if (utils.isNullOrUndefined(target)) {
14
+ if (isNullOrUndefined(target)) {
15
15
  return;
16
16
  }
17
17
  const dataValue = target.dataset['dropdownItemValue'];
18
- if (utils.isNullOrEmpty(dataValue)) {
18
+ if (isNullOrEmpty(dataValue)) {
19
19
  return;
20
20
  }
21
21
  const item = items.find(x => x.value === dataValue);
22
- if (utils.isNullOrUndefined(item)) {
22
+ if (isNullOrUndefined(item)) {
23
23
  return;
24
24
  }
25
25
  if (value === item) {
@@ -31,7 +31,7 @@ const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hi
31
31
  }, [setListVisible, value, items, onSelect]);
32
32
  const onLabelClick = useCallback((event) => {
33
33
  const target = event.target;
34
- if (utils.isNullOrUndefined(target)) {
34
+ if (isNullOrUndefined(target)) {
35
35
  return;
36
36
  }
37
37
  if (target.classList.contains("bi-plus-lg")) {
@@ -42,14 +42,12 @@ const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hi
42
42
  }
43
43
  }, [onSelect, setListVisible]);
44
44
  useComponentOutsideClick(`[data-dropdown-id="${id}"]`, isListVisible, () => setListVisible(false), hideOnOuterClick);
45
- const classNames = [
45
+ const classNames = getClassName([
46
46
  "app-dropdown",
47
47
  isListVisible ? "is-active" : "",
48
48
  className,
49
49
  "dropdown"
50
- ]
51
- .filter(x => !utils.isNullOrEmpty(x))
52
- .join(" ");
50
+ ]);
53
51
  return (_jsxs("div", { className: classNames, "data-dropdown-id": id, children: [_jsx(DropdownLabel, { caption: caption, deselectable: deselectable === true, selectedItem: value, onClick: onLabelClick }), _jsx("div", { className: "dropdown-menu", children: items.length > 0
54
52
  ? _jsx("ul", { className: "dropdown-content", children: items.map(item => _jsx(DropdownItem, { item: item, selected: value?.value === item.value, onClick: onItemClick }, item.id)) })
55
53
  : _jsx("span", { className: "dropdown-content dropdown-item", children: "No items found" }) })] }, id));
@@ -1,22 +1,22 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
- import utils from '@bodynarf/utils';
3
+ import { generateGuid, getClassName, isStringEmpty } from '@bodynarf/utils';
4
4
  /** Date input component */
5
5
  const DatePicker = (props) => {
6
- const onValueChange = useCallback((event) => props.onValueChange(utils.isStringEmpty(event.target.value)
6
+ const onValueChange = useCallback((event) => props.onValueChange(isStringEmpty(event.target.value)
7
7
  ? undefined
8
8
  : new Date(event.target.value)),
9
9
  // eslint-disable-next-line react-hooks/exhaustive-deps
10
10
  [props.onValueChange]);
11
- const id = props.name || utils.generateGuid();
11
+ const id = props.name || generateGuid();
12
12
  const size = `is-${(props.size || 'normal')}`;
13
- const className = utils.getClassName([
13
+ const className = getClassName([
14
14
  props.className,
15
15
  size,
16
16
  props.rounded === true ? 'is-rounded' : '',
17
17
  "input",
18
18
  ]);
19
- const inputContainerClassName = utils.getClassName([
19
+ const inputContainerClassName = getClassName([
20
20
  "control",
21
21
  props.loading === true ? 'is-loading' : '',
22
22
  (props.style || 'default') === 'default' ? '' : `is-${props.style}`
@@ -1,21 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
- import utils from '@bodynarf/utils';
3
+ import { generateGuid, getClassName } from '@bodynarf/utils';
4
4
  /** Multiline textual input component with describing label */
5
5
  const MultilineWithLabel = (props) => {
6
6
  const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
7
7
  // eslint-disable-next-line react-hooks/exhaustive-deps
8
8
  [props.onValueChange]);
9
- const id = props.name || utils.generateGuid();
9
+ const id = props.name || generateGuid();
10
10
  const size = `is-${(props.size || 'normal')}`;
11
- const className = utils.getClassName([
11
+ const className = getClassName([
12
12
  props.className,
13
13
  size,
14
14
  props.rounded === true ? 'is-rounded' : '',
15
15
  "textarea",
16
16
  props.fixed === true ? 'has-fixed-size' : '',
17
17
  ]);
18
- const inputContainerClassName = utils.getClassName([
18
+ const inputContainerClassName = getClassName([
19
19
  "control",
20
20
  props.loading === true ? 'is-loading' : '',
21
21
  (props.style || 'default') === 'default' ? '' : `is-${props.style}`
@@ -1,21 +1,21 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
- import utils from '@bodynarf/utils';
3
+ import { generateGuid, getClassName } from '@bodynarf/utils';
4
4
  /** Multiline textual input component without describing label*/
5
5
  const MultilineWithoutLabel = (props) => {
6
6
  const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
7
7
  // eslint-disable-next-line react-hooks/exhaustive-deps
8
8
  [props.onValueChange]);
9
- const id = props.name || utils.generateGuid();
9
+ const id = props.name || generateGuid();
10
10
  const size = `is-${(props.size || 'normal')}`;
11
- const className = utils.getClassName([
11
+ const className = getClassName([
12
12
  props.className,
13
13
  size,
14
14
  props.rounded === true ? 'is-rounded' : '',
15
15
  "textarea",
16
16
  props.fixed === true ? 'has-fixed-size' : '',
17
17
  ]);
18
- const inputContainerClassName = utils.getClassName([
18
+ const inputContainerClassName = getClassName([
19
19
  "control",
20
20
  props.loading === true ? 'is-loading' : '',
21
21
  (props.style || 'default') === 'default' ? '' : `is-${props.style}`
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import utils from '@bodynarf/utils';
2
+ import { isNullOrUndefined } from '@bodynarf/utils';
3
3
  import MultilineWithoutLabel from './components/multilineWithoutLabel';
4
4
  import MultilineWithLabel from './components/multilineWithLabel';
5
5
  /** Multiline textual input component */
6
6
  const Multiline = (props) => {
7
- if (utils.isNullOrUndefined(props.label)) {
7
+ if (isNullOrUndefined(props.label)) {
8
8
  return (_jsx(MultilineWithoutLabel, { ...props }));
9
9
  }
10
10
  else {
@@ -1,20 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
- import utils from '@bodynarf/utils';
3
+ import { generateGuid, getClassName, } from '@bodynarf/utils';
4
4
  /** Textual input with describing label */
5
5
  const TextWithLabel = (props) => {
6
6
  const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
7
7
  // eslint-disable-next-line react-hooks/exhaustive-deps
8
8
  [props.onValueChange]);
9
- const id = props.name || utils.generateGuid();
9
+ const id = props.name || generateGuid();
10
10
  const size = `is-${(props.size || 'normal')}`;
11
- const className = utils.getClassName([
11
+ const className = getClassName([
12
12
  props.className,
13
13
  size,
14
14
  props.rounded === true ? 'is-rounded' : '',
15
15
  "input",
16
16
  ]);
17
- const inputContainerClassName = utils.getClassName([
17
+ const inputContainerClassName = getClassName([
18
18
  "control",
19
19
  props.loading === true ? 'is-loading' : '',
20
20
  (props.style || 'default') === 'default' ? '' : `is-${props.style}`
@@ -1,24 +1,24 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
- import utils from '@bodynarf/utils';
3
+ import { generateGuid, getClassName } from '@bodynarf/utils';
4
4
  /** Textual input without describing label */
5
5
  const TextWithoutLabel = (props) => {
6
6
  const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
7
7
  // eslint-disable-next-line react-hooks/exhaustive-deps
8
8
  [props.onValueChange]);
9
- const className = utils.getClassName([
9
+ const className = getClassName([
10
10
  props.className,
11
11
  `is-${(props.size || 'normal')}`,
12
12
  props.rounded === true ? 'is-rounded' : '',
13
13
  "input",
14
14
  ]);
15
- const containerClassName = utils.getClassName([
15
+ const containerClassName = getClassName([
16
16
  "app-input",
17
17
  "control",
18
18
  props.loading === true ? 'is-loading' : '',
19
19
  (props.style || 'default') === 'default' ? '' : `is-${props.style}`
20
20
  ]);
21
- const id = props.name || utils.generateGuid();
21
+ const id = props.name || generateGuid();
22
22
  return (_jsx("div", { className: containerClassName, children: _jsx("input", { className: className, type: "text", placeholder: props.placeholder, readOnly: props.readonly, disabled: props.disabled, defaultValue: props.defaultValue, onChange: onValueChange, name: id, id: id }) }));
23
23
  };
24
24
  export default TextWithoutLabel;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import utils from '@bodynarf/utils';
2
+ import { isNullOrUndefined } from '@bodynarf/utils';
3
3
  import TextWithLabel from './components/textWithLabel';
4
4
  import TextWithoutLabel from './components/textWithoutLabel';
5
5
  /** Textual input component */
6
6
  const Text = (props) => {
7
- if (utils.isNullOrUndefined(props.label)) {
7
+ if (isNullOrUndefined(props.label)) {
8
8
  return (_jsx(TextWithoutLabel, { ...props }));
9
9
  }
10
10
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/search/index.tsx"],"names":[],"mappings":";AAIA,OAAO,eAAe,CAAC;AAIvB,oBAAY,WAAW,GAAG;IACtB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;MAIE;IACF,UAAU,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAErC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IAE/C,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,uBAAuB;AACvB,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAgF9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/search/index.tsx"],"names":[],"mappings":";AAIA,OAAO,eAAe,CAAC;AAIvB,oBAAY,WAAW,GAAG;IACtB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;MAIE;IACF,UAAU,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAErC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IAE/C,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,uBAAuB;AACvB,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CA+E9D"}
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useState } from 'react';
3
- import utils from '@bodynarf/utils';
3
+ import { generateGuid, getClassName, isNullOrUndefined } from '@bodynarf/utils';
4
4
  import './search.scss';
5
5
  import Button from '../button';
6
6
  /** Search component */
7
7
  export default function Search(props) {
8
- const [name] = useState(props.name || utils.generateGuid());
8
+ const [name] = useState(props.name || generateGuid());
9
9
  const [searchValue, setSearchValue] = useState(props.defaultValue || '');
10
10
  const searchType = props.searchType || 'byTyping';
11
11
  const onChange = useCallback((event) => {
12
12
  const elementValue = event.target.value;
13
13
  if (searchType === 'byTyping') {
14
- const minCharsToSearch = utils.isNullOrUndefined(props.minCharsToSearch)
14
+ const minCharsToSearch = isNullOrUndefined(props.minCharsToSearch)
15
15
  ? 3
16
16
  : props.minCharsToSearch;
17
17
  if (elementValue.length >= minCharsToSearch) {
@@ -20,16 +20,18 @@ export default function Search(props) {
20
20
  }
21
21
  setSearchValue(elementValue);
22
22
  }, [props, searchType]);
23
- const onSearchButtonClick = useCallback(() => {
24
- props.onSearch(searchValue);
25
- }, [props, searchValue]);
26
- const className = 'app-search control'
27
- + ` is-${(props.size || 'normal')}`
28
- + (props.isLoading === true ? ' is-loading' : '')
29
- + (searchType === 'byButton' ? ' is-expanded' : '');
30
- const inputClassName = 'input is-unselectable'
31
- + ` is-${(props.size || 'normal')}`
32
- + (props.rounded === true ? ' is-rounded' : '');
23
+ const onSearchButtonClick = useCallback(() => props.onSearch(searchValue), [props, searchValue]);
24
+ const className = getClassName([
25
+ 'app-search control',
26
+ `is-${(props.size || 'normal')}`,
27
+ props.isLoading === true ? 'is-loading' : '',
28
+ searchType === 'byButton' ? 'is-expanded' : '',
29
+ ]);
30
+ const inputClassName = getClassName([
31
+ 'input is-unselectable',
32
+ `is-${(props.size || 'normal')}`,
33
+ props.rounded === true ? 'is-rounded' : '',
34
+ ]);
33
35
  if (searchType === 'byButton') {
34
36
  return (_jsxs("div", { className: "field has-addons", children: [_jsx("div", { className: className, children: _jsx("input", { type: 'search', name: name, defaultValue: searchValue, className: inputClassName, disabled: props.disabled, onChange: onChange, placeholder: props.caption }) }), _jsx("div", { className: "control", children: _jsx(Button, { caption: "Search", type: "info", onClick: onSearchButtonClick, isLoading: props.isLoading }) })] }));
35
37
  }
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect } from "react";
2
- import utils from "@bodynarf/utils";
2
+ import { isNullOrUndefined, isNull } from "@bodynarf/utils";
3
3
  /**
4
4
  * Subscribe to component outside click
5
5
  * @param selector Component root selector
@@ -12,18 +12,18 @@ export const useComponentOutsideClick = (selector, clickHandleCondition, clickHa
12
12
  const onDocumentClick = useCallback((event) => {
13
13
  if (clickHandleCondition) {
14
14
  const target = event.target;
15
- if (utils.isNullOrUndefined(target)) {
15
+ if (isNullOrUndefined(target)) {
16
16
  return;
17
17
  }
18
18
  const relatedComponent = target.closest(selector);
19
- if (utils.isNull(relatedComponent)) {
19
+ if (isNull(relatedComponent)) {
20
20
  clickHandleChange();
21
21
  }
22
22
  }
23
23
  // eslint-disable-next-line react-hooks/exhaustive-deps
24
24
  }, [clickHandleCondition, selector, clickHandleChange, dependencies]);
25
25
  useEffect(() => {
26
- if (utils.isNullOrUndefined(clickListenCondition) || clickListenCondition === true) {
26
+ if (isNullOrUndefined(clickListenCondition) || clickListenCondition === true) {
27
27
  document.addEventListener('click', onDocumentClick);
28
28
  return () => document.removeEventListener('click', onDocumentClick);
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodynarf/react.components",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "author": {
5
5
  "name": "Artem",
6
6
  "email": "bodynar@gmail.com"
@@ -1,15 +0,0 @@
1
- .app-anchor {
2
- text-decoration: none;
3
- color: inherit;
4
-
5
- transition: 0.15s ease-in-out color;
6
-
7
- &:not(&--unhoverable):hover {
8
- text-decoration: underline;
9
- color: #3273dc;
10
- }
11
-
12
- .app-icon {
13
- transition: none;
14
- }
15
- }
@@ -1,12 +0,0 @@
1
- .button {
2
- transition: 0.15s ease-in-out;
3
- transition-property: background-color, border-color;
4
-
5
- &--icon-only {
6
- padding: 0.55rem;
7
- }
8
-
9
- &.is-warning.is-outlined:not([disabled]):hover {
10
- color: #000;
11
- }
12
- }
@@ -1,89 +0,0 @@
1
- .app-dropdown {
2
- min-width: 7.5rem;
3
- width: fit-content;
4
-
5
- &__list {
6
- position: absolute;
7
-
8
- opacity: 0;
9
- visibility: collapse;
10
-
11
- transition: 0.15s ease-in-out opacity;
12
- }
13
-
14
- & .dropdown-menu {
15
- min-width: 11.75rem;
16
- }
17
-
18
- span.dropdown-item {
19
- color: gray;
20
- text-align: center;
21
- }
22
-
23
- &__label {
24
- cursor: pointer;
25
- user-select: none;
26
- display: flex;
27
- justify-content: space-between;
28
-
29
- span {
30
- white-space: nowrap;
31
- text-overflow: ellipsis;
32
- overflow-x: hidden;
33
- max-width: 15rem;
34
- }
35
-
36
- &--default span {
37
- color: gray;
38
- font-style: italic;
39
- }
40
-
41
- .app-icon {
42
- &:hover {
43
- color: #0d6efd;
44
- }
45
-
46
- &.bi-arrow-up::before {
47
- transition: 0.25s ease-in-out transform;
48
- }
49
-
50
- &.bi-plus-lg::before {
51
- transform: rotate(45deg);
52
- }
53
- }
54
- }
55
-
56
- &-item {
57
- cursor: pointer;
58
- user-select: none;
59
- white-space: normal;
60
-
61
- transition: 0.25s ease-in-out;
62
- transition-property: color, background-color;
63
-
64
- &:hover {
65
- background-color: rgba(0, 0, 0, 0.05);
66
- color: #0a0a0a;
67
- }
68
- &:active {
69
- background-color: rgba(0, 0, 0, 0.15);
70
- color: #0a0a0a;
71
- }
72
-
73
- &.is-active {
74
- background-color: #485fc7;
75
- color: #fff;
76
- }
77
- }
78
-
79
- &.is-active {
80
- .app-dropdown__label .app-icon.bi-arrow-up::before {
81
- transform: rotate(180deg);
82
- }
83
-
84
- .app-dropdown__list {
85
- opacity: 1;
86
- visibility: visible;
87
- }
88
- }
89
- }
@@ -1,18 +0,0 @@
1
- .app-icon {
2
- transition: 0.15s ease-in-out color;
3
- font-size: 1.3rem;
4
-
5
- &--small {
6
- font-size: 1rem;
7
- }
8
- &--large {
9
- font-size: 2rem;
10
- }
11
-
12
- &--right {
13
- margin-left: 0.5rem;
14
- }
15
- &--left {
16
- margin-right: 0.5rem;
17
- }
18
- }
@@ -1,24 +0,0 @@
1
- .app-search {
2
- input[type="search"] {
3
- transition: 0.15s ease-out;
4
- transition-property: border-color, color, background-color;
5
-
6
- &::placeholder {
7
- user-select: none;
8
- }
9
-
10
- &::-webkit-input-placeholder {
11
- transition: 0.15s ease-out color;
12
- }
13
-
14
- &::-webkit-search-cancel-button {
15
- cursor: pointer;
16
- font-size: 1.25rem;
17
- }
18
- }
19
-
20
- &.is-loading::after {
21
- right: 1rem;
22
- top: 0.725rem;
23
- }
24
- }