@intility/bifrost-react-select 0.0.0-bifrost5-20241202131439
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/CHANGELOG.md +114 -0
- package/dist/Select.d.ts +100 -0
- package/dist/Select.js +253 -0
- package/dist/assets/bfSpinner.d.ts +10 -0
- package/dist/assets/bfSpinner.js +22 -0
- package/dist/overrides/ClearIndicator.internal.d.ts +2 -0
- package/dist/overrides/ClearIndicator.internal.js +13 -0
- package/dist/overrides/CustomInput.internal.d.ts +2 -0
- package/dist/overrides/CustomInput.internal.js +32 -0
- package/dist/overrides/CustomMenuList.internal.d.ts +2 -0
- package/dist/overrides/CustomMenuList.internal.js +11 -0
- package/dist/overrides/CustomOption.internal.d.ts +2 -0
- package/dist/overrides/CustomOption.internal.js +30 -0
- package/dist/overrides/DropdownIndicator.internal.d.ts +2 -0
- package/dist/overrides/DropdownIndicator.internal.js +13 -0
- package/dist/overrides/LoadingIndicator.internal.d.ts +1 -0
- package/dist/overrides/LoadingIndicator.internal.js +11 -0
- package/package.json +56 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @intility/bifrost-react-select
|
|
2
|
+
|
|
3
|
+
## 0.0.0-bifrost5-20241202131439
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [582d87e]
|
|
8
|
+
- Updated dependencies [65c4ebd]
|
|
9
|
+
- Updated dependencies [11e52eb]
|
|
10
|
+
- Updated dependencies [11e52eb]
|
|
11
|
+
- Updated dependencies [285f893]
|
|
12
|
+
- @intility/bifrost-react@0.0.0-bifrost5-20241202131439
|
|
13
|
+
|
|
14
|
+
## 4.3.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 9ac0d65: allow react 17 as a peer dep
|
|
19
|
+
|
|
20
|
+
## 4.3.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 2703b98: Add support for `small` variants for most form field inputs, to match existing `small` button styling.
|
|
25
|
+
|
|
26
|
+
- `<Input>`
|
|
27
|
+
- `<DatePicker>`
|
|
28
|
+
- `<FieldGroup.Item>`
|
|
29
|
+
- `<Select>`
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- f70f414: Use `theme` color for selected checkbox with multi-select
|
|
34
|
+
- c2dfb58: Added translation text for select loading state
|
|
35
|
+
|
|
36
|
+
## 4.2.4 - 2024-08-07
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 2308f1a: Update multi-select checkboxes to more closely match bifrost checkbox styling.
|
|
41
|
+
|
|
42
|
+
## 4.2.3 - 2024-08-06
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 633e7b2: chore: avoid internal barrel file imports
|
|
47
|
+
- 899927b: Fix: form field height should follow browser font-size setting. Use `rem` over `px` for height-related units for form fields (input, button, select, datepicker).
|
|
48
|
+
|
|
49
|
+
## 4.2.2 - 2024-07-30
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 3434ad1: Update Select styling to match new bifrost Button
|
|
54
|
+
|
|
55
|
+
- Increased `border-radius` (from xs to s)
|
|
56
|
+
- Slight `border-color` tweaks
|
|
57
|
+
|
|
58
|
+
- 7b2eacc: Fix: Apparently, Chrome has changed its `<input autocomplete>` behaviour and now appears to only respect `autoComplete="off"`, so lets try that and pray to the browser gods that this will satisfy all of them for the forseeable future. #758
|
|
59
|
+
|
|
60
|
+
## 4.2.1 - 2024-06-21
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- ba934052: Change option hover background to bfc-base-1
|
|
65
|
+
|
|
66
|
+
## 4.2.0 - 2024-06-13
|
|
67
|
+
|
|
68
|
+
### Minor Changes
|
|
69
|
+
|
|
70
|
+
- 833a15e4: Fix: update Select styling to allow `menuPlacement="top"` and more closely match DatePicker #754
|
|
71
|
+
|
|
72
|
+
## 4.1.0 - 2024-05-31
|
|
73
|
+
|
|
74
|
+
### Minor Changes
|
|
75
|
+
|
|
76
|
+
- ab69807d: Styling changes for Select input #740
|
|
77
|
+
|
|
78
|
+
## 4.0.3 - 2024-05-16
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- 3db0503a: Fix: `selectComponents` properties should now correcly be non-null
|
|
83
|
+
|
|
84
|
+
## 4.0.2 - 2024-04-10
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- 26deecde: Fix de-dupe issues by un-pinning `@intility/bifrost-react` version number and and moved to `devDependencies` and `peerDependencies`.
|
|
89
|
+
- Updated dependencies [79b9ab5d]
|
|
90
|
+
- @intility/bifrost-react@4.0.2
|
|
91
|
+
|
|
92
|
+
## 4.0.1 - 2024-04-05
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- 611f82ca: Removed unnecessary files from npm package output.
|
|
97
|
+
- 63f4c54d: fix: Select menu background color is no longer transparent for grouped options.
|
|
98
|
+
- Updated dependencies [611f82ca]
|
|
99
|
+
- @intility/bifrost-react@4.0.1
|
|
100
|
+
|
|
101
|
+
## 4.0.0 - 2024-04-03 (first release, previously part of @intility/bifrost-react)
|
|
102
|
+
|
|
103
|
+
### Minor Changes
|
|
104
|
+
|
|
105
|
+
- 62b02461: Include JSDoc comments in typescript definition output
|
|
106
|
+
- 6b355639: New styling for inputs, now always outlined.
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- 217c8741: Named export for Select and DatePicker
|
|
111
|
+
- a903f282: Fix: export typescript types used in react components
|
|
112
|
+
- e410a910: New base color values for light mode #711
|
|
113
|
+
- 165904af: Use deep imports from @intility/bifrost-react
|
|
114
|
+
- fdc6caee: Fix: select dropdown background should no longer bleed outside border radius when opened
|
package/dist/Select.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, RefAttributes } from "react";
|
|
2
|
+
import { GroupBase, Props as ReactSelectProps, SelectInstance, components as originalComponents } from "react-select";
|
|
3
|
+
import { AsyncProps as AsyncSelectProps } from "react-select/async";
|
|
4
|
+
import { CreatableProps as CreatableSelectProps } from "react-select/creatable";
|
|
5
|
+
import { AsyncCreatableProps as AsyncCreatableSelectProps } from "react-select/async-creatable";
|
|
6
|
+
export declare const selectStyles: {
|
|
7
|
+
container: (provided: any) => any;
|
|
8
|
+
control: (provided: any, state: any) => any;
|
|
9
|
+
indicatorSeparator: () => {
|
|
10
|
+
display: string;
|
|
11
|
+
};
|
|
12
|
+
indicatorsContainer: (provided: any) => any;
|
|
13
|
+
clearIndicator: (provided: any) => any;
|
|
14
|
+
dropdownIndicator: (provided: any, state: any) => any;
|
|
15
|
+
input: (provided: any) => any;
|
|
16
|
+
menuPortal: (provided: any) => any;
|
|
17
|
+
menu: (provided: any) => any;
|
|
18
|
+
menuList: (provided: any) => any;
|
|
19
|
+
placeholder: (provided: any) => any;
|
|
20
|
+
singleValue: (provided: any, state: any) => any;
|
|
21
|
+
option: (provided: any, state: any) => any;
|
|
22
|
+
multiValue: (provided: any, state: any) => any;
|
|
23
|
+
multiValueLabel: (provided: any) => any;
|
|
24
|
+
multiValueRemove: (provided: any, state: any) => any;
|
|
25
|
+
group: (provided: any) => any;
|
|
26
|
+
groupHeading: (provided: any) => any;
|
|
27
|
+
};
|
|
28
|
+
export declare const selectComponents: typeof originalComponents;
|
|
29
|
+
declare const selectStates: readonly ["default", "alert"];
|
|
30
|
+
export type SelectState = (typeof selectStates)[number];
|
|
31
|
+
export type SelectProps = {
|
|
32
|
+
/** Required label text */
|
|
33
|
+
label: ReactNode;
|
|
34
|
+
/** Hide label text, will add label prop as aria-label for screen readers */
|
|
35
|
+
hideLabel?: boolean;
|
|
36
|
+
/** Description text to show more information */
|
|
37
|
+
description?: ReactNode;
|
|
38
|
+
/** Available states: `default` and `alert` */
|
|
39
|
+
state?: SelectState;
|
|
40
|
+
/** Feedback text below the Select component */
|
|
41
|
+
feedback?: ReactNode;
|
|
42
|
+
/** Required prop indicating mandatory field */
|
|
43
|
+
required?: boolean;
|
|
44
|
+
/** Bool to mark Select component required, but hides the required label */
|
|
45
|
+
requiredNoLabel?: boolean;
|
|
46
|
+
/** Marks Select component as optional */
|
|
47
|
+
optional?: boolean;
|
|
48
|
+
/** Inline CSS styles */
|
|
49
|
+
style?: CSSProperties;
|
|
50
|
+
/** Displays a loading spinner */
|
|
51
|
+
loading?: boolean;
|
|
52
|
+
/** Decrease height of the input from `40px` to `32px` */
|
|
53
|
+
small?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export type SelectType = {
|
|
56
|
+
<OptionType = {
|
|
57
|
+
label: string;
|
|
58
|
+
value: string;
|
|
59
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = GroupBase<OptionType>>(props: ReactSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
60
|
+
displayName?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Select component - dropdown list
|
|
64
|
+
*/
|
|
65
|
+
export declare const Select: SelectType;
|
|
66
|
+
export type AsyncType = {
|
|
67
|
+
<OptionType = {
|
|
68
|
+
label: string;
|
|
69
|
+
value: string;
|
|
70
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = {
|
|
71
|
+
options: OptionType[];
|
|
72
|
+
label?: string;
|
|
73
|
+
}>(props: AsyncSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
74
|
+
displayName?: string;
|
|
75
|
+
};
|
|
76
|
+
declare const AsyncSelect: AsyncType;
|
|
77
|
+
export type CreatableType = {
|
|
78
|
+
<OptionType = {
|
|
79
|
+
label: string;
|
|
80
|
+
value: string;
|
|
81
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = {
|
|
82
|
+
options: OptionType[];
|
|
83
|
+
label?: string;
|
|
84
|
+
}>(props: CreatableSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
85
|
+
displayName?: string;
|
|
86
|
+
};
|
|
87
|
+
declare const CreatableSelect: CreatableType;
|
|
88
|
+
export type AsyncCreatableType = {
|
|
89
|
+
<OptionType = {
|
|
90
|
+
label: string;
|
|
91
|
+
value: string;
|
|
92
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = {
|
|
93
|
+
options: OptionType[];
|
|
94
|
+
label?: string;
|
|
95
|
+
}>(props: AsyncCreatableSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
96
|
+
displayName?: string;
|
|
97
|
+
};
|
|
98
|
+
declare const AsyncCreatableSelect: AsyncCreatableType;
|
|
99
|
+
export { AsyncSelect, CreatableSelect, AsyncCreatableSelect };
|
|
100
|
+
export default Select;
|
package/dist/Select.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */ "use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import ReactSelectDefaultExport, { components as originalComponents } from "react-select";
|
|
5
|
+
import AsyncReactSelect from "react-select/async";
|
|
6
|
+
import CreatableReactSelect from "react-select/creatable";
|
|
7
|
+
import AsyncCreatableReactSelect from "react-select/async-creatable";
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
import Description from "@intility/bifrost-react/Description";
|
|
10
|
+
import Feedback from "@intility/bifrost-react/Feedback";
|
|
11
|
+
import Label from "@intility/bifrost-react/Label";
|
|
12
|
+
import useUniqueId from "@intility/bifrost-react/hooks/useUniqueId";
|
|
13
|
+
import useLocale from "@intility/bifrost-react/hooks/useLocale";
|
|
14
|
+
import DropdownIndicator from "./overrides/DropdownIndicator.internal.js";
|
|
15
|
+
import CustomInput from "./overrides/CustomInput.internal.js";
|
|
16
|
+
import CustomMenuList from "./overrides/CustomMenuList.internal.js";
|
|
17
|
+
import ClearIndicator from "./overrides/ClearIndicator.internal.js";
|
|
18
|
+
import CustomOption from "./overrides/CustomOption.internal.js";
|
|
19
|
+
import LoadingIndicator from "./overrides/LoadingIndicator.internal.js";
|
|
20
|
+
const ReactSelect = ReactSelectDefaultExport.default ?? ReactSelectDefaultExport;
|
|
21
|
+
export const selectStyles = {
|
|
22
|
+
container: (provided)=>({
|
|
23
|
+
...provided,
|
|
24
|
+
".bf-label-description + &, .bf-label + &": {
|
|
25
|
+
marginTop: "var(--bfs4)"
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
control: (provided, state)=>({
|
|
29
|
+
...provided,
|
|
30
|
+
"&:hover": {
|
|
31
|
+
borderColor: "var(--bfc-base-c-inverted)",
|
|
32
|
+
// Change color of dropdown icon when hover on Select
|
|
33
|
+
".bf-select__dropdown-indicator": {
|
|
34
|
+
color: "var(--bfc-base-c)"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
backgroundColor: state.isDisabled ? "var(--bfc-base-dimmed)" : "var(--bfc-base-3)",
|
|
38
|
+
borderWidth: "1px",
|
|
39
|
+
borderStyle: "solid",
|
|
40
|
+
borderColor: state.isFocused ? "var(--bfc-base-c-inverted)" : state.isDisabled ? "transparent" : "var(--bfc-base-c-wcag)",
|
|
41
|
+
boxShadow: state.isFocused ? "inset 0 0 0 1px var(--bfc-base-c-inverted)" : "none",
|
|
42
|
+
borderRadius: "var(--bf-radius-s)",
|
|
43
|
+
minHeight: undefined,
|
|
44
|
+
cursor: "text"
|
|
45
|
+
}),
|
|
46
|
+
indicatorSeparator: ()=>({
|
|
47
|
+
display: "none"
|
|
48
|
+
}),
|
|
49
|
+
indicatorsContainer: (provided)=>({
|
|
50
|
+
...provided,
|
|
51
|
+
alignItems: "flex-start"
|
|
52
|
+
}),
|
|
53
|
+
clearIndicator: (provided)=>({
|
|
54
|
+
...provided,
|
|
55
|
+
"&:hover": {
|
|
56
|
+
color: "var(--bfc-base-c-1)"
|
|
57
|
+
},
|
|
58
|
+
color: "var(--bfc-base-c-2)",
|
|
59
|
+
cursor: "pointer",
|
|
60
|
+
padding: "var(--bfs4)",
|
|
61
|
+
margin: "1px 4px 0px 0px"
|
|
62
|
+
}),
|
|
63
|
+
dropdownIndicator: (provided, state)=>({
|
|
64
|
+
...provided,
|
|
65
|
+
color: state.isFocused ? "var(--bfc-base-c)" : "var(--bfc-base-c-2)",
|
|
66
|
+
cursor: "pointer",
|
|
67
|
+
padding: "var(--bfs4)",
|
|
68
|
+
marginRight: 8
|
|
69
|
+
}),
|
|
70
|
+
input: (provided)=>({
|
|
71
|
+
...provided,
|
|
72
|
+
color: "var(--bfc-base-c-1)",
|
|
73
|
+
fontFamily: "inherit",
|
|
74
|
+
fontSize: "var(--bf-font-size-l)"
|
|
75
|
+
}),
|
|
76
|
+
menuPortal: (provided)=>({
|
|
77
|
+
...provided,
|
|
78
|
+
zIndex: 9999
|
|
79
|
+
}),
|
|
80
|
+
menu: (provided)=>({
|
|
81
|
+
...provided,
|
|
82
|
+
backgroundColor: "transparent",
|
|
83
|
+
boxShadow: "none",
|
|
84
|
+
borderRadius: "none",
|
|
85
|
+
zIndex: 3
|
|
86
|
+
}),
|
|
87
|
+
menuList: (provided)=>({
|
|
88
|
+
...provided,
|
|
89
|
+
backgroundColor: "var(--bfc-base-3)",
|
|
90
|
+
padding: 0,
|
|
91
|
+
border: "1px solid var(--bfc-base-c-wcag)",
|
|
92
|
+
borderRadius: "var(--bf-radius-s)"
|
|
93
|
+
}),
|
|
94
|
+
placeholder: (provided)=>({
|
|
95
|
+
...provided,
|
|
96
|
+
color: "var(--bfc-base-c-2)",
|
|
97
|
+
fontSize: "var(--bf-font-size-l)"
|
|
98
|
+
}),
|
|
99
|
+
singleValue: (provided, state)=>({
|
|
100
|
+
...provided,
|
|
101
|
+
color: state.selectProps.menuIsOpen ? "var(--bfc-base-c-2)" : "var(--bfc-base-c)",
|
|
102
|
+
fontSize: "var(--bf-font-size-l)"
|
|
103
|
+
}),
|
|
104
|
+
option: (provided, state)=>({
|
|
105
|
+
...provided,
|
|
106
|
+
display: "flex",
|
|
107
|
+
justifyContent: !state.isMulti ? "space-between" : "normal",
|
|
108
|
+
alignItems: "baseline",
|
|
109
|
+
padding: "7px 12px",
|
|
110
|
+
backgroundColor: state.isDisabled ? "var(--bfc-base-dimmed)" : state.isFocused ? "var(--bfc-base-1)" : "var(--bfc-base-3)",
|
|
111
|
+
color: "var(--bfc-base-c)",
|
|
112
|
+
"& .bf-select-selected-icon": {
|
|
113
|
+
color: "var(--bfc-base-c)",
|
|
114
|
+
marginLeft: "var(--bfs4)"
|
|
115
|
+
},
|
|
116
|
+
"&:hover": {
|
|
117
|
+
backgroundColor: state.isDisabled ? "var(--bfc-base-dimmed)" : "var(--bfc-base-1)",
|
|
118
|
+
cursor: state.isDisabled ? "default" : "pointer"
|
|
119
|
+
},
|
|
120
|
+
fontSize: "var(--bf-font-size-l)",
|
|
121
|
+
fontWeight: state.isSelected ? 600 : 400,
|
|
122
|
+
wordBreak: "break-word",
|
|
123
|
+
whiteSpace: "normal"
|
|
124
|
+
}),
|
|
125
|
+
multiValue: (provided, state)=>({
|
|
126
|
+
...provided,
|
|
127
|
+
backgroundColor: "var(--bfc-base)",
|
|
128
|
+
borderRadius: "var(--bf-radius-xs)",
|
|
129
|
+
border: state.isDisabled ? "1px solid var(--bfc-base-c-disabled)" : "var(--bf-border)",
|
|
130
|
+
opacity: state.isDisabled ? 0.5 : 1
|
|
131
|
+
}),
|
|
132
|
+
multiValueLabel: (provided)=>({
|
|
133
|
+
...provided,
|
|
134
|
+
fontSize: "var(--bf-font-size-m)",
|
|
135
|
+
padding: "1.5px 4px 1.5px 8px",
|
|
136
|
+
color: "inherit"
|
|
137
|
+
}),
|
|
138
|
+
multiValueRemove: (provided, state)=>({
|
|
139
|
+
...provided,
|
|
140
|
+
color: "var(--bfc-base-c-2)",
|
|
141
|
+
paddingLeft: 5,
|
|
142
|
+
paddingRight: 5,
|
|
143
|
+
background: state.isFocused && "var(--bfc-theme-2)",
|
|
144
|
+
"&:hover": {
|
|
145
|
+
color: "var(--bfc-base-c-1)",
|
|
146
|
+
cursor: "pointer",
|
|
147
|
+
background: "var(--bfc-base-2)"
|
|
148
|
+
},
|
|
149
|
+
"&:active": {
|
|
150
|
+
background: "var(--bfc-base-3)"
|
|
151
|
+
},
|
|
152
|
+
svg: {
|
|
153
|
+
marginTop: "1px"
|
|
154
|
+
}
|
|
155
|
+
}),
|
|
156
|
+
group: (provided)=>({
|
|
157
|
+
...provided,
|
|
158
|
+
padding: "var(--bfs6) 0",
|
|
159
|
+
"&:first-of-type": {
|
|
160
|
+
marginTop: "var(--bfs4)"
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
groupHeading: (provided)=>({
|
|
164
|
+
...provided,
|
|
165
|
+
textTransform: "capitalize",
|
|
166
|
+
color: "var(--bfc-base-c-2)",
|
|
167
|
+
fontSize: "var(--bf-font-size-s)",
|
|
168
|
+
marginBottom: "var(--bfs2)"
|
|
169
|
+
})
|
|
170
|
+
};
|
|
171
|
+
export const selectComponents = {
|
|
172
|
+
...originalComponents,
|
|
173
|
+
DropdownIndicator,
|
|
174
|
+
Input: CustomInput,
|
|
175
|
+
MenuList: CustomMenuList,
|
|
176
|
+
ClearIndicator,
|
|
177
|
+
Option: CustomOption,
|
|
178
|
+
LoadingIndicator
|
|
179
|
+
};
|
|
180
|
+
const selectStates = [
|
|
181
|
+
"default",
|
|
182
|
+
"alert"
|
|
183
|
+
];
|
|
184
|
+
/**
|
|
185
|
+
* Select HOC
|
|
186
|
+
*/ const SelectHOC = (Selector)=>{
|
|
187
|
+
// @ts-ignore
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, react/display-name
|
|
189
|
+
const GeneratedSelect = /*#__PURE__*/ forwardRef(({ label, hideLabel = false, isDisabled = false, state, feedback, required = false, description, requiredNoLabel = false, optional = false, inputId, className, style, loading = false, components, small = false, ...props }, ref)=>{
|
|
190
|
+
const selectId = useUniqueId(inputId);
|
|
191
|
+
const locale = useLocale();
|
|
192
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
193
|
+
className: classNames(className, {
|
|
194
|
+
"bf-select-container": true
|
|
195
|
+
}, {
|
|
196
|
+
"bf-select-disabled": isDisabled
|
|
197
|
+
}, {
|
|
198
|
+
"bf-select-alert": !isDisabled && state === "alert"
|
|
199
|
+
}, {
|
|
200
|
+
"bf-select-small": small
|
|
201
|
+
}),
|
|
202
|
+
style: style,
|
|
203
|
+
"data-testid": "bf-select-container",
|
|
204
|
+
children: [
|
|
205
|
+
!hideLabel && /*#__PURE__*/ _jsx(Label, {
|
|
206
|
+
htmlFor: selectId,
|
|
207
|
+
required: !isDisabled && required && !requiredNoLabel,
|
|
208
|
+
optional: optional,
|
|
209
|
+
disabled: isDisabled,
|
|
210
|
+
children: label
|
|
211
|
+
}),
|
|
212
|
+
/*#__PURE__*/ _jsx(Description, {
|
|
213
|
+
children: description
|
|
214
|
+
}),
|
|
215
|
+
/*#__PURE__*/ _jsx(Selector, {
|
|
216
|
+
ref: ref,
|
|
217
|
+
inputId: selectId,
|
|
218
|
+
placeholder: "",
|
|
219
|
+
components: {
|
|
220
|
+
...selectComponents,
|
|
221
|
+
...components
|
|
222
|
+
},
|
|
223
|
+
styles: selectStyles,
|
|
224
|
+
isDisabled: isDisabled,
|
|
225
|
+
classNamePrefix: "bf-select",
|
|
226
|
+
required: !isDisabled && (required || requiredNoLabel),
|
|
227
|
+
"aria-label": label,
|
|
228
|
+
hideSelectedOptions: false,
|
|
229
|
+
closeMenuOnSelect: props.isMulti ? false : true,
|
|
230
|
+
isLoading: loading ?? props.isLoading,
|
|
231
|
+
loadingMessage: ()=>locale.loading + "...",
|
|
232
|
+
...props
|
|
233
|
+
}),
|
|
234
|
+
/*#__PURE__*/ _jsx(Feedback, {
|
|
235
|
+
children: feedback
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
return GeneratedSelect;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Select component - dropdown list
|
|
244
|
+
*/ export const Select = SelectHOC(ReactSelect);
|
|
245
|
+
Select.displayName = "Select";
|
|
246
|
+
const AsyncSelect = SelectHOC(AsyncReactSelect);
|
|
247
|
+
AsyncSelect.displayName = "AsyncSelect";
|
|
248
|
+
const CreatableSelect = SelectHOC(CreatableReactSelect);
|
|
249
|
+
CreatableSelect.displayName = "CreatableSelect";
|
|
250
|
+
const AsyncCreatableSelect = SelectHOC(AsyncCreatableReactSelect);
|
|
251
|
+
AsyncCreatableSelect.displayName = "AsyncCreatableSelect";
|
|
252
|
+
export { AsyncSelect, CreatableSelect, AsyncCreatableSelect };
|
|
253
|
+
export default Select;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IconDefinition, IconName, IconPathData, IconPrefix } from "@fortawesome/fontawesome-svg-core";
|
|
2
|
+
declare const prefix: IconPrefix;
|
|
3
|
+
declare const iconName: IconName;
|
|
4
|
+
declare const width = 18;
|
|
5
|
+
declare const height = 18;
|
|
6
|
+
declare const aliases: never[];
|
|
7
|
+
declare const unicode = "";
|
|
8
|
+
declare const svgPathData: IconPathData;
|
|
9
|
+
declare const definition: IconDefinition;
|
|
10
|
+
export { definition as default, definition as faIndeterminate, definition, prefix, iconName, width, height, aliases as ligatures, unicode, svgPathData, aliases, };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const prefix = "fac";
|
|
2
|
+
const iconName = "bf-spinner";
|
|
3
|
+
const width = 18;
|
|
4
|
+
const height = 18;
|
|
5
|
+
const aliases = [];
|
|
6
|
+
const unicode = "";
|
|
7
|
+
const svgPathData = [
|
|
8
|
+
"M9 2C5.13401 2 2 5.13401 2 9C2 12.866 5.13401 16 9 16C12.866 16 16 12.866 16 9C16 5.13401 12.866 2 9 2ZM0 9C0 4.02944 4.02944 0 9 0C13.9706 0 18 4.02944 18 9C18 13.9706 13.9706 18 9 18C4.02944 18 0 13.9706 0 9Z",
|
|
9
|
+
"M8 1C8 0.447715 8.44772 0 9 0C13.9706 0 18 4.02944 18 9C18 9.55229 17.5523 10 17 10C16.4477 10 16 9.55229 16 9C16 5.13401 12.866 2 9 2C8.44772 2 8 1.55228 8 1Z"
|
|
10
|
+
];
|
|
11
|
+
const definition = {
|
|
12
|
+
prefix,
|
|
13
|
+
iconName,
|
|
14
|
+
icon: [
|
|
15
|
+
width,
|
|
16
|
+
height,
|
|
17
|
+
aliases,
|
|
18
|
+
unicode,
|
|
19
|
+
svgPathData
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
export { definition as default, definition as faIndeterminate, definition, prefix, iconName, width, height, aliases as ligatures, unicode, svgPathData, aliases };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@intility/bifrost-react";
|
|
3
|
+
import { components } from "react-select";
|
|
4
|
+
import { faXmark } from "@fortawesome/free-solid-svg-icons/faXmark";
|
|
5
|
+
const ClearIndicator = (props)=>{
|
|
6
|
+
return /*#__PURE__*/ _jsx(components.ClearIndicator, {
|
|
7
|
+
...props,
|
|
8
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
9
|
+
icon: faXmark
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export default ClearIndicator;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { components } from "react-select";
|
|
3
|
+
const CustomInput = (props)=>{
|
|
4
|
+
const { required, value } = props.selectProps;
|
|
5
|
+
const updatedProps = {
|
|
6
|
+
...props,
|
|
7
|
+
autoComplete: "off"
|
|
8
|
+
};
|
|
9
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ _jsx(components.Input, {
|
|
12
|
+
...updatedProps
|
|
13
|
+
}),
|
|
14
|
+
/*#__PURE__*/ _jsx("input", {
|
|
15
|
+
style: {
|
|
16
|
+
opacity: 0,
|
|
17
|
+
height: 0,
|
|
18
|
+
position: "absolute",
|
|
19
|
+
pointerEvents: "none"
|
|
20
|
+
},
|
|
21
|
+
onChange: (e)=>e.preventDefault(),
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
value: value?.label ?? "",
|
|
24
|
+
tabIndex: -1,
|
|
25
|
+
autoComplete: "off",
|
|
26
|
+
required: required,
|
|
27
|
+
"data-testid": "bf-select-input"
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export default CustomInput;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { components } from "react-select";
|
|
3
|
+
const CustomMenuList = (props)=>{
|
|
4
|
+
return /*#__PURE__*/ _jsx(components.MenuList, {
|
|
5
|
+
"data-testid": "bf-select-menulist",
|
|
6
|
+
className: "bf-scrollbar-small",
|
|
7
|
+
...props,
|
|
8
|
+
children: props.children
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export default CustomMenuList;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { components } from "react-select";
|
|
3
|
+
import { faSquare } from "@fortawesome/free-regular-svg-icons/faSquare";
|
|
4
|
+
import { faCheckSquare } from "@fortawesome/free-solid-svg-icons/faCheckSquare";
|
|
5
|
+
import { faCheck } from "@fortawesome/free-solid-svg-icons/faCheck";
|
|
6
|
+
import { Icon } from "@intility/bifrost-react";
|
|
7
|
+
const CustomOption = (props)=>{
|
|
8
|
+
return /*#__PURE__*/ _jsxs(components.Option, {
|
|
9
|
+
...props,
|
|
10
|
+
children: [
|
|
11
|
+
props.isMulti && /*#__PURE__*/ _jsx("div", {
|
|
12
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
13
|
+
icon: props.isSelected ? faCheckSquare : faSquare,
|
|
14
|
+
fixedWidth: true,
|
|
15
|
+
marginRight: true,
|
|
16
|
+
color: props.isSelected ? "var(--bfc-theme)" : "var(--bfc-base-c-2)"
|
|
17
|
+
})
|
|
18
|
+
}),
|
|
19
|
+
props.children,
|
|
20
|
+
!props.isMulti && props.isSelected && /*#__PURE__*/ _jsx("div", {
|
|
21
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
22
|
+
icon: faCheck,
|
|
23
|
+
fixedWidth: true,
|
|
24
|
+
className: "bf-select-selected-icon"
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export default CustomOption;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { components } from "react-select";
|
|
3
|
+
import { faCaretDown } from "@fortawesome/free-solid-svg-icons/faCaretDown";
|
|
4
|
+
import { Icon } from "@intility/bifrost-react";
|
|
5
|
+
const DropdownIndicator = (props)=>{
|
|
6
|
+
return /*#__PURE__*/ _jsx(components.DropdownIndicator, {
|
|
7
|
+
...props,
|
|
8
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
9
|
+
icon: faCaretDown
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export default DropdownIndicator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function LoadingIndicator(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@intility/bifrost-react";
|
|
3
|
+
import bfSpinner from "../assets/bfSpinner.js";
|
|
4
|
+
export default function LoadingIndicator() {
|
|
5
|
+
return /*#__PURE__*/ _jsx(Icon, {
|
|
6
|
+
icon: bfSpinner,
|
|
7
|
+
spin: true,
|
|
8
|
+
fixedWidth: true,
|
|
9
|
+
className: "bf-input-loading-icon"
|
|
10
|
+
});
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intility/bifrost-react-select",
|
|
3
|
+
"version": "0.0.0-bifrost5-20241202131439",
|
|
4
|
+
"description": "React select component for Intility's design system, Bifrost.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/Select.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "run-p build:*",
|
|
9
|
+
"build:module": "swc ./src -d dist",
|
|
10
|
+
"build:types": "tsc",
|
|
11
|
+
"start": "run-p watch:*",
|
|
12
|
+
"watch:module": "npm run build:module -- --watch",
|
|
13
|
+
"watch:types": "npm run build:types -- --watch --preserveWatchOutput",
|
|
14
|
+
"clean": "rimraf dist",
|
|
15
|
+
"lint": "eslint ./src/**/*.{ts,tsx}"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
".": "./dist/Select.js"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://bifrost.intility.com",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"react",
|
|
24
|
+
"typescript",
|
|
25
|
+
"intility",
|
|
26
|
+
"design system",
|
|
27
|
+
"bifrost",
|
|
28
|
+
"select"
|
|
29
|
+
],
|
|
30
|
+
"author": "Intility AS",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"registry": "https://registry.npmjs.org/",
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react-dom": ">=17.0.0",
|
|
38
|
+
"react": ">=17.0.0",
|
|
39
|
+
"@intility/bifrost-react": "0.0.0-bifrost5-20241202131439"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@intility/bifrost-react": "0.0.0-bifrost5-20241202131439"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
|
46
|
+
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
|
47
|
+
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
48
|
+
"classnames": "^2.2.6",
|
|
49
|
+
"react-select": "^5.7.7"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"CHANGELOG.md",
|
|
53
|
+
"dist/**/*",
|
|
54
|
+
"!dist/**/*.test.*"
|
|
55
|
+
]
|
|
56
|
+
}
|