@bodynarf/react.components 1.3.4 → 1.3.8

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.
@@ -15,6 +15,6 @@ const DropdownLabel = ({ caption, selectedItem, onClick, deselectable }) => {
15
15
  "button"
16
16
  ]);
17
17
  return (_jsxs("label", { className: className, onClick: onClick, children: [deselectVisible &&
18
- _jsx(Icon, { name: "plus-lg" }), _jsx("span", { className: deselectVisible ? "mx-2" : "mr-2", title: itemSelected ? text : undefined, children: text }), _jsx(Icon, { name: "arrow-up" })] }));
18
+ _jsx(Icon, { name: "plus-lg" }), _jsx("span", { className: deselectVisible ? "mx-2" : "mr-2", title: itemSelected ? text : undefined, children: text }), _jsx(Icon, { name: "arrow-down" })] }));
19
19
  };
20
20
  export default DropdownLabel;
@@ -2,22 +2,12 @@
2
2
  min-width: 7.5rem;
3
3
  width: fit-content;
4
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
5
  & .dropdown-menu {
15
6
  min-width: 11.75rem;
16
- }
17
7
 
18
- span.dropdown-item {
19
- color: gray;
20
- text-align: center;
8
+ & .dropdown-content {
9
+ overflow: auto;
10
+ }
21
11
  }
22
12
 
23
13
  &__label {
@@ -80,10 +70,11 @@
80
70
  .app-dropdown__label .app-icon.bi-arrow-up::before {
81
71
  transform: rotate(180deg);
82
72
  }
73
+ }
83
74
 
84
- .app-dropdown__list {
85
- opacity: 1;
86
- visibility: visible;
75
+ &--height-default {
76
+ .dropdown-menu .dropdown-content {
77
+ height: 15vw;
87
78
  }
88
79
  }
89
80
  }
@@ -11,19 +11,21 @@ export declare type DropdownProps = BaseElementProps & {
11
11
  value?: SelectableItem;
12
12
  /**
13
13
  * Action to update selected value, which stored outside
14
- */
14
+ */
15
15
  onSelect: (item?: SelectableItem) => void;
16
16
  /**
17
17
  * Caption.
18
18
  * Appears only no element selected
19
- */
19
+ */
20
20
  caption: string;
21
21
  /** Hide dropdown list when its opened and user click outside */
22
22
  hideOnOuterClick: boolean;
23
23
  /** Can user deselect */
24
24
  deselectable?: boolean;
25
+ /** Custom dropdown list height property */
26
+ listHeight?: string;
25
27
  };
26
28
  /** Dropdown component */
27
- declare const Dropdown: ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick }: DropdownProps) => JSX.Element;
29
+ declare const Dropdown: ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick, listHeight }: DropdownProps) => JSX.Element;
28
30
  export default Dropdown;
29
31
  //# sourceMappingURL=index.d.ts.map
@@ -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;;OAEG;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
+ {"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;;MAEE;IACF,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;MAGE;IACF,OAAO,EAAE,MAAM,CAAC;IAEhB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAA;AAED,yBAAyB;AACzB,QAAA,MAAM,QAAQ,+FAAgG,aAAa,KAAG,WA4F7H,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -6,7 +6,7 @@ import { useComponentOutsideClick } from '../../hooks/useComponentOutsideClick';
6
6
  import DropdownItem from './components/dropdownItem';
7
7
  import DropdownLabel from './components/dropdownLabel';
8
8
  /** Dropdown component */
9
- const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick }) => {
9
+ const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hideOnOuterClick, listHeight }) => {
10
10
  const id = useId();
11
11
  const [isListVisible, setListVisible] = useState(false);
12
12
  const onItemClick = useCallback((event) => {
@@ -45,11 +45,12 @@ const Dropdown = ({ value, items, onSelect, caption, deselectable, className, hi
45
45
  const classNames = getClassName([
46
46
  "app-dropdown",
47
47
  isListVisible ? "is-active" : "",
48
+ isNullOrEmpty(listHeight) ? "app-dropdown--height-default" : "",
48
49
  className,
49
50
  "dropdown"
50
51
  ]);
51
52
  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
52
- ? _jsx("ul", { className: "dropdown-content", children: items.map(item => _jsx(DropdownItem, { item: item, selected: value?.value === item.value, onClick: onItemClick }, item.id)) })
53
+ ? _jsx("ul", { className: "dropdown-content", style: { height: listHeight }, children: items.map(item => _jsx(DropdownItem, { item: item, selected: value?.value === item.value, onClick: onItemClick }, item.id)) })
53
54
  : _jsx("span", { className: "dropdown-content dropdown-item", children: "No items found" }) })] }, id));
54
55
  };
55
56
  export default Dropdown;
@@ -1,24 +1,23 @@
1
1
  /// <reference types="react" />
2
2
  import './search.scss';
