@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.
- package/components/anchor/components/anchorWithIcon/index.js +2 -2
- package/components/anchor/index.js +4 -4
- package/components/button/components/buttonWithIcon/index.js +3 -3
- package/components/button/index.d.ts.map +1 -1
- package/components/button/index.js +12 -10
- package/components/dropdown/components/dropdownLabel/index.d.ts.map +1 -1
- package/components/dropdown/components/dropdownLabel/index.js +4 -5
- package/components/dropdown/index.d.ts.map +1 -1
- package/components/dropdown/index.js +7 -9
- package/components/primitives/date/index.js +5 -5
- package/components/primitives/multiline/components/multilineWithLabel/index.js +4 -4
- package/components/primitives/multiline/components/multilineWithoutLabel/index.js +4 -4
- package/components/primitives/multiline/index.js +2 -2
- package/components/primitives/text/components/textWithLabel/index.js +4 -4
- package/components/primitives/text/components/textWithoutLabel/index.js +4 -4
- package/components/primitives/text/index.js +2 -2
- package/components/search/index.d.ts.map +1 -1
- package/components/search/index.js +15 -13
- package/hooks/useComponentOutsideClick.js +4 -4
- package/package.json +1 -1
- package/components/anchor/anchor.scss +0 -15
- package/components/button/button.scss +0 -12
- package/components/dropdown/dropdown.scss +0 -89
- package/components/icon/icon.scss +0 -18
- package/components/search/search.scss +0 -24
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
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 =
|
|
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
|
|
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 (
|
|
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
|
-
+ (!
|
|
12
|
+
+ (!isNullOrEmpty(props.className) ? ` ${props.className}` : '')
|
|
13
13
|
+ (props.disableHovering === true ? ' app-anchor--unhoverable' : '');
|
|
14
|
-
if (
|
|
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
|
|
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 =
|
|
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 =
|
|
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,
|
|
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
|
|
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 ((
|
|
12
|
-
&& (
|
|
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 =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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,
|
|
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
|
|
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 = !
|
|
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
|
-
]
|
|
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,
|
|
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
|
|
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 (
|
|
14
|
+
if (isNullOrUndefined(target)) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
const dataValue = target.dataset['dropdownItemValue'];
|
|
18
|
-
if (
|
|
18
|
+
if (isNullOrEmpty(dataValue)) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const item = items.find(x => x.value === dataValue);
|
|
22
|
-
if (
|
|
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 (
|
|
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
|
|
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(
|
|
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 ||
|
|
11
|
+
const id = props.name || generateGuid();
|
|
12
12
|
const size = `is-${(props.size || 'normal')}`;
|
|
13
|
-
const className =
|
|
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 =
|
|
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
|
|
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 ||
|
|
9
|
+
const id = props.name || generateGuid();
|
|
10
10
|
const size = `is-${(props.size || 'normal')}`;
|
|
11
|
-
const className =
|
|
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 =
|
|
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
|
|
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 ||
|
|
9
|
+
const id = props.name || generateGuid();
|
|
10
10
|
const size = `is-${(props.size || 'normal')}`;
|
|
11
|
-
const className =
|
|
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 =
|
|
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
|
|
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 (
|
|
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
|
|
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 ||
|
|
9
|
+
const id = props.name || generateGuid();
|
|
10
10
|
const size = `is-${(props.size || 'normal')}`;
|
|
11
|
-
const className =
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 ||
|
|
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
|
|
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 (
|
|
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,
|
|
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
|
|
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 ||
|
|
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 =
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const inputClassName =
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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 (
|
|
15
|
+
if (isNullOrUndefined(target)) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const relatedComponent = target.closest(selector);
|
|
19
|
-
if (
|
|
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 (
|
|
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,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,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
|
-
}
|