@bodynarf/react.components 1.4.17 → 1.4.18
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/dropdown/components/compact/index.d.ts +1 -2
- package/components/dropdown/components/compact/index.d.ts.map +1 -1
- package/components/dropdown/components/compact/index.js +10 -3
- package/components/dropdown/components/withLabel/index.d.ts +1 -1
- package/components/dropdown/components/withLabel/index.d.ts.map +1 -1
- package/components/dropdown/components/withLabel/index.js +10 -3
- package/components/dropdown/dropdown.scss +23 -8
- package/components/dropdown/index.d.ts +9 -11
- package/components/dropdown/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { DropdownProps } from "../..";
|
|
3
|
-
declare const DropdownCompact: ({ items, value, onSelect, deselectable, className, hideOnOuterClick, listMaxHeight, placeholder, compact, }: DropdownProps) => JSX.Element;
|
|
2
|
+
declare const DropdownCompact: ({ items, value, onSelect, deselectable, className, hideOnOuterClick, listMaxHeight, placeholder, compact, disabled, }: DropdownProps) => JSX.Element;
|
|
4
3
|
export default DropdownCompact;
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/compact/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/compact/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAKtC,QAAA,MAAM,eAAe,0HAMlB,aAAa,KAAG,WAsGlB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -4,10 +4,13 @@ import { getClassName, isNullOrEmpty, isNullOrUndefined } from "@bodynarf/utils"
|
|
|
4
4
|
import { useComponentOutsideClick } from "../../../../hooks";
|
|
5
5
|
import DropdownItem from '../item';
|
|
6
6
|
import DropdownLabel from '../label';
|
|
7
|
-
const DropdownCompact = ({ items, value, onSelect, deselectable, className, hideOnOuterClick, listMaxHeight, placeholder, compact, }) => {
|
|
7
|
+
const DropdownCompact = ({ items, value, onSelect, deselectable, className, hideOnOuterClick, listMaxHeight, placeholder, compact, disabled, }) => {
|
|
8
8
|
const id = useId();
|
|
9
9
|
const [isListVisible, setListVisible] = useState(false);
|
|
10
10
|
const onItemClick = useCallback((event) => {
|
|
11
|
+
if (disabled ?? false) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
11
14
|
const target = event.target;
|
|
12
15
|
if (isNullOrUndefined(target)) {
|
|
13
16
|
return;
|
|
@@ -26,8 +29,11 @@ const DropdownCompact = ({ items, value, onSelect, deselectable, className, hide
|
|
|
26
29
|
}
|
|
27
30
|
onSelect(item);
|
|
28
31
|
setListVisible(false);
|
|
29
|
-
}, [setListVisible, value, items, onSelect]);
|
|
32
|
+
}, [setListVisible, value, items, onSelect, disabled]);
|
|
30
33
|
const onLabelClick = useCallback((event) => {
|
|
34
|
+
if (disabled ?? false) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
31
37
|
const target = event.target;
|
|
32
38
|
if (isNullOrUndefined(target)) {
|
|
33
39
|
return;
|
|
@@ -38,10 +44,11 @@ const DropdownCompact = ({ items, value, onSelect, deselectable, className, hide
|
|
|
38
44
|
else {
|
|
39
45
|
setListVisible(state => !state);
|
|
40
46
|
}
|
|
41
|
-
}, [onSelect, setListVisible]);
|
|
47
|
+
}, [onSelect, setListVisible, disabled]);
|
|
42
48
|
useComponentOutsideClick(`[data-dropdown-id="${id}"]`, isListVisible, () => setListVisible(false), hideOnOuterClick);
|
|
43
49
|
const classNames = getClassName([
|
|
44
50
|
"bbr-dropdown",
|
|
51
|
+
(disabled ?? false) ? "bbr-dropdown--disabled" : "",
|
|
45
52
|
(compact ?? false) ? "bbr-dropdown--compact" : "",
|
|
46
53
|
isListVisible ? "is-active" : "",
|
|
47
54
|
isNullOrEmpty(listMaxHeight) ? "bbr-dropdown--height-default" : "",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DropdownProps } from '../..';
|
|
2
|
-
declare const DropdownWithLabel: ({ items, value, onSelect, validationState, deselectable, className, hideOnOuterClick, listMaxHeight, label, placeholder }: DropdownProps) => JSX.Element;
|
|
2
|
+
declare const DropdownWithLabel: ({ items, value, onSelect, validationState, deselectable, className, hideOnOuterClick, listMaxHeight, label, placeholder, disabled }: DropdownProps) => JSX.Element;
|
|
3
3
|
export default DropdownWithLabel;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/withLabel/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAKtC,QAAA,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/dropdown/components/withLabel/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAKtC,QAAA,MAAM,iBAAiB,wIAOpB,aAAa,KAAG,WAoLlB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -5,11 +5,14 @@ import { getValidationValues } from '../../../../utils';
|
|
|
5
5
|
import { useComponentOutsideClick } from '../../../../hooks';
|
|
6
6
|
import DropdownItem from '../item';
|
|
7
7
|
import DropdownLabel from '../label';
|
|
8
|
-
const DropdownWithLabel = ({ items, value, onSelect, validationState, deselectable, className, hideOnOuterClick, listMaxHeight, label, placeholder }) => {
|
|
8
|
+
const DropdownWithLabel = ({ items, value, onSelect, validationState, deselectable, className, hideOnOuterClick, listMaxHeight, label, placeholder, disabled }) => {
|
|
9
9
|
const id = useId();
|
|
10
10
|
const [isListVisible, setListVisible] = useState(false);
|
|
11
11
|
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(undefined, validationState);
|
|
12
12
|
const onItemClick = useCallback((event) => {
|
|
13
|
+
if (disabled ?? false) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
13
16
|
const target = event.target;
|
|
14
17
|
if (isNullOrUndefined(target)) {
|
|
15
18
|
return;
|
|
@@ -28,8 +31,11 @@ const DropdownWithLabel = ({ items, value, onSelect, validationState, deselectab
|
|
|
28
31
|
}
|
|
29
32
|
onSelect(item);
|
|
30
33
|
setListVisible(false);
|
|
31
|
-
}, [setListVisible, value, items, onSelect]);
|
|
34
|
+
}, [setListVisible, value, items, onSelect, disabled]);
|
|
32
35
|
const onLabelClick = useCallback((event) => {
|
|
36
|
+
if (disabled ?? false) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
33
39
|
const target = event.target;
|
|
34
40
|
if (isNullOrUndefined(target)) {
|
|
35
41
|
return;
|
|
@@ -40,10 +46,11 @@ const DropdownWithLabel = ({ items, value, onSelect, validationState, deselectab
|
|
|
40
46
|
else {
|
|
41
47
|
setListVisible(state => !state);
|
|
42
48
|
}
|
|
43
|
-
}, [onSelect, setListVisible]);
|
|
49
|
+
}, [onSelect, setListVisible, disabled]);
|
|
44
50
|
useComponentOutsideClick(`[data-dropdown-id="${id}"]`, isListVisible, () => setListVisible(false), hideOnOuterClick);
|
|
45
51
|
const classNames = getClassName([
|
|
46
52
|
"bbr-dropdown",
|
|
53
|
+
(disabled ?? false) ? "bbr-dropdown--disabled" : "",
|
|
47
54
|
isListVisible ? "is-active" : "",
|
|
48
55
|
isNullOrEmpty(listMaxHeight) ? "bbr-dropdown--height-default" : "",
|
|
49
56
|
className,
|
|
@@ -5,14 +5,6 @@
|
|
|
5
5
|
display: block;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
&--compact {
|
|
9
|
-
width: fit-content;
|
|
10
|
-
|
|
11
|
-
& .dropdown-menu {
|
|
12
|
-
min-width: 11.75rem;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
8
|
&:not(.bbr-dropdown--compact) {
|
|
17
9
|
& .dropdown-menu {
|
|
18
10
|
min-width: 100%;
|
|
@@ -102,4 +94,27 @@
|
|
|
102
94
|
max-height: 15vw;
|
|
103
95
|
}
|
|
104
96
|
}
|
|
97
|
+
|
|
98
|
+
&--compact {
|
|
99
|
+
width: fit-content;
|
|
100
|
+
|
|
101
|
+
& .dropdown-menu {
|
|
102
|
+
min-width: 11.75rem;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&--disabled {
|
|
107
|
+
.bbr-dropdown__label {
|
|
108
|
+
background-color: hsl(0deg, 0%, 96%);
|
|
109
|
+
border-color: hsl(0deg, 0%, 96%);
|
|
110
|
+
box-shadow: none;
|
|
111
|
+
color: hsl(0deg, 0%, 48%);
|
|
112
|
+
|
|
113
|
+
cursor: not-allowed;
|
|
114
|
+
|
|
115
|
+
.bbr-icon {
|
|
116
|
+
pointer-events: none;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
105
120
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import './dropdown.scss';
|
|
3
2
|
import { BaseElementProps } from '../types';
|
|
4
3
|
import { InputLabel, ValidationState } from '../primitives';
|
|
@@ -6,20 +5,17 @@ import { SelectableItem } from './types';
|
|
|
6
5
|
export declare type DropdownProps = BaseElementProps & {
|
|
7
6
|
/** Items which can be selected */
|
|
8
7
|
items: Array<SelectableItem>;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
* Must be stored outside
|
|
12
|
-
*/
|
|
13
|
-
value?: SelectableItem;
|
|
8
|
+
/** Input element placeholder */
|
|
9
|
+
placeholder: string;
|
|
14
10
|
/**
|
|
15
11
|
* Action to update selected value, which stored outside
|
|
16
12
|
*/
|
|
17
13
|
onSelect: (item?: SelectableItem) => void;
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* Selected value.
|
|
16
|
+
* Must be stored outside
|
|
21
17
|
*/
|
|
22
|
-
|
|
18
|
+
value: SelectableItem;
|
|
23
19
|
/** Hide dropdown list when its opened and user click outside */
|
|
24
20
|
hideOnOuterClick: boolean;
|
|
25
21
|
/** Can user deselect */
|
|
@@ -31,8 +27,10 @@ export declare type DropdownProps = BaseElementProps & {
|
|
|
31
27
|
* Will have width by maximum current selection item width
|
|
32
28
|
*/
|
|
33
29
|
compact?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Is element disabled
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
36
34
|
/** Label configuration */
|
|
37
35
|
label?: InputLabel;
|
|
38
36
|
/** Current validation state */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropdown/index.tsx"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIzC,oBAAY,aAAa,GAAG,gBAAgB,GAAG;IAC3C,kCAAkC;IAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7B,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IAEpB;;MAEE;IACF,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C;;;MAGE;IACF,KAAK,EAAE,cAAc,CAAC;IAEtB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB,+BAA+B;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;CACrC,CAAA;AAED,yBAAyB;AACzB,QAAA,MAAM,QAAQ,UAAW,aAAa,KAAG,WAMxC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|