3
+ import { ElementSize } from '../types';
3
4
  export declare type SearchProps = {
5
+ /**
6
+ * Search type: by typing, starts from minimum characters to search
7
+ * or by clicking on button next to search bar.
8
+ * Default `is byTyping`
9
+ */
10
+ searchType: 'byTyping' | 'byButton';
4
11
  /** Search caption */
5
12
  caption: string;
6
13
  /** Search handler */
7
14
  onSearch: (searchPattern: string) => void;
8
15
  /** Initial search value */
9
16
  defaultValue?: string;
10
- /**
11
- * Search type: by typing, starts from minimum characters to search
12
- * or by clicking on button next to search bar.
13
- * Default `is byTyping`
14
- */
15
- searchType?: 'byTyping' | 'byButton';
16
17
  /** Control name. If empty - will be replaced by random guid */
17
18
  name?: string;
18
- /** Minimum amount of characters to search */
19
- minCharsToSearch?: number;
20
19
  /** Size of search bar */
21
- size?: 'small' | 'normal' | 'medium' | 'large';
20
+ size?: ElementSize;
22
21
  /** Should search bar be rounded */
23
22
  rounded?: boolean;
24
23
  /** Is search bar disabled */
@@ -27,5 +26,5 @@ export declare type SearchProps = {
27
26
  isLoading?: boolean;
28
27
  };
29
28
  /** Search component */
30
- export default function Search(props: SearchProps): JSX.Element;
29
+ export default function Search({ searchType, onSearch, caption, name, defaultValue, size, isLoading, rounded, disabled, }: SearchProps): JSX.Element;
31
30
  //# sourceMappingURL=index.d.ts.map
@@ -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,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,uBAAuB;AACvB,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CA4E9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/search/index.tsx"],"names":[],"mappings":";AAIA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,oBAAY,WAAW,GAAG;IACtB;;;;MAIE;IACF,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IAEpC,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,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,yBAAyB;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,uBAAuB;AACvB,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC3B,UAAU,EAAE,QAAQ,EAAE,OAAO,EAC7B,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,GACrC,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAsE3B"}
@@ -4,36 +4,32 @@ import { generateGuid, getClassName } from '@bodynarf/utils';
4
4
  import './search.scss';
5
5
  import Button from '../button';
6
6
  /** Search component */
7
- export default function Search(props) {
8
- const [name] = useState(props.name || generateGuid());
9
- const [searchValue, setSearchValue] = useState(props.defaultValue || '');
10
- const searchType = props.searchType || 'byTyping';
7
+ export default function Search({ searchType, onSearch, caption, name, defaultValue, size, isLoading, rounded, disabled, }) {
8
+ const [elementName] = useState(name || generateGuid());
9
+ const [searchValue, setSearchValue] = useState(defaultValue || '');
11
10
  const onChange = useCallback((event) => {
12
11
  const elementValue = event.target.value;
13
12
  if (searchType === 'byTyping') {
14
- const minCharsToSearch = props.minCharsToSearch || 3;
15
- if (elementValue.length >= minCharsToSearch) {
16
- props.onSearch(elementValue);
17
- }
13
+ onSearch(elementValue);
18
14
  }
19
15
  setSearchValue(elementValue);
20
- }, [props, searchType]);
21
- const onSearchButtonClick = useCallback(() => props.onSearch(searchValue), [props, searchValue]);
16
+ }, [onSearch, searchType]);
17
+ const onSearchButtonClick = useCallback(() => onSearch(searchValue), [onSearch, searchValue]);
22
18
  const className = getClassName([
23
19
  'app-search control',
24
- `is-${(props.size || 'normal')}`,
25
- props.isLoading === true ? 'is-loading' : '',
20
+ `is-${(size || 'normal')}`,
21
+ isLoading === true ? 'is-loading' : '',
26
22
  searchType === 'byButton' ? 'is-expanded' : '',
27
23
  ]);
28
24
  const inputClassName = getClassName([
29
25
  'input is-unselectable',
30
- `is-${(props.size || 'normal')}`,
31
- props.rounded === true ? 'is-rounded' : '',
26
+ `is-${(size || 'normal')}`,
27
+ rounded === true ? 'is-rounded' : '',
32
28
  ]);
33
29
  if (searchType === 'byButton') {
34
- 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 }) })] }));
30
+ return (_jsxs("div", { className: "field has-addons", children: [_jsx("div", { className: className, children: _jsx("input", { type: 'search', name: elementName, defaultValue: searchValue, className: inputClassName, disabled: disabled, onChange: onChange, placeholder: caption }) }), _jsx("div", { className: "control", children: _jsx(Button, { caption: "Search", type: "info", onClick: onSearchButtonClick, isLoading: isLoading }) })] }));
35
31
  }
36
32
  else {
37
- return (_jsx("div", { className: className, children: _jsx("input", { type: 'search', name: name, defaultValue: searchValue, className: inputClassName, disabled: props.disabled, onChange: onChange, placeholder: props.caption }) }));
33
+ return (_jsx("div", { className: className, children: _jsx("input", { type: 'search', name: elementName, defaultValue: searchValue, className: inputClassName, disabled: disabled, onChange: onChange, placeholder: caption }) }));
38
34
  }
39
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodynarf/react.components",
3
- "version": "1.3.4",
3
+ "version": "1.3.8",
4
4
  "author": {
5
5
  "name": "Artem",
6
6
  "email": "bodynar@gmail.com"