@atlaskit/react-select 1.5.1 → 1.6.0
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 +16 -0
- package/dist/cjs/components/group.js +2 -7
- package/dist/cjs/components/index.js +0 -3
- package/dist/cjs/components/indicators.js +54 -133
- package/dist/cjs/components/input.js +5 -8
- package/dist/cjs/components/menu.js +23 -21
- package/dist/cjs/components/multi-value.js +47 -10
- package/dist/cjs/components/single-value.js +1 -2
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/select.js +88 -131
- package/dist/cjs/styles.js +0 -1
- package/dist/cjs/utils.js +1 -2
- package/dist/es2019/components/group.js +2 -7
- package/dist/es2019/components/index.js +1 -4
- package/dist/es2019/components/indicators.js +39 -113
- package/dist/es2019/components/input.js +5 -9
- package/dist/es2019/components/menu.js +23 -29
- package/dist/es2019/components/multi-value.js +48 -12
- package/dist/es2019/components/single-value.js +1 -4
- package/dist/es2019/index.js +0 -1
- package/dist/es2019/select.js +7 -52
- package/dist/es2019/styles.js +1 -2
- package/dist/es2019/utils.js +0 -2
- package/dist/esm/components/group.js +2 -7
- package/dist/esm/components/index.js +1 -4
- package/dist/esm/components/indicators.js +54 -133
- package/dist/esm/components/input.js +5 -8
- package/dist/esm/components/menu.js +23 -21
- package/dist/esm/components/multi-value.js +48 -11
- package/dist/esm/components/single-value.js +1 -2
- package/dist/esm/index.js +0 -1
- package/dist/esm/select.js +88 -131
- package/dist/esm/styles.js +1 -2
- package/dist/esm/utils.js +1 -2
- package/dist/types/components/group.d.ts +1 -2
- package/dist/types/components/index.d.ts +16 -22
- package/dist/types/components/indicators.d.ts +1 -16
- package/dist/types/components/input.d.ts +1 -1
- package/dist/types/components/menu.d.ts +3 -3
- package/dist/types/components/multi-value.d.ts +3 -2
- package/dist/types/components/single-value.d.ts +1 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/select.d.ts +15 -28
- package/dist/types/styles.d.ts +1 -3
- package/dist/types/theme.d.ts +0 -1
- package/dist/types/types.d.ts +0 -1
- package/dist/types-ts4.5/components/group.d.ts +1 -2
- package/dist/types-ts4.5/components/index.d.ts +16 -22
- package/dist/types-ts4.5/components/indicators.d.ts +1 -16
- package/dist/types-ts4.5/components/input.d.ts +1 -1
- package/dist/types-ts4.5/components/menu.d.ts +3 -3
- package/dist/types-ts4.5/components/multi-value.d.ts +3 -2
- package/dist/types-ts4.5/components/single-value.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -3
- package/dist/types-ts4.5/select.d.ts +15 -28
- package/dist/types-ts4.5/styles.d.ts +1 -3
- package/dist/types-ts4.5/theme.d.ts +0 -1
- package/dist/types-ts4.5/types.d.ts +0 -1
- package/package.json +11 -2
- package/types/package.json +17 -0
|
@@ -4,48 +4,28 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { jsx } from '@emotion/react';
|
|
8
|
+
import DownIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
|
9
|
+
import CrossIcon from '@atlaskit/icon/utility/migration/cross-circle--select-clear';
|
|
10
|
+
import { Inline, Pressable, xcss } from '@atlaskit/primitives';
|
|
11
|
+
import Spinner from '@atlaskit/spinner';
|
|
8
12
|
import { getStyleProps } from '../utils';
|
|
9
13
|
|
|
10
14
|
// ==============================
|
|
11
15
|
// Dropdown & Clear Icons
|
|
12
16
|
// ==============================
|
|
13
17
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const iconContainerStyles = xcss({
|
|
19
|
+
all: 'unset',
|
|
20
|
+
outline: 'revert',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
padding: 'space.025'
|
|
25
|
+
});
|
|
26
|
+
const dropdownWrapperStyles = xcss({
|
|
27
|
+
padding: 'space.075'
|
|
20
28
|
});
|
|
21
|
-
const Svg = ({
|
|
22
|
-
size,
|
|
23
|
-
...props
|
|
24
|
-
}) => jsx("svg", _extends({
|
|
25
|
-
height: size,
|
|
26
|
-
width: size,
|
|
27
|
-
viewBox: "0 0 20 20",
|
|
28
|
-
"aria-hidden": "true",
|
|
29
|
-
focusable: "false",
|
|
30
|
-
css: styles
|
|
31
|
-
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
32
|
-
}, props));
|
|
33
|
-
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
34
|
-
export const CrossIcon = props =>
|
|
35
|
-
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
36
|
-
jsx(Svg, _extends({
|
|
37
|
-
size: 20
|
|
38
|
-
}, props), jsx("path", {
|
|
39
|
-
d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"
|
|
40
|
-
}));
|
|
41
|
-
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
42
|
-
export const DownChevron = props =>
|
|
43
|
-
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
44
|
-
jsx(Svg, _extends({
|
|
45
|
-
size: 20
|
|
46
|
-
}, props), jsx("path", {
|
|
47
|
-
d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
|
48
|
-
}));
|
|
49
29
|
|
|
50
30
|
// ==============================
|
|
51
31
|
// Dropdown & Clear Buttons
|
|
@@ -68,13 +48,20 @@ export const dropdownIndicatorCSS = ({
|
|
|
68
48
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
69
49
|
export const DropdownIndicator = props => {
|
|
70
50
|
const {
|
|
71
|
-
|
|
72
|
-
|
|
51
|
+
innerProps,
|
|
52
|
+
children
|
|
73
53
|
} = props;
|
|
74
54
|
return jsx("div", _extends({}, getStyleProps(props, 'dropdownIndicator', {
|
|
75
55
|
indicator: true,
|
|
76
56
|
'dropdown-indicator': true
|
|
77
|
-
}), innerProps), children
|
|
57
|
+
}), innerProps), children ? children : jsx(Inline, {
|
|
58
|
+
as: "span",
|
|
59
|
+
xcss: dropdownWrapperStyles
|
|
60
|
+
}, jsx(DownIcon, {
|
|
61
|
+
color: "currentColor",
|
|
62
|
+
label: "open",
|
|
63
|
+
LEGACY_margin: "var(--ds-space-negative-075, -0.375rem)"
|
|
64
|
+
})));
|
|
78
65
|
};
|
|
79
66
|
export const clearIndicatorCSS = ({
|
|
80
67
|
isCompact
|
|
@@ -92,37 +79,21 @@ export const clearIndicatorCSS = ({
|
|
|
92
79
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
93
80
|
export const ClearIndicator = props => {
|
|
94
81
|
const {
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
innerProps,
|
|
83
|
+
clearControlLabel = 'clear'
|
|
97
84
|
} = props;
|
|
98
85
|
return jsx("div", _extends({}, getStyleProps(props, 'clearIndicator', {
|
|
99
86
|
indicator: true,
|
|
100
87
|
'clear-indicator': true
|
|
101
|
-
}), innerProps),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}) => ({
|
|
111
|
-
label: 'indicatorSeparator',
|
|
112
|
-
alignSelf: 'stretch',
|
|
113
|
-
width: 1,
|
|
114
|
-
backgroundColor: isDisabled ? "var(--ds-border-disabled, #091E420F)" : "var(--ds-border, #091E4224)",
|
|
115
|
-
marginBottom: "var(--ds-space-100, 8px)",
|
|
116
|
-
marginTop: "var(--ds-space-100, 8px)"
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
120
|
-
export const IndicatorSeparator = props => {
|
|
121
|
-
const {
|
|
122
|
-
innerProps
|
|
123
|
-
} = props;
|
|
124
|
-
return jsx("span", _extends({}, innerProps, getStyleProps(props, 'indicatorSeparator', {
|
|
125
|
-
'indicator-separator': true
|
|
88
|
+
}), innerProps), jsx(Pressable, {
|
|
89
|
+
xcss: iconContainerStyles,
|
|
90
|
+
tabIndex: -1,
|
|
91
|
+
"aria-label": clearControlLabel
|
|
92
|
+
}, jsx(CrossIcon, {
|
|
93
|
+
label: "",
|
|
94
|
+
color: "currentColor",
|
|
95
|
+
LEGACY_size: "small",
|
|
96
|
+
LEGACY_margin: "var(--ds-space-negative-025, -0.125rem)"
|
|
126
97
|
})));
|
|
127
98
|
};
|
|
128
99
|
|
|
@@ -130,50 +101,12 @@ export const IndicatorSeparator = props => {
|
|
|
130
101
|
// Loading
|
|
131
102
|
// ==============================
|
|
132
103
|
|
|
133
|
-
const loadingDotAnimations = keyframes({
|
|
134
|
-
'0%, 80%, 100%': {
|
|
135
|
-
opacity: 0
|
|
136
|
-
},
|
|
137
|
-
'40%': {
|
|
138
|
-
opacity: 1
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
104
|
export const loadingIndicatorCSS = ({
|
|
142
|
-
|
|
143
|
-
size,
|
|
144
|
-
isCompact,
|
|
145
|
-
theme: {
|
|
146
|
-
colors
|
|
147
|
-
}
|
|
105
|
+
isCompact
|
|
148
106
|
}) => ({
|
|
149
107
|
label: 'loadingIndicator',
|
|
150
|
-
display: 'flex',
|
|
151
|
-
transition: 'color 150ms',
|
|
152
|
-
alignSelf: 'center',
|
|
153
|
-
fontSize: size,
|
|
154
|
-
lineHeight: 1,
|
|
155
|
-
marginRight: size,
|
|
156
|
-
textAlign: 'center',
|
|
157
|
-
verticalAlign: 'middle',
|
|
158
|
-
color: isFocused ? colors.neutral60 : colors.neutral20,
|
|
159
108
|
padding: `${isCompact ? 0 : "var(--ds-space-075, 6px)"} ${"var(--ds-space-100, 8px)"}`
|
|
160
109
|
});
|
|
161
|
-
const LoadingDot = ({
|
|
162
|
-
delay,
|
|
163
|
-
offset
|
|
164
|
-
}) => jsx("span", {
|
|
165
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
166
|
-
css: {
|
|
167
|
-
animation: `${loadingDotAnimations} 1s ease-in-out ${delay}ms infinite;`,
|
|
168
|
-
backgroundColor: 'currentColor',
|
|
169
|
-
borderRadius: '1em',
|
|
170
|
-
display: 'inline-block',
|
|
171
|
-
marginLeft: offset ? '1em' : undefined,
|
|
172
|
-
height: '1em',
|
|
173
|
-
verticalAlign: 'top',
|
|
174
|
-
width: '1em'
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
110
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
178
111
|
export const LoadingIndicator = ({
|
|
179
112
|
innerProps,
|
|
@@ -189,14 +122,7 @@ export const LoadingIndicator = ({
|
|
|
189
122
|
}, 'loadingIndicator', {
|
|
190
123
|
indicator: true,
|
|
191
124
|
'loading-indicator': true
|
|
192
|
-
}), innerProps), jsx(
|
|
193
|
-
|
|
194
|
-
offset: isRtl
|
|
195
|
-
}), jsx(LoadingDot, {
|
|
196
|
-
delay: 160,
|
|
197
|
-
offset: true
|
|
198
|
-
}), jsx(LoadingDot, {
|
|
199
|
-
delay: 320,
|
|
200
|
-
offset: !isRtl
|
|
125
|
+
}), innerProps), jsx(Spinner, {
|
|
126
|
+
size: "small"
|
|
201
127
|
}));
|
|
202
128
|
};
|
|
@@ -8,21 +8,17 @@ import { jsx } from '@emotion/react';
|
|
|
8
8
|
import { cleanCommonProps, getStyleProps } from '../utils';
|
|
9
9
|
export const inputCSS = ({
|
|
10
10
|
isDisabled,
|
|
11
|
-
value
|
|
12
|
-
theme: {
|
|
13
|
-
spacing,
|
|
14
|
-
colors
|
|
15
|
-
}
|
|
11
|
+
value
|
|
16
12
|
}) => ({
|
|
17
13
|
visibility: isDisabled ? 'hidden' : 'visible',
|
|
18
14
|
// force css to recompute when value change due to @emotion bug.
|
|
19
15
|
// We can remove it whenever the bug is fixed.
|
|
20
16
|
transform: value ? 'translateZ(0)' : '',
|
|
21
17
|
...containerStyle,
|
|
22
|
-
margin:
|
|
23
|
-
paddingBottom:
|
|
24
|
-
paddingTop:
|
|
25
|
-
color: "var(--ds-text,
|
|
18
|
+
margin: "var(--ds-space-025, 2px)",
|
|
19
|
+
paddingBottom: "var(--ds-space-025, 2px)",
|
|
20
|
+
paddingTop: "var(--ds-space-025, 2px)",
|
|
21
|
+
color: "var(--ds-text, #172B4D)"
|
|
26
22
|
});
|
|
27
23
|
const spacingStyle = {
|
|
28
24
|
gridArea: '1 / 2',
|
|
@@ -8,6 +8,8 @@ import { jsx } from '@emotion/react';
|
|
|
8
8
|
import { autoUpdate } from '@floating-ui/dom';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import useLayoutEffect from 'use-isomorphic-layout-effect';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { Text } from '@atlaskit/primitives';
|
|
11
13
|
import { animatedScrollTo, getBoundingClientObj, getScrollParent, getScrollTop, getStyleProps, normalizedHeight, scrollTo } from '../utils';
|
|
12
14
|
|
|
13
15
|
// ==============================
|
|
@@ -40,7 +42,8 @@ export function getMenuPlacement({
|
|
|
40
42
|
// we can't trust `scrollParent.scrollHeight` --> it may increase when
|
|
41
43
|
// the menu is rendered
|
|
42
44
|
const {
|
|
43
|
-
height: scrollHeight
|
|
45
|
+
height: scrollHeight,
|
|
46
|
+
top: scrollParentTop
|
|
44
47
|
} = scrollParent.getBoundingClientRect();
|
|
45
48
|
const {
|
|
46
49
|
bottom: menuBottom,
|
|
@@ -52,12 +55,14 @@ export function getMenuPlacement({
|
|
|
52
55
|
} = menuEl.offsetParent.getBoundingClientRect();
|
|
53
56
|
const viewHeight = isFixedPosition ? window.innerHeight : normalizedHeight(scrollParent);
|
|
54
57
|
const scrollTop = getScrollTop(scrollParent);
|
|
58
|
+
// use menuTop - scrollParentTop for the actual top space of menu in the scroll container
|
|
59
|
+
const menuTopFromParent = fg('design-system-select-fix-placement') ? menuTop - scrollParentTop : menuTop;
|
|
55
60
|
const marginBottom = parseInt(getComputedStyle(menuEl).marginBottom, 10);
|
|
56
61
|
const marginTop = parseInt(getComputedStyle(menuEl).marginTop, 10);
|
|
57
62
|
const viewSpaceAbove = containerTop - marginTop;
|
|
58
|
-
const viewSpaceBelow = viewHeight -
|
|
63
|
+
const viewSpaceBelow = viewHeight - menuTopFromParent;
|
|
59
64
|
const scrollSpaceAbove = viewSpaceAbove + scrollTop;
|
|
60
|
-
const scrollSpaceBelow = scrollHeight - scrollTop -
|
|
65
|
+
const scrollSpaceBelow = scrollHeight - scrollTop - menuTopFromParent;
|
|
61
66
|
const scrollDown = menuBottom - viewHeight + scrollTop + marginBottom;
|
|
62
67
|
const scrollUp = scrollTop + menuTop - marginTop;
|
|
63
68
|
const scrollDuration = 160;
|
|
@@ -188,21 +193,16 @@ function alignToControl(placement) {
|
|
|
188
193
|
}
|
|
189
194
|
const coercePlacement = p => p === 'auto' ? 'bottom' : p;
|
|
190
195
|
export const menuCSS = ({
|
|
191
|
-
placement
|
|
192
|
-
theme: {
|
|
193
|
-
borderRadius,
|
|
194
|
-
spacing,
|
|
195
|
-
colors
|
|
196
|
-
}
|
|
196
|
+
placement
|
|
197
197
|
}) => ({
|
|
198
198
|
label: 'menu',
|
|
199
199
|
[alignToControl(placement)]: '100%',
|
|
200
200
|
position: 'absolute',
|
|
201
201
|
width: '100%',
|
|
202
202
|
zIndex: 1,
|
|
203
|
-
borderRadius:
|
|
204
|
-
marginBottom:
|
|
205
|
-
marginTop:
|
|
203
|
+
borderRadius: "var(--ds-border-radius, 4px)",
|
|
204
|
+
marginBottom: "var(--ds-space-100, 8px)",
|
|
205
|
+
marginTop: "var(--ds-space-100, 8px)",
|
|
206
206
|
backgroundColor: "var(--ds-surface-overlay, white)",
|
|
207
207
|
boxShadow: "var(--ds-shadow-overlay, 0 0 0 1px hsl(0deg 0% 0% / 10%), 0 4px 11px hsl(0deg 0% 0% / 10%))"
|
|
208
208
|
});
|
|
@@ -217,8 +217,7 @@ export const MenuPlacer = props => {
|
|
|
217
217
|
maxMenuHeight,
|
|
218
218
|
menuPlacement,
|
|
219
219
|
menuPosition,
|
|
220
|
-
menuShouldScrollIntoView
|
|
221
|
-
theme
|
|
220
|
+
menuShouldScrollIntoView
|
|
222
221
|
} = props;
|
|
223
222
|
const {
|
|
224
223
|
setPortalPlacement
|
|
@@ -226,9 +225,8 @@ export const MenuPlacer = props => {
|
|
|
226
225
|
const ref = useRef(null);
|
|
227
226
|
const [maxHeight, setMaxHeight] = useState(maxMenuHeight);
|
|
228
227
|
const [placement, setPlacement] = useState(null);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
} = theme.spacing;
|
|
228
|
+
// The minimum height of the control
|
|
229
|
+
const controlHeight = 38;
|
|
232
230
|
useLayoutEffect(() => {
|
|
233
231
|
const menuEl = ref.current;
|
|
234
232
|
if (!menuEl) {
|
|
@@ -314,17 +312,9 @@ export const MenuList = props => {
|
|
|
314
312
|
// Menu Notices
|
|
315
313
|
// ==============================
|
|
316
314
|
|
|
317
|
-
const noticeCSS = ({
|
|
318
|
-
theme: {
|
|
319
|
-
spacing: {
|
|
320
|
-
baseUnit
|
|
321
|
-
},
|
|
322
|
-
colors
|
|
323
|
-
}
|
|
324
|
-
}) => ({
|
|
315
|
+
const noticeCSS = ({}) => ({
|
|
325
316
|
textAlign: 'center',
|
|
326
|
-
|
|
327
|
-
padding: `${baseUnit * 2}px ${baseUnit * 3}px`
|
|
317
|
+
padding: `${"var(--ds-space-100, 8px)"} ${"var(--ds-space-150, 12px)"}`
|
|
328
318
|
});
|
|
329
319
|
export const noOptionsMessageCSS = noticeCSS;
|
|
330
320
|
export const loadingMessageCSS = noticeCSS;
|
|
@@ -344,7 +334,9 @@ export const NoOptionsMessage = ({
|
|
|
344
334
|
}), {
|
|
345
335
|
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
346
336
|
role: "option"
|
|
347
|
-
}, innerProps),
|
|
337
|
+
}, innerProps), jsx(Text, {
|
|
338
|
+
color: "color.text.subtle"
|
|
339
|
+
}, children));
|
|
348
340
|
};
|
|
349
341
|
|
|
350
342
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
@@ -363,7 +355,9 @@ export const LoadingMessage = ({
|
|
|
363
355
|
}), innerProps, {
|
|
364
356
|
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
365
357
|
role: "option"
|
|
366
|
-
}),
|
|
358
|
+
}), jsx(Text, {
|
|
359
|
+
color: "color.text.subtle"
|
|
360
|
+
}, children));
|
|
367
361
|
};
|
|
368
362
|
|
|
369
363
|
// ==============================
|
|
@@ -4,18 +4,15 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { jsx } from '@emotion/react';
|
|
7
|
+
import { css, jsx } from '@emotion/react';
|
|
8
|
+
import LegacySelectClearIcon from '@atlaskit/icon/glyph/select-clear';
|
|
9
|
+
import CrossIcon from '@atlaskit/icon/utility/cross';
|
|
8
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { Inline, xcss } from '@atlaskit/primitives';
|
|
9
12
|
import { getStyleProps } from '../utils';
|
|
10
|
-
import { CrossIcon } from './indicators';
|
|
11
13
|
export const multiValueCSS = ({
|
|
12
14
|
isDisabled,
|
|
13
|
-
isFocused
|
|
14
|
-
theme: {
|
|
15
|
-
spacing,
|
|
16
|
-
borderRadius,
|
|
17
|
-
colors
|
|
18
|
-
}
|
|
15
|
+
isFocused
|
|
19
16
|
}) => {
|
|
20
17
|
let backgroundColor;
|
|
21
18
|
let color;
|
|
@@ -127,15 +124,53 @@ export const MultiValueContainer = MultiValueGeneric;
|
|
|
127
124
|
|
|
128
125
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
129
126
|
export const MultiValueLabel = MultiValueGeneric;
|
|
127
|
+
const disabledStyles = css({
|
|
128
|
+
display: 'none'
|
|
129
|
+
});
|
|
130
|
+
const enabledStyles = css({
|
|
131
|
+
display: 'inherit'
|
|
132
|
+
});
|
|
133
|
+
const iconWrapperStyles = xcss({
|
|
134
|
+
padding: 'space.025'
|
|
135
|
+
});
|
|
136
|
+
const renderIcon = () => {
|
|
137
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
138
|
+
if (fg('platform-component-visual-refresh')) {
|
|
139
|
+
return jsx(CrossIcon, {
|
|
140
|
+
label: "Clear",
|
|
141
|
+
color: "currentColor"
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
146
|
+
if (fg('platform-visual-refresh-icons-legacy-facade')) {
|
|
147
|
+
return jsx(Inline, {
|
|
148
|
+
xcss: iconWrapperStyles
|
|
149
|
+
}, jsx(CrossIcon, {
|
|
150
|
+
label: "Clear",
|
|
151
|
+
color: "currentColor"
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
return (
|
|
155
|
+
// eslint-disable-next-line @atlaskit/design-system/no-legacy-icons
|
|
156
|
+
jsx(LegacySelectClearIcon, {
|
|
157
|
+
label: "Clear",
|
|
158
|
+
primaryColor: "transparent",
|
|
159
|
+
size: "small",
|
|
160
|
+
secondaryColor: "inherit"
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
};
|
|
130
164
|
export function MultiValueRemove({
|
|
131
|
-
|
|
165
|
+
isDisabled,
|
|
132
166
|
innerProps
|
|
133
167
|
}) {
|
|
134
168
|
return jsx("div", _extends({
|
|
135
169
|
role: "button"
|
|
136
|
-
}, innerProps),
|
|
137
|
-
|
|
138
|
-
|
|
170
|
+
}, innerProps), jsx("div", {
|
|
171
|
+
css: isDisabled ? disabledStyles : enabledStyles,
|
|
172
|
+
"data-testid": isDisabled ? 'hide-clear-icon' : 'show-clear-icon'
|
|
173
|
+
}, renderIcon()));
|
|
139
174
|
}
|
|
140
175
|
const MultiValue = props => {
|
|
141
176
|
const {
|
|
@@ -179,6 +214,7 @@ const MultiValue = props => {
|
|
|
179
214
|
'aria-label': `Remove ${children || 'option'}`,
|
|
180
215
|
...removeProps
|
|
181
216
|
},
|
|
217
|
+
isDisabled: isDisabled,
|
|
182
218
|
selectProps: selectProps
|
|
183
219
|
}));
|
|
184
220
|
};
|
|
@@ -7,10 +7,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
7
7
|
import { jsx } from '@emotion/react';
|
|
8
8
|
import { getStyleProps } from '../utils';
|
|
9
9
|
export const css = ({
|
|
10
|
-
isDisabled
|
|
11
|
-
theme: {
|
|
12
|
-
spacing
|
|
13
|
-
}
|
|
10
|
+
isDisabled
|
|
14
11
|
}) => ({
|
|
15
12
|
label: 'singleValue',
|
|
16
13
|
gridArea: '1 / 1 / 2 / 3',
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import useStateManager from './use-state-manager';
|
|
2
2
|
export { default } from './state-manager';
|
|
3
3
|
export { mergeStyles } from './styles';
|
|
4
|
-
export { defaultTheme } from './theme';
|
|
5
4
|
export { createFilter } from './filters';
|
|
6
5
|
export { components } from './components';
|
|
7
6
|
export { useStateManager };
|
package/dist/es2019/select.js
CHANGED
|
@@ -11,10 +11,10 @@ import LiveRegion from './components/live-region';
|
|
|
11
11
|
import { MenuPlacer } from './components/menu';
|
|
12
12
|
import { createFilter } from './filters';
|
|
13
13
|
import { defaultStyles } from './styles';
|
|
14
|
-
import { defaultTheme } from './theme';
|
|
15
14
|
import { classNames, cleanValue, isDocumentElement, isMobileDevice, isTouchCapable, multiValueAsValue, noop, notNullish, scrollIntoView, singleValueAsValue, valueTernary } from './utils';
|
|
16
15
|
export const defaultProps = {
|
|
17
16
|
// aria-live is by default with the live region so we don't need it
|
|
17
|
+
// eslint-disable-next-line @atlaskit/platform/no-module-level-eval
|
|
18
18
|
'aria-live': fg('design_system_select-a11y-improvement') ? undefined : 'polite',
|
|
19
19
|
backspaceRemovesValue: true,
|
|
20
20
|
blurInputOnSelect: isTouchCapable(),
|
|
@@ -356,6 +356,9 @@ export default class Select extends Component {
|
|
|
356
356
|
removedValue: lastSelectedValue
|
|
357
357
|
});
|
|
358
358
|
});
|
|
359
|
+
// ==============================
|
|
360
|
+
// Getters
|
|
361
|
+
// ==============================
|
|
359
362
|
_defineProperty(this, "getFocusedOptionId", focusedOption => {
|
|
360
363
|
return getFocusedOptionId(this.state.focusableOptionsWithIds, focusedOption);
|
|
361
364
|
});
|
|
@@ -1074,28 +1077,6 @@ export default class Select extends Component {
|
|
|
1074
1077
|
focusedOptionId: this.getFocusedOptionId(options[nextFocus])
|
|
1075
1078
|
});
|
|
1076
1079
|
}
|
|
1077
|
-
// ==============================
|
|
1078
|
-
// Getters
|
|
1079
|
-
// ==============================
|
|
1080
|
-
|
|
1081
|
-
getTheme() {
|
|
1082
|
-
// Use the default theme if there are no customisations.
|
|
1083
|
-
if (!this.props.theme) {
|
|
1084
|
-
return defaultTheme;
|
|
1085
|
-
}
|
|
1086
|
-
// If the theme prop is a function, assume the function
|
|
1087
|
-
// knows how to merge the passed-in default theme with
|
|
1088
|
-
// its own modifications.
|
|
1089
|
-
if (typeof this.props.theme === 'function') {
|
|
1090
|
-
return this.props.theme(defaultTheme);
|
|
1091
|
-
}
|
|
1092
|
-
// Otherwise, if a plain theme object was passed in,
|
|
1093
|
-
// overlay it with the default theme.
|
|
1094
|
-
return {
|
|
1095
|
-
...defaultTheme,
|
|
1096
|
-
...this.props.theme
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
1080
|
getCommonProps() {
|
|
1100
1081
|
const {
|
|
1101
1082
|
clearValue,
|
|
@@ -1125,8 +1106,7 @@ export default class Select extends Component {
|
|
|
1125
1106
|
options,
|
|
1126
1107
|
selectOption,
|
|
1127
1108
|
selectProps: props,
|
|
1128
|
-
setValue
|
|
1129
|
-
theme: this.getTheme()
|
|
1109
|
+
setValue
|
|
1130
1110
|
};
|
|
1131
1111
|
}
|
|
1132
1112
|
hasValue() {
|
|
@@ -1425,8 +1405,7 @@ export default class Select extends Component {
|
|
|
1425
1405
|
}
|
|
1426
1406
|
const innerProps = {
|
|
1427
1407
|
onMouseDown: this.onClearIndicatorMouseDown,
|
|
1428
|
-
onTouchEnd: this.onClearIndicatorTouchEnd
|
|
1429
|
-
'aria-hidden': 'true'
|
|
1408
|
+
onTouchEnd: this.onClearIndicatorTouchEnd
|
|
1430
1409
|
};
|
|
1431
1410
|
const isCompact = spacing === 'compact';
|
|
1432
1411
|
return /*#__PURE__*/React.createElement(ClearIndicator, _extends({
|
|
@@ -1466,30 +1445,6 @@ export default class Select extends Component {
|
|
|
1466
1445
|
isCompact: isCompact
|
|
1467
1446
|
}));
|
|
1468
1447
|
}
|
|
1469
|
-
renderIndicatorSeparator() {
|
|
1470
|
-
const {
|
|
1471
|
-
DropdownIndicator,
|
|
1472
|
-
IndicatorSeparator
|
|
1473
|
-
} = this.getComponents();
|
|
1474
|
-
|
|
1475
|
-
// separator doesn't make sense without the dropdown indicator
|
|
1476
|
-
if (!DropdownIndicator || !IndicatorSeparator) {
|
|
1477
|
-
return null;
|
|
1478
|
-
}
|
|
1479
|
-
const {
|
|
1480
|
-
commonProps
|
|
1481
|
-
} = this;
|
|
1482
|
-
const {
|
|
1483
|
-
isDisabled
|
|
1484
|
-
} = this.props;
|
|
1485
|
-
const {
|
|
1486
|
-
isFocused
|
|
1487
|
-
} = this.state;
|
|
1488
|
-
return /*#__PURE__*/React.createElement(IndicatorSeparator, _extends({}, commonProps, {
|
|
1489
|
-
isDisabled: isDisabled,
|
|
1490
|
-
isFocused: isFocused
|
|
1491
|
-
}));
|
|
1492
|
-
}
|
|
1493
1448
|
renderDropdownIndicator() {
|
|
1494
1449
|
const {
|
|
1495
1450
|
DropdownIndicator
|
|
@@ -1829,7 +1784,7 @@ export default class Select extends Component {
|
|
|
1829
1784
|
isCompact: isCompact
|
|
1830
1785
|
}), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/React.createElement(IndicatorsContainer, _extends({}, commonProps, {
|
|
1831
1786
|
isDisabled: isDisabled
|
|
1832
|
-
}), this.renderClearIndicator(), this.renderLoadingIndicator(), this.
|
|
1787
|
+
}), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
|
|
1833
1788
|
}
|
|
1834
1789
|
}
|
|
1835
1790
|
_defineProperty(Select, "defaultProps", defaultProps);
|
package/dist/es2019/styles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { containerCSS, indicatorsContainerCSS, valueContainerCSS } from './components/containers';
|
|
2
2
|
import { css as controlCSS } from './components/control';
|
|
3
3
|
import { groupCSS, groupHeadingCSS } from './components/group';
|
|
4
|
-
import { clearIndicatorCSS, dropdownIndicatorCSS,
|
|
4
|
+
import { clearIndicatorCSS, dropdownIndicatorCSS, loadingIndicatorCSS } from './components/indicators';
|
|
5
5
|
import { inputCSS } from './components/input';
|
|
6
6
|
import { loadingMessageCSS, menuCSS, menuListCSS, menuPortalCSS, noOptionsMessageCSS } from './components/menu';
|
|
7
7
|
import { multiValueCSS, multiValueLabelCSS, multiValueRemoveCSS } from './components/multi-value';
|
|
@@ -16,7 +16,6 @@ export const defaultStyles = {
|
|
|
16
16
|
group: groupCSS,
|
|
17
17
|
groupHeading: groupHeadingCSS,
|
|
18
18
|
indicatorsContainer: indicatorsContainerCSS,
|
|
19
|
-
indicatorSeparator: indicatorSeparatorCSS,
|
|
20
19
|
input: inputCSS,
|
|
21
20
|
loadingIndicator: loadingIndicatorCSS,
|
|
22
21
|
loadingMessage: loadingMessageCSS,
|
package/dist/es2019/utils.js
CHANGED
|
@@ -25,15 +25,11 @@ var Group = function Group(props) {
|
|
|
25
25
|
headingProps = props.headingProps,
|
|
26
26
|
innerProps = props.innerProps,
|
|
27
27
|
label = props.label,
|
|
28
|
-
theme = props.theme,
|
|
29
28
|
selectProps = props.selectProps;
|
|
30
29
|
return jsx("div", _extends({}, getStyleProps(props, 'group', {
|
|
31
30
|
group: true
|
|
32
31
|
}), innerProps), jsx(Heading, _extends({}, headingProps, {
|
|
33
|
-
selectProps: selectProps
|
|
34
|
-
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
35
|
-
,
|
|
36
|
-
theme: theme,
|
|
32
|
+
selectProps: selectProps,
|
|
37
33
|
getStyles: getStyles,
|
|
38
34
|
getClassNames: getClassNames,
|
|
39
35
|
cx: cx
|
|
@@ -45,13 +41,12 @@ export var groupHeadingCSS = function groupHeadingCSS(_ref2) {
|
|
|
45
41
|
label: 'group',
|
|
46
42
|
cursor: 'default',
|
|
47
43
|
display: 'block',
|
|
48
|
-
fontSize: '75%',
|
|
49
44
|
marginBottom: '0.25em',
|
|
50
45
|
paddingLeft: "var(--ds-space-150, 12px)",
|
|
51
46
|
paddingRight: "var(--ds-space-150, 12px)",
|
|
52
47
|
font: "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
53
48
|
color: "var(--ds-text-subtle, #44546F)",
|
|
54
|
-
fontWeight: "var(--ds-font-weight-bold, 700)"
|
|
49
|
+
fontWeight: "var(--ds-font-weight-bold, 700)",
|
|
55
50
|
textTransform: 'none'
|
|
56
51
|
};
|
|
57
52
|
};
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { IndicatorsContainer, SelectContainer, ValueContainer } from './containers';
|
|
5
5
|
import Control from './control';
|
|
6
6
|
import Group, { GroupHeading } from './group';
|
|
7
|
-
import { ClearIndicator,
|
|
7
|
+
import { ClearIndicator, DropdownIndicator, LoadingIndicator } from './indicators';
|
|
8
8
|
import Input from './input';
|
|
9
9
|
import Menu, { LoadingMessage, MenuList, MenuPortal, NoOptionsMessage } from './menu';
|
|
10
10
|
import MultiValue, { MultiValueContainer, MultiValueLabel, MultiValueRemove } from './multi-value';
|
|
@@ -15,12 +15,9 @@ export var components = {
|
|
|
15
15
|
ClearIndicator: ClearIndicator,
|
|
16
16
|
Control: Control,
|
|
17
17
|
DropdownIndicator: DropdownIndicator,
|
|
18
|
-
DownChevron: DownChevron,
|
|
19
|
-
CrossIcon: CrossIcon,
|
|
20
18
|
Group: Group,
|
|
21
19
|
GroupHeading: GroupHeading,
|
|
22
20
|
IndicatorsContainer: IndicatorsContainer,
|
|
23
|
-
IndicatorSeparator: IndicatorSeparator,
|
|
24
21
|
Input: Input,
|
|
25
22
|
LoadingIndicator: LoadingIndicator,
|
|
26
23
|
Menu: Menu,
|