@intility/bifrost-react-select 4.0.0-alpha.3
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/.swcrc +16 -0
- package/CHANGELOG.md +12 -0
- package/dist/Select.d.ts +85 -0
- package/dist/Select.js +246 -0
- package/dist/Select.test.d.ts +1 -0
- package/dist/assets/bfSpinner.d.ts +10 -0
- package/dist/assets/bfSpinner.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -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 +29 -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/dist/overrides/index.d.ts +6 -0
- package/dist/overrides/index.js +6 -0
- package/package.json +47 -0
- package/src/Select.md +410 -0
- package/src/Select.test.tsx +118 -0
- package/src/Select.tsx +436 -0
- package/src/assets/bfSpinner.ts +37 -0
- package/src/index.ts +8 -0
- package/src/overrides/ClearIndicator.internal.tsx +13 -0
- package/src/overrides/CustomInput.internal.tsx +32 -0
- package/src/overrides/CustomMenuList.internal.tsx +15 -0
- package/src/overrides/CustomOption.internal.tsx +29 -0
- package/src/overrides/DropdownIndicator.internal.tsx +13 -0
- package/src/overrides/LoadingIndicator.internal.tsx +9 -0
- package/src/overrides/index.ts +6 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +12 -0
package/.swcrc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/swcrc",
|
|
3
|
+
"jsc": {
|
|
4
|
+
"parser": {
|
|
5
|
+
"syntax": "typescript",
|
|
6
|
+
"tsx": true
|
|
7
|
+
},
|
|
8
|
+
"transform": {
|
|
9
|
+
"react": {
|
|
10
|
+
"runtime": "automatic"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"target": "es2022"
|
|
14
|
+
},
|
|
15
|
+
"exclude": ["\\.test\\.", "\\.d\\.ts$"]
|
|
16
|
+
}
|
package/CHANGELOG.md
ADDED
package/dist/Select.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
import { GroupBase, Props as ReactSelectProps, SelectInstance, components } 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, state: 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: Partial<typeof components>;
|
|
29
|
+
declare const selectStates: readonly ["default", "alert"];
|
|
30
|
+
export type SelectState = (typeof selectStates)[number];
|
|
31
|
+
export type SelectProps = {
|
|
32
|
+
label: ReactNode;
|
|
33
|
+
hideLabel?: boolean;
|
|
34
|
+
description?: ReactNode;
|
|
35
|
+
state?: SelectState;
|
|
36
|
+
feedback?: ReactNode;
|
|
37
|
+
required?: boolean;
|
|
38
|
+
requiredNoLabel?: boolean;
|
|
39
|
+
optional?: boolean;
|
|
40
|
+
style?: CSSProperties;
|
|
41
|
+
loading?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type SelectType = {
|
|
44
|
+
<OptionType = {
|
|
45
|
+
label: string;
|
|
46
|
+
value: string;
|
|
47
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = GroupBase<OptionType>>(props: ReactSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
48
|
+
displayName?: string;
|
|
49
|
+
};
|
|
50
|
+
declare const SelectComponent: SelectType;
|
|
51
|
+
export type AsyncType = {
|
|
52
|
+
<OptionType = {
|
|
53
|
+
label: string;
|
|
54
|
+
value: string;
|
|
55
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = {
|
|
56
|
+
options: OptionType[];
|
|
57
|
+
label?: string;
|
|
58
|
+
}>(props: AsyncSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
59
|
+
displayName?: string;
|
|
60
|
+
};
|
|
61
|
+
declare const AsyncSelect: AsyncType;
|
|
62
|
+
export type CreatableType = {
|
|
63
|
+
<OptionType = {
|
|
64
|
+
label: string;
|
|
65
|
+
value: string;
|
|
66
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = {
|
|
67
|
+
options: OptionType[];
|
|
68
|
+
label?: string;
|
|
69
|
+
}>(props: CreatableSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
70
|
+
displayName?: string;
|
|
71
|
+
};
|
|
72
|
+
declare const CreatableSelect: CreatableType;
|
|
73
|
+
export type AsyncCreatableType = {
|
|
74
|
+
<OptionType = {
|
|
75
|
+
label: string;
|
|
76
|
+
value: string;
|
|
77
|
+
}, IsMulti extends boolean = false, Group extends GroupBase<OptionType> = {
|
|
78
|
+
options: OptionType[];
|
|
79
|
+
label?: string;
|
|
80
|
+
}>(props: AsyncCreatableSelectProps<OptionType, IsMulti, Group> & RefAttributes<SelectInstance<OptionType, IsMulti, Group>> & SelectProps): React.ReactElement | null;
|
|
81
|
+
displayName?: string;
|
|
82
|
+
};
|
|
83
|
+
declare const AsyncCreatableSelect: AsyncCreatableType;
|
|
84
|
+
export { AsyncSelect, CreatableSelect, AsyncCreatableSelect };
|
|
85
|
+
export default SelectComponent;
|
package/dist/Select.js
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
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 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, Feedback, Label, useUniqueId } from '@intility/bifrost-react';
|
|
10
|
+
import { DropdownIndicator, ClearIndicator, CustomInput, CustomMenuList, CustomOption, LoadingIndicator } from './overrides';
|
|
11
|
+
const ReactSelect = ReactSelectDefaultExport.default ?? ReactSelectDefaultExport;
|
|
12
|
+
export const selectStyles = {
|
|
13
|
+
container: (provided)=>({
|
|
14
|
+
...provided,
|
|
15
|
+
'.bf-label-description + &, .bf-label + &': {
|
|
16
|
+
marginTop: 'var(--bfs4)' // add margin-top only when label or description is direct sibling with select
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
control: (provided, state)=>({
|
|
20
|
+
...provided,
|
|
21
|
+
'&:hover': {
|
|
22
|
+
borderBottomColor: state.isFocused ? 'var(--bfc-base-c-theme)' : 'var(--bfc-base-c-inverted-2)',
|
|
23
|
+
// Change color of dropdown icon when hover on Select
|
|
24
|
+
'.bf-select__dropdown-indicator': {
|
|
25
|
+
color: 'var(--bfc-theme-3)'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
backgroundColor: state.isDisabled ? 'var(--bfc-base-dimmed)' : 'var(--bfc-base-3)',
|
|
29
|
+
border: 0,
|
|
30
|
+
borderBottomWidth: '2px',
|
|
31
|
+
borderBottomStyle: 'solid',
|
|
32
|
+
borderBottomColor: state.isFocused ? 'var(--bfc-base-c-theme)' : state.isDisabled ? 'transparent' : 'var(--bfc-base-c-wcag)',
|
|
33
|
+
boxShadow: state.isFocused && '0 0 0 1px var(--bfc-theme-3)',
|
|
34
|
+
borderRadius: state.selectProps.menuIsOpen ? ' var(--bfl-border-radius) var(--bfl-border-radius) 0 0' : 'var(--bfl-border-radius)',
|
|
35
|
+
minHeight: 'var(--bfs40)',
|
|
36
|
+
cursor: 'text'
|
|
37
|
+
}),
|
|
38
|
+
indicatorSeparator: ()=>({
|
|
39
|
+
display: 'none'
|
|
40
|
+
}),
|
|
41
|
+
indicatorsContainer: (provided)=>({
|
|
42
|
+
...provided,
|
|
43
|
+
alignItems: 'flex-start',
|
|
44
|
+
padding: '7.5px 0'
|
|
45
|
+
}),
|
|
46
|
+
clearIndicator: (provided)=>({
|
|
47
|
+
...provided,
|
|
48
|
+
'&:hover': {
|
|
49
|
+
color: 'var(--bfc-base-c-1)'
|
|
50
|
+
},
|
|
51
|
+
color: 'var(--bfc-base-c-2)',
|
|
52
|
+
cursor: 'pointer',
|
|
53
|
+
padding: 'var(--bfs4)',
|
|
54
|
+
margin: '1px var(--bfs4) 0px 0px'
|
|
55
|
+
}),
|
|
56
|
+
dropdownIndicator: (provided, state)=>({
|
|
57
|
+
...provided,
|
|
58
|
+
color: state.isDisabled ? 'var(--bfc-base-c-2)' : 'var(--bfc-theme-1)',
|
|
59
|
+
cursor: 'pointer',
|
|
60
|
+
padding: 'var(--bfs4)',
|
|
61
|
+
marginRight: 'var(--bfs8)'
|
|
62
|
+
}),
|
|
63
|
+
input: (provided)=>({
|
|
64
|
+
...provided,
|
|
65
|
+
color: 'var(--bfc-base-c-1)',
|
|
66
|
+
fontFamily: 'inherit',
|
|
67
|
+
fontSize: 'var(--bf-font-size-l)'
|
|
68
|
+
}),
|
|
69
|
+
menuPortal: (provided)=>({
|
|
70
|
+
...provided,
|
|
71
|
+
zIndex: 9999
|
|
72
|
+
}),
|
|
73
|
+
menu: (provided)=>({
|
|
74
|
+
...provided,
|
|
75
|
+
backgroundColor: 'var(--bfc-base-3)',
|
|
76
|
+
boxShadow: 'none',
|
|
77
|
+
borderRadius: 'none',
|
|
78
|
+
marginTop: 0,
|
|
79
|
+
zIndex: 3
|
|
80
|
+
}),
|
|
81
|
+
menuList: (provided)=>({
|
|
82
|
+
...provided,
|
|
83
|
+
padding: 0,
|
|
84
|
+
boxShadow: '0 0 0 1px var(--bfc-theme-3)',
|
|
85
|
+
borderRadius: '0 0 var(--bfl-border-radius) var(--bfl-border-radius)'
|
|
86
|
+
}),
|
|
87
|
+
placeholder: (provided)=>({
|
|
88
|
+
...provided,
|
|
89
|
+
color: 'var(--bfc-base-c-2)',
|
|
90
|
+
fontSize: 'var(--bf-font-size-l)'
|
|
91
|
+
}),
|
|
92
|
+
singleValue: (provided, state)=>({
|
|
93
|
+
...provided,
|
|
94
|
+
color: state.selectProps.menuIsOpen ? 'var(--bfc-base-c-2)' : 'var(--bfc-base-c)',
|
|
95
|
+
fontSize: 'var(--bf-font-size-l)'
|
|
96
|
+
}),
|
|
97
|
+
option: (provided, state)=>({
|
|
98
|
+
...provided,
|
|
99
|
+
display: 'flex',
|
|
100
|
+
justifyContent: !state.isMulti ? 'space-between' : 'normal',
|
|
101
|
+
alignItems: 'baseline',
|
|
102
|
+
padding: '7px 12px',
|
|
103
|
+
backgroundColor: state.isDisabled ? 'var(--bfc-base-dimmed)' : state.isFocused ? 'var(--bfc-base-1)' : 'var(--bfc-base-3)',
|
|
104
|
+
color: 'var(--bfc-base-c)',
|
|
105
|
+
'& .bf-select-checkbox': {
|
|
106
|
+
marginRight: 'var(--bfs8)',
|
|
107
|
+
color: 'var(--bfc-theme)'
|
|
108
|
+
},
|
|
109
|
+
'& .bf-select-selected-icon': {
|
|
110
|
+
color: 'var(--bfc-base-c-theme)',
|
|
111
|
+
marginLeft: 'var(--bfs4)'
|
|
112
|
+
},
|
|
113
|
+
'&:hover': {
|
|
114
|
+
backgroundColor: state.isDisabled ? 'var(--bfc-base-dimmed)' : 'var(--bfc-base-1)',
|
|
115
|
+
cursor: state.isDisabled ? 'default' : 'pointer'
|
|
116
|
+
},
|
|
117
|
+
fontSize: 'var(--bf-font-size-l)',
|
|
118
|
+
fontWeight: state.isSelected ? 600 : 400,
|
|
119
|
+
wordBreak: 'break-word',
|
|
120
|
+
whiteSpace: 'normal'
|
|
121
|
+
}),
|
|
122
|
+
multiValue: (provided, state)=>({
|
|
123
|
+
...provided,
|
|
124
|
+
backgroundColor: state.isDisabled ? 'var(--bfc-base-c-inverted-2)' : 'var(--bfc-theme-c)',
|
|
125
|
+
borderRadius: 'var(--bfl-border-radius)'
|
|
126
|
+
}),
|
|
127
|
+
multiValueLabel: (provided, state)=>({
|
|
128
|
+
...provided,
|
|
129
|
+
color: state.isDisabled ? 'var(--bfc-base-1)' : 'var(--bfc-base-c-theme)',
|
|
130
|
+
fontSize: 'var(--bf-font-size-m)'
|
|
131
|
+
}),
|
|
132
|
+
multiValueRemove: (provided, state)=>({
|
|
133
|
+
...provided,
|
|
134
|
+
color: state.isDisabled ? 'var(--bfc-base-1)' : state.isFocused ? 'var(--bfc-theme-c-base-3)' : 'var(--bfc-theme-1)',
|
|
135
|
+
borderRadius: 'unset',
|
|
136
|
+
borderTopRightRadius: 'var(--bfl-border-radius)',
|
|
137
|
+
borderBottomRightRadius: 'var(--bfl-border-radius)',
|
|
138
|
+
paddingLeft: 'var(--bfs2)',
|
|
139
|
+
paddingRight: 'var(--bfs2)',
|
|
140
|
+
marginLeft: 'var(--bfs2)',
|
|
141
|
+
background: state.isFocused && 'var(--bfc-theme-2)',
|
|
142
|
+
'&:hover': {
|
|
143
|
+
color: 'var(--bfc-theme-c-base-3)',
|
|
144
|
+
cursor: 'pointer',
|
|
145
|
+
background: 'var(--bfc-theme)'
|
|
146
|
+
},
|
|
147
|
+
'&:active': {
|
|
148
|
+
background: 'var(--bfc-theme-2)'
|
|
149
|
+
},
|
|
150
|
+
svg: {
|
|
151
|
+
marginTop: '1px'
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
group: (provided)=>({
|
|
155
|
+
...provided,
|
|
156
|
+
padding: 'var(--bfs6) 0',
|
|
157
|
+
'&:first-of-type': {
|
|
158
|
+
marginTop: 'var(--bfs4)'
|
|
159
|
+
}
|
|
160
|
+
}),
|
|
161
|
+
groupHeading: (provided)=>({
|
|
162
|
+
...provided,
|
|
163
|
+
textTransform: 'capitalize',
|
|
164
|
+
color: 'var(--bfc-base-c-2)',
|
|
165
|
+
fontSize: 'var(--bf-font-size-s)',
|
|
166
|
+
marginBottom: 'var(--bfs2)'
|
|
167
|
+
})
|
|
168
|
+
};
|
|
169
|
+
export const selectComponents = {
|
|
170
|
+
DropdownIndicator,
|
|
171
|
+
Input: CustomInput,
|
|
172
|
+
MenuList: CustomMenuList,
|
|
173
|
+
ClearIndicator,
|
|
174
|
+
Option: CustomOption,
|
|
175
|
+
LoadingIndicator
|
|
176
|
+
};
|
|
177
|
+
const selectStates = [
|
|
178
|
+
'default',
|
|
179
|
+
'alert'
|
|
180
|
+
];
|
|
181
|
+
/**
|
|
182
|
+
* Select HOC
|
|
183
|
+
*/ const SelectHOC = (Selector)=>{
|
|
184
|
+
// @ts-ignore
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
186
|
+
const GeneratedSelect = /*#__PURE__*/ forwardRef(({ label, hideLabel = false, isDisabled = false, state, feedback, required = false, description, requiredNoLabel = false, optional = false, inputId, className, style, loading = false, components, ...props }, ref)=>{
|
|
187
|
+
const selectId = useUniqueId(inputId);
|
|
188
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
189
|
+
className: classNames(className, {
|
|
190
|
+
'bf-select-container': true
|
|
191
|
+
}, {
|
|
192
|
+
'bf-select-disabled': isDisabled
|
|
193
|
+
}, {
|
|
194
|
+
'bf-select-alert': !isDisabled && state === 'alert'
|
|
195
|
+
}),
|
|
196
|
+
style: style,
|
|
197
|
+
"data-testid": "bf-select-container",
|
|
198
|
+
children: [
|
|
199
|
+
!hideLabel && /*#__PURE__*/ _jsx(Label, {
|
|
200
|
+
htmlFor: selectId,
|
|
201
|
+
required: !isDisabled && required && !requiredNoLabel,
|
|
202
|
+
optional: optional,
|
|
203
|
+
disabled: isDisabled,
|
|
204
|
+
children: label
|
|
205
|
+
}),
|
|
206
|
+
/*#__PURE__*/ _jsx(Description, {
|
|
207
|
+
children: description
|
|
208
|
+
}),
|
|
209
|
+
/*#__PURE__*/ _jsx(Selector, {
|
|
210
|
+
ref: ref,
|
|
211
|
+
inputId: selectId,
|
|
212
|
+
placeholder: "",
|
|
213
|
+
components: {
|
|
214
|
+
...selectComponents,
|
|
215
|
+
...components
|
|
216
|
+
},
|
|
217
|
+
styles: selectStyles,
|
|
218
|
+
isDisabled: isDisabled,
|
|
219
|
+
classNamePrefix: "bf-select",
|
|
220
|
+
required: !isDisabled && (required || requiredNoLabel),
|
|
221
|
+
"aria-label": label,
|
|
222
|
+
hideSelectedOptions: false,
|
|
223
|
+
closeMenuOnSelect: props.isMulti ? false : true,
|
|
224
|
+
isLoading: loading ?? props.isLoading,
|
|
225
|
+
...props
|
|
226
|
+
}),
|
|
227
|
+
/*#__PURE__*/ _jsx(Feedback, {
|
|
228
|
+
children: feedback
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
return GeneratedSelect;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Select component - dropdown list
|
|
237
|
+
*/ const SelectComponent = SelectHOC(ReactSelect);
|
|
238
|
+
SelectComponent.displayName = 'Select';
|
|
239
|
+
const AsyncSelect = SelectHOC(AsyncReactSelect);
|
|
240
|
+
AsyncSelect.displayName = 'AsyncSelect';
|
|
241
|
+
const CreatableSelect = SelectHOC(CreatableReactSelect);
|
|
242
|
+
CreatableSelect.displayName = 'CreatableSelect';
|
|
243
|
+
const AsyncCreatableSelect = SelectHOC(AsyncCreatableReactSelect);
|
|
244
|
+
AsyncCreatableSelect.displayName = 'AsyncCreatableSelect';
|
|
245
|
+
export { AsyncSelect, CreatableSelect, AsyncCreatableSelect };
|
|
246
|
+
export default SelectComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, AsyncSelect, CreatableSelect, AsyncCreatableSelect, selectStyles, selectComponents } from './Select';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, AsyncSelect, CreatableSelect, AsyncCreatableSelect, selectStyles, selectComponents } from './Select';
|
|
@@ -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: 'noAutocomplete'
|
|
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: "noAutocomplete",
|
|
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,29 @@
|
|
|
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
|
+
className: "bf-select-checkbox"
|
|
16
|
+
})
|
|
17
|
+
}),
|
|
18
|
+
props.children,
|
|
19
|
+
!props.isMulti && props.isSelected && /*#__PURE__*/ _jsx("div", {
|
|
20
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
21
|
+
icon: faCheck,
|
|
22
|
+
fixedWidth: true,
|
|
23
|
+
className: "bf-select-selected-icon"
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
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';
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as ClearIndicator } from './ClearIndicator.internal';
|
|
2
|
+
export { default as CustomInput } from './CustomInput.internal';
|
|
3
|
+
export { default as LoadingIndicator } from './LoadingIndicator.internal';
|
|
4
|
+
export { default as CustomMenuList } from './CustomMenuList.internal';
|
|
5
|
+
export { default as DropdownIndicator } from './DropdownIndicator.internal';
|
|
6
|
+
export { default as CustomOption } from './CustomOption.internal';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as ClearIndicator } from './ClearIndicator.internal';
|
|
2
|
+
export { default as CustomInput } from './CustomInput.internal';
|
|
3
|
+
export { default as LoadingIndicator } from './LoadingIndicator.internal';
|
|
4
|
+
export { default as CustomMenuList } from './CustomMenuList.internal';
|
|
5
|
+
export { default as DropdownIndicator } from './DropdownIndicator.internal';
|
|
6
|
+
export { default as CustomOption } from './CustomOption.internal';
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intility/bifrost-react-select",
|
|
3
|
+
"version": "4.0.0-alpha.3",
|
|
4
|
+
"description": "React select component for Intility's design system, Bifrost.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.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
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
".": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://bifrost.intility.com",
|
|
21
|
+
"keywords": [
|
|
22
|
+
"react",
|
|
23
|
+
"typescript",
|
|
24
|
+
"intility",
|
|
25
|
+
"design system",
|
|
26
|
+
"bifrost",
|
|
27
|
+
"select"
|
|
28
|
+
],
|
|
29
|
+
"author": "Intility AS",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"registry": "https://registry.npmjs.org/",
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react-dom": ">=18.0.0",
|
|
37
|
+
"react": ">=18.0.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
|
41
|
+
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
|
42
|
+
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
43
|
+
"@intility/bifrost-react": "4.0.0-alpha.3",
|
|
44
|
+
"classnames": "^2.2.6",
|
|
45
|
+
"react-select": "^5.7.7"
|
|
46
|
+
}
|
|
47
|
+
}
|