@conduction/components 2.1.36 → 2.1.37
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/README.md
CHANGED
|
@@ -5,18 +5,54 @@ import ReactSelect from "react-select";
|
|
|
5
5
|
import CreatableSelect from "react-select/creatable";
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
import { ErrorMessage } from "../errorMessage/ErrorMessage";
|
|
8
|
+
const selectStyles = {
|
|
9
|
+
menuPortal: (base) => ({ ...base, zIndex: 100 }),
|
|
10
|
+
option: (base) => ({
|
|
11
|
+
...base,
|
|
12
|
+
fontFamily: `var(--conduction-input-select-list-option-font-family, ${base.fontFamily})`,
|
|
13
|
+
backgroundColor: `var(--conduction-input-select-list-option-background-color, ${base.backgroundColor}) `,
|
|
14
|
+
"&:hover": {
|
|
15
|
+
backgroundColor: `var(--conduction-input-select-list-option-hover-background-color, ${base.backgroundColor})`,
|
|
16
|
+
color: `var(--conduction-input-select-list-option-hover-color, ${base.color})`,
|
|
17
|
+
fontFamily: `var(--conduction-input-select-list-option-hover-font-family, var(--conduction-input-select-list-option-font-family, ${base.fontFamily}))`,
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
placeholder: (base) => ({
|
|
21
|
+
...base,
|
|
22
|
+
fontFamily: `var(--conduction-input-select-placeholder-font-family, var(--utrecht-form-input-placeholder-font-family, ${base.fontFamily}))`,
|
|
23
|
+
color: `var(--conduction-input-select-placeholder-color, var(--utrecht-form-input-placeholder-color, ${base.color}) )`,
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
const selectMultiStyles = {
|
|
27
|
+
menuPortal: (base) => ({ ...base, zIndex: 100 }),
|
|
28
|
+
option: (base) => ({
|
|
29
|
+
...base,
|
|
30
|
+
fontFamily: `var(--conduction-input-select-list-option-font-family, ${base.fontFamily})`,
|
|
31
|
+
backgroundColor: `var(--conduction-input-select-list-option-background-color, ${base.backgroundColor}) `,
|
|
32
|
+
"&:hover": {
|
|
33
|
+
backgroundColor: `var(--conduction-input-select-list-option-hover-background-color, ${base.backgroundColor})`,
|
|
34
|
+
color: `var(--conduction-input-select-list-option-hover-color, ${base.color})`,
|
|
35
|
+
fontFamily: `var(--conduction-input-select-list-option-hover-font-family, var(--conduction-input-select-list-option-font-family, ${base.fontFamily}))`,
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
placeholder: (base) => ({
|
|
39
|
+
...base,
|
|
40
|
+
fontFamily: `var(--conduction-input-select-placeholder-font-family, var(--utrecht-form-input-placeholder-font-family, ${base.fontFamily}))`,
|
|
41
|
+
color: `var(--conduction-input-select-placeholder-color, var(--utrecht-form-input-placeholder-color, ${base.color}) )`,
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
8
44
|
export const SelectMultiple = ({ id, name, options, errors, control, validation, defaultValue, disabled, hideErrorMessage, menuPlacement, placeholder, }) => {
|
|
9
45
|
return (_jsx(Controller, { ...{ control, name, defaultValue }, rules: validation, render: ({ field: { onChange, value } }) => {
|
|
10
|
-
return (_jsxs(_Fragment, { children: [_jsx(ReactSelect, { inputId: id, value: value ?? "", className: clsx(styles.select, errors[name] && styles.error), isMulti: true, isDisabled: disabled, ...{ options, onChange, errors }, menuPortalTarget: document.body, menuPlacement: menuPlacement, styles:
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsx(ReactSelect, { inputId: id, value: value ?? "", className: clsx(styles.select, errors[name] && styles.error), isMulti: true, isDisabled: disabled, ...{ options, onChange, errors }, menuPortalTarget: document.body, menuPlacement: menuPlacement, styles: selectStyles, placeholder: disabled ? "Disabled..." : placeholder ?? "Select one or more options..." }), errors[name] && !hideErrorMessage && _jsx(ErrorMessage, { message: errors[name].message })] }));
|
|
11
47
|
} }));
|
|
12
48
|
};
|
|
13
49
|
export const SelectCreate = ({ id, name, options, errors, control, validation, defaultValue, disabled, hideErrorMessage, menuPlacement, placeholder, }) => {
|
|
14
50
|
return (_jsx(Controller, { ...{ control, name, defaultValue }, rules: validation, render: ({ field: { onChange, value } }) => {
|
|
15
|
-
return (_jsxs(_Fragment, { children: [_jsx(CreatableSelect, { inputId: id, value: value ?? "", placeholder: disabled ? "Disabled..." : placeholder ?? "Select one or more options...", className: clsx(styles.select, errors[name] && styles.error), isMulti: true, isDisabled: disabled, ...{ options, onChange, errors }, menuPortalTarget: document.body, menuPlacement: menuPlacement, styles:
|
|
51
|
+
return (_jsxs(_Fragment, { children: [_jsx(CreatableSelect, { inputId: id, value: value ?? "", placeholder: disabled ? "Disabled..." : placeholder ?? "Select one or more options...", className: clsx(styles.select, errors[name] && styles.error), isMulti: true, isDisabled: disabled, ...{ options, onChange, errors }, menuPortalTarget: document.body, menuPlacement: menuPlacement, styles: selectStyles }), errors[name] && !hideErrorMessage && _jsx(ErrorMessage, { message: errors[name].message })] }));
|
|
16
52
|
} }));
|
|
17
53
|
};
|
|
18
54
|
export const SelectSingle = ({ id, name, options, errors, control, validation, isClearable, defaultValue, disabled, hideErrorMessage, menuPlacement, placeholder, }) => {
|
|
19
55
|
return (_jsx(Controller, { ...{ control, name, defaultValue }, rules: validation, render: ({ field: { onChange, value } }) => {
|
|
20
|
-
return (_jsxs(_Fragment, { children: [_jsx(ReactSelect, { inputId: id, value: value ?? "", className: clsx(styles.select, errors[name] && styles.error), isDisabled: disabled, ...{ options, onChange, errors, isClearable }, menuPortalTarget: document.body, menuPlacement: menuPlacement, styles:
|
|
56
|
+
return (_jsxs(_Fragment, { children: [_jsx(ReactSelect, { inputId: id, value: value ?? "", className: clsx(styles.select, errors[name] && styles.error), isDisabled: disabled, ...{ options, onChange, errors, isClearable }, menuPortalTarget: document.body, menuPlacement: menuPlacement, styles: selectStyles, placeholder: disabled ? "Disabled..." : placeholder ?? "Select one or more options..." }), errors[name] && !hideErrorMessage && _jsx(ErrorMessage, { message: errors[name].message })] }));
|
|
21
57
|
} }));
|
|
22
58
|
};
|
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
--utrecht-textbox-invalid-border-color,
|
|
10
10
|
var(--utrecht-form-input-invalid-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-input-border-color)))
|
|
11
11
|
);
|
|
12
|
+
|
|
13
|
+
--conduction-input-select-list-option-font-family: "Noto Sans", Arial, sans-serif;
|
|
14
|
+
/* --conduction-input-select-list-option-background-color: unset; */
|
|
15
|
+
|
|
16
|
+
/* --conduction-input-select-list-option-hover-background-color: unset; */
|
|
17
|
+
/* --conduction-input-select-list-option-hover-color: unset; */
|
|
18
|
+
/* --conduction-input-select-list-option-font-family: unset; */
|
|
19
|
+
|
|
20
|
+
--conduction-input-select-placeholder-font-family: "Noto Sans", Arial, sans-serif;
|
|
21
|
+
--conduction-input-select-placeholder-color: #757575;
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
.select > div {
|
package/package.json
CHANGED
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
--utrecht-textbox-invalid-border-color,
|
|
10
10
|
var(--utrecht-form-input-invalid-border-color, var(--utrecht-textbox-border-color, var(--utrecht-form-input-border-color)))
|
|
11
11
|
);
|
|
12
|
+
|
|
13
|
+
--conduction-input-select-list-option-font-family: "Noto Sans", Arial, sans-serif;
|
|
14
|
+
/* --conduction-input-select-list-option-background-color: unset; */
|
|
15
|
+
|
|
16
|
+
/* --conduction-input-select-list-option-hover-background-color: unset; */
|
|
17
|
+
/* --conduction-input-select-list-option-hover-color: unset; */
|
|
18
|
+
/* --conduction-input-select-list-option-font-family: unset; */
|
|
19
|
+
|
|
20
|
+
--conduction-input-select-placeholder-font-family: "Noto Sans", Arial, sans-serif;
|
|
21
|
+
--conduction-input-select-placeholder-color: #757575;
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
.select > div {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as styles from "./select.module.css";
|
|
3
3
|
import { Control, Controller, FieldValues } from "react-hook-form";
|
|
4
|
-
import ReactSelect, { MenuPlacement } from "react-select";
|
|
4
|
+
import ReactSelect, { MenuPlacement, StylesConfig } from "react-select";
|
|
5
5
|
import CreatableSelect from "react-select/creatable";
|
|
6
6
|
import { IReactHookFormProps } from "../types";
|
|
7
7
|
import clsx from "clsx";
|
|
@@ -20,6 +20,46 @@ interface ISelectProps {
|
|
|
20
20
|
placeholder?: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const selectStyles: StylesConfig = {
|
|
24
|
+
menuPortal: (base) => ({ ...base, zIndex: 100 }),
|
|
25
|
+
option: (base) => ({
|
|
26
|
+
...base,
|
|
27
|
+
fontFamily: `var(--conduction-input-select-list-option-font-family, ${base.fontFamily})`,
|
|
28
|
+
backgroundColor: `var(--conduction-input-select-list-option-background-color, ${base.backgroundColor}) `,
|
|
29
|
+
|
|
30
|
+
"&:hover": {
|
|
31
|
+
backgroundColor: `var(--conduction-input-select-list-option-hover-background-color, ${base.backgroundColor})`,
|
|
32
|
+
color: `var(--conduction-input-select-list-option-hover-color, ${base.color})`,
|
|
33
|
+
fontFamily: `var(--conduction-input-select-list-option-hover-font-family, var(--conduction-input-select-list-option-font-family, ${base.fontFamily}))`,
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
placeholder: (base) => ({
|
|
37
|
+
...base,
|
|
38
|
+
fontFamily: `var(--conduction-input-select-placeholder-font-family, var(--utrecht-form-input-placeholder-font-family, ${base.fontFamily}))`,
|
|
39
|
+
color: `var(--conduction-input-select-placeholder-color, var(--utrecht-form-input-placeholder-color, ${base.color}) )`,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const selectMultiStyles: StylesConfig = {
|
|
44
|
+
menuPortal: (base) => ({ ...base, zIndex: 100 }),
|
|
45
|
+
option: (base) => ({
|
|
46
|
+
...base,
|
|
47
|
+
fontFamily: `var(--conduction-input-select-list-option-font-family, ${base.fontFamily})`,
|
|
48
|
+
backgroundColor: `var(--conduction-input-select-list-option-background-color, ${base.backgroundColor}) `,
|
|
49
|
+
|
|
50
|
+
"&:hover": {
|
|
51
|
+
backgroundColor: `var(--conduction-input-select-list-option-hover-background-color, ${base.backgroundColor})`,
|
|
52
|
+
color: `var(--conduction-input-select-list-option-hover-color, ${base.color})`,
|
|
53
|
+
fontFamily: `var(--conduction-input-select-list-option-hover-font-family, var(--conduction-input-select-list-option-font-family, ${base.fontFamily}))`,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
placeholder: (base) => ({
|
|
57
|
+
...base,
|
|
58
|
+
fontFamily: `var(--conduction-input-select-placeholder-font-family, var(--utrecht-form-input-placeholder-font-family, ${base.fontFamily}))`,
|
|
59
|
+
color: `var(--conduction-input-select-placeholder-color, var(--utrecht-form-input-placeholder-color, ${base.color}) )`,
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
|
|
23
63
|
export const SelectMultiple = ({
|
|
24
64
|
id,
|
|
25
65
|
name,
|
|
@@ -49,7 +89,7 @@ export const SelectMultiple = ({
|
|
|
49
89
|
{...{ options, onChange, errors }}
|
|
50
90
|
menuPortalTarget={document.body}
|
|
51
91
|
menuPlacement={menuPlacement}
|
|
52
|
-
styles={
|
|
92
|
+
styles={selectStyles}
|
|
53
93
|
placeholder={disabled ? "Disabled..." : placeholder ?? "Select one or more options..."}
|
|
54
94
|
/>
|
|
55
95
|
{errors[name] && !hideErrorMessage && <ErrorMessage message={errors[name].message} />}
|
|
@@ -90,7 +130,7 @@ export const SelectCreate = ({
|
|
|
90
130
|
{...{ options, onChange, errors }}
|
|
91
131
|
menuPortalTarget={document.body}
|
|
92
132
|
menuPlacement={menuPlacement}
|
|
93
|
-
styles={
|
|
133
|
+
styles={selectStyles}
|
|
94
134
|
/>
|
|
95
135
|
{errors[name] && !hideErrorMessage && <ErrorMessage message={errors[name].message} />}
|
|
96
136
|
</>
|
|
@@ -129,7 +169,7 @@ export const SelectSingle = ({
|
|
|
129
169
|
{...{ options, onChange, errors, isClearable }}
|
|
130
170
|
menuPortalTarget={document.body}
|
|
131
171
|
menuPlacement={menuPlacement}
|
|
132
|
-
styles={
|
|
172
|
+
styles={selectStyles}
|
|
133
173
|
placeholder={disabled ? "Disabled..." : placeholder ?? "Select one or more options..."}
|
|
134
174
|
/>
|
|
135
175
|
{errors[name] && !hideErrorMessage && <ErrorMessage message={errors[name].message} />}
|