@atlaskit/react-select 2.1.0 → 2.2.1
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/emotion/components/containers.js +111 -0
- package/dist/cjs/emotion/components/control.js +110 -0
- package/dist/cjs/emotion/components/group.js +71 -0
- package/dist/cjs/emotion/components/index.js +52 -0
- package/dist/cjs/emotion/components/indicators.js +137 -0
- package/dist/cjs/emotion/components/input.js +94 -0
- package/dist/cjs/emotion/components/internal/a11y-text.js +36 -0
- package/dist/cjs/emotion/components/internal/dummy-input.js +44 -0
- package/dist/cjs/emotion/components/internal/index.js +34 -0
- package/dist/cjs/emotion/components/internal/notify-open-layer-observer.js +21 -0
- package/dist/cjs/emotion/components/internal/required-input.js +43 -0
- package/dist/cjs/emotion/components/internal/scroll-manager.js +57 -0
- package/dist/cjs/emotion/components/internal/use-scroll-capture.js +132 -0
- package/dist/cjs/emotion/components/internal/use-scroll-lock.js +149 -0
- package/dist/cjs/emotion/components/live-region.js +182 -0
- package/dist/cjs/emotion/components/menu.js +456 -0
- package/dist/cjs/emotion/components/multi-value.js +224 -0
- package/dist/cjs/emotion/components/option.js +82 -0
- package/dist/cjs/emotion/components/placeholder.js +34 -0
- package/dist/cjs/emotion/components/single-value.js +40 -0
- package/dist/cjs/select.js +11 -8
- package/dist/es2019/emotion/components/containers.js +109 -0
- package/dist/es2019/emotion/components/control.js +107 -0
- package/dist/es2019/emotion/components/group.js +59 -0
- package/dist/es2019/emotion/components/index.js +41 -0
- package/dist/es2019/emotion/components/indicators.js +128 -0
- package/dist/es2019/emotion/components/input.js +86 -0
- package/dist/es2019/emotion/components/internal/a11y-text.js +27 -0
- package/dist/es2019/emotion/components/internal/dummy-input.js +37 -0
- package/dist/es2019/emotion/components/internal/index.js +4 -0
- package/dist/es2019/emotion/components/internal/notify-open-layer-observer.js +16 -0
- package/dist/es2019/emotion/components/internal/required-input.js +35 -0
- package/dist/es2019/emotion/components/internal/scroll-manager.js +49 -0
- package/dist/es2019/emotion/components/internal/use-scroll-capture.js +128 -0
- package/dist/es2019/emotion/components/internal/use-scroll-lock.js +143 -0
- package/dist/es2019/emotion/components/live-region.js +178 -0
- package/dist/es2019/emotion/components/menu.js +450 -0
- package/dist/es2019/emotion/components/multi-value.js +227 -0
- package/dist/es2019/emotion/components/option.js +78 -0
- package/dist/es2019/emotion/components/placeholder.js +28 -0
- package/dist/es2019/emotion/components/single-value.js +34 -0
- package/dist/es2019/select.js +11 -8
- package/dist/esm/emotion/components/containers.js +105 -0
- package/dist/esm/emotion/components/control.js +103 -0
- package/dist/esm/emotion/components/group.js +65 -0
- package/dist/esm/emotion/components/index.js +43 -0
- package/dist/esm/emotion/components/indicators.js +132 -0
- package/dist/esm/emotion/components/input.js +89 -0
- package/dist/esm/emotion/components/internal/a11y-text.js +29 -0
- package/dist/esm/emotion/components/internal/dummy-input.js +38 -0
- package/dist/esm/emotion/components/internal/index.js +4 -0
- package/dist/esm/emotion/components/internal/notify-open-layer-observer.js +15 -0
- package/dist/esm/emotion/components/internal/required-input.js +36 -0
- package/dist/esm/emotion/components/internal/scroll-manager.js +49 -0
- package/dist/esm/emotion/components/internal/use-scroll-capture.js +126 -0
- package/dist/esm/emotion/components/internal/use-scroll-lock.js +143 -0
- package/dist/esm/emotion/components/live-region.js +175 -0
- package/dist/esm/emotion/components/menu.js +454 -0
- package/dist/esm/emotion/components/multi-value.js +217 -0
- package/dist/esm/emotion/components/option.js +75 -0
- package/dist/esm/emotion/components/placeholder.js +27 -0
- package/dist/esm/emotion/components/single-value.js +33 -0
- package/dist/esm/select.js +11 -8
- package/dist/types/components/internal/notify-open-layer-observer.d.ts +4 -2
- package/dist/types/emotion/components/containers.d.ts +54 -0
- package/dist/types/emotion/components/control.d.ts +42 -0
- package/dist/types/emotion/components/group.d.ts +52 -0
- package/dist/types/emotion/components/index.d.ts +67 -0
- package/dist/types/emotion/components/indicators.d.ts +73 -0
- package/dist/types/emotion/components/input.d.ts +37 -0
- package/dist/types/emotion/components/internal/a11y-text.d.ts +8 -0
- package/dist/types/emotion/components/internal/dummy-input.d.ts +9 -0
- package/dist/types/emotion/components/internal/index.d.ts +4 -0
- package/dist/types/emotion/components/internal/notify-open-layer-observer.d.ts +11 -0
- package/dist/types/emotion/components/internal/required-input.d.ts +10 -0
- package/dist/types/emotion/components/internal/scroll-manager.d.ts +17 -0
- package/dist/types/emotion/components/internal/use-scroll-capture.d.ts +12 -0
- package/dist/types/emotion/components/internal/use-scroll-lock.d.ts +9 -0
- package/dist/types/emotion/components/live-region.d.ts +25 -0
- package/dist/types/emotion/components/menu.d.ts +116 -0
- package/dist/types/emotion/components/multi-value.d.ts +47 -0
- package/dist/types/emotion/components/option.d.ts +49 -0
- package/dist/types/emotion/components/placeholder.d.ts +22 -0
- package/dist/types/emotion/components/single-value.d.ts +28 -0
- package/dist/types/select.d.ts +7 -4
- package/dist/types-ts4.5/components/internal/notify-open-layer-observer.d.ts +4 -2
- package/dist/types-ts4.5/emotion/components/containers.d.ts +54 -0
- package/dist/types-ts4.5/emotion/components/control.d.ts +42 -0
- package/dist/types-ts4.5/emotion/components/group.d.ts +52 -0
- package/dist/types-ts4.5/emotion/components/index.d.ts +67 -0
- package/dist/types-ts4.5/emotion/components/indicators.d.ts +73 -0
- package/dist/types-ts4.5/emotion/components/input.d.ts +37 -0
- package/dist/types-ts4.5/emotion/components/internal/a11y-text.d.ts +8 -0
- package/dist/types-ts4.5/emotion/components/internal/dummy-input.d.ts +9 -0
- package/dist/types-ts4.5/emotion/components/internal/index.d.ts +4 -0
- package/dist/types-ts4.5/emotion/components/internal/notify-open-layer-observer.d.ts +11 -0
- package/dist/types-ts4.5/emotion/components/internal/required-input.d.ts +10 -0
- package/dist/types-ts4.5/emotion/components/internal/scroll-manager.d.ts +17 -0
- package/dist/types-ts4.5/emotion/components/internal/use-scroll-capture.d.ts +12 -0
- package/dist/types-ts4.5/emotion/components/internal/use-scroll-lock.d.ts +9 -0
- package/dist/types-ts4.5/emotion/components/live-region.d.ts +25 -0
- package/dist/types-ts4.5/emotion/components/menu.d.ts +116 -0
- package/dist/types-ts4.5/emotion/components/multi-value.d.ts +47 -0
- package/dist/types-ts4.5/emotion/components/option.d.ts +49 -0
- package/dist/types-ts4.5/emotion/components/placeholder.d.ts +22 -0
- package/dist/types-ts4.5/emotion/components/single-value.d.ts +28 -0
- package/dist/types-ts4.5/select.d.ts +7 -4
- package/package.json +3 -3
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import LegacySelectClearIcon from '@atlaskit/icon/glyph/select-clear';
|
|
8
|
+
import CrossIcon from '@atlaskit/icon/utility/cross';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
+
import { Inline, xcss } from '@atlaskit/primitives';
|
|
11
|
+
import { getStyleProps } from '../../utils';
|
|
12
|
+
export const multiValueCSS = ({
|
|
13
|
+
isDisabled,
|
|
14
|
+
isFocused
|
|
15
|
+
}) => {
|
|
16
|
+
let backgroundColor;
|
|
17
|
+
let color;
|
|
18
|
+
if (isDisabled) {
|
|
19
|
+
// Use the basic neutral background so it is slightly separate from the
|
|
20
|
+
// field's background
|
|
21
|
+
backgroundColor = "var(--ds-background-neutral, #091E420F)";
|
|
22
|
+
color = "var(--ds-text-disabled, #091E424F)";
|
|
23
|
+
} else if (isFocused) {
|
|
24
|
+
backgroundColor = "var(--ds-background-selected, #E9F2FF)";
|
|
25
|
+
color = "var(--ds-text-selected, hsl(0, 0%, 20%))";
|
|
26
|
+
} else {
|
|
27
|
+
backgroundColor = fg('platform-component-visual-refresh') ? "var(--ds-background-neutral-subtle-hovered, #091E420F)" : "var(--ds-background-neutral, #091E420F)";
|
|
28
|
+
color = "var(--ds-text, hsl(0, 0%, 20%))";
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
label: 'multiValue',
|
|
32
|
+
display: 'flex',
|
|
33
|
+
minWidth: 0,
|
|
34
|
+
// resolves flex/text-overflow bug
|
|
35
|
+
margin: "var(--ds-space-025, 2px)",
|
|
36
|
+
borderRadius: "var(--ds-border-radius-050, 2px)",
|
|
37
|
+
backgroundColor,
|
|
38
|
+
boxShadow: isFocused ? `0 0 0 2px ${"var(--ds-surface, transparent)"}, 0 0 0 4px ${"var(--ds-border-focused, transparent)"}` : 'none',
|
|
39
|
+
maxWidth: '100%',
|
|
40
|
+
'@media screen and (-ms-high-contrast: active)': {
|
|
41
|
+
border: isFocused ? '1px solid transparent' : 'none'
|
|
42
|
+
},
|
|
43
|
+
color,
|
|
44
|
+
...(fg('platform-component-visual-refresh') && {
|
|
45
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
46
|
+
// Hardcode this color for visual refresh as there is no token color yet
|
|
47
|
+
borderColor: '#B7B9BE',
|
|
48
|
+
borderWidth: "var(--ds-border-width, 1px)",
|
|
49
|
+
borderStyle: 'solid',
|
|
50
|
+
backgroundColor: "var(--ds-background-input, #FFFFFF)"
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export const multiValueLabelCSS = ({
|
|
55
|
+
cropWithEllipsis,
|
|
56
|
+
isDisabled
|
|
57
|
+
}) => ({
|
|
58
|
+
overflow: 'hidden',
|
|
59
|
+
textOverflow: cropWithEllipsis || cropWithEllipsis === undefined ? 'ellipsis' : undefined,
|
|
60
|
+
whiteSpace: 'nowrap',
|
|
61
|
+
borderRadius: "var(--ds-border-radius-050, 2px)",
|
|
62
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
63
|
+
fontSize: '85%',
|
|
64
|
+
font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
65
|
+
padding: "var(--ds-space-025, 2px)",
|
|
66
|
+
color: isDisabled ? "var(--ds-text-disabled, #091E424F)" : 'inherit',
|
|
67
|
+
paddingLeft: "var(--ds-space-075, 6px)",
|
|
68
|
+
...(fg('platform-component-visual-refresh') && {
|
|
69
|
+
font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
70
|
+
paddingTop: 0,
|
|
71
|
+
paddingBottom: 0,
|
|
72
|
+
paddingLeft: "var(--ds-space-050, 4px)"
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
export const multiValueRemoveCSS = ({
|
|
76
|
+
isFocused
|
|
77
|
+
}) => ({
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
display: 'flex',
|
|
80
|
+
backgroundColor: isFocused ? "var(--ds-UNSAFE-transparent, transparent)" : undefined,
|
|
81
|
+
fill: isFocused ? "var(--ds-text-selected, #000)" : "var(--ds-text, #000)",
|
|
82
|
+
paddingLeft: "var(--ds-space-025, 2px)",
|
|
83
|
+
paddingRight: "var(--ds-space-025, 2px)",
|
|
84
|
+
borderRadius: '0px 2px 2px 0px',
|
|
85
|
+
// DSP-6470 we should style like Tag once we have the :has selector
|
|
86
|
+
':hover': {
|
|
87
|
+
backgroundColor: "var(--ds-background-danger-hovered, #FFD5D2)",
|
|
88
|
+
fill: "var(--ds-text-danger, #000)"
|
|
89
|
+
},
|
|
90
|
+
':active': {
|
|
91
|
+
backgroundColor: "var(--ds-background-danger-pressed, #FD9891)",
|
|
92
|
+
fill: "var(--ds-text-danger, #000)"
|
|
93
|
+
},
|
|
94
|
+
...(fg('platform-component-visual-refresh') && {
|
|
95
|
+
backgroundColor: "var(--ds-background-neutral-subtle, #00000000)",
|
|
96
|
+
border: 'none',
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
justifyContent: 'center',
|
|
99
|
+
alignSelf: 'center',
|
|
100
|
+
appearance: 'none',
|
|
101
|
+
borderRadius: "var(--ds-border-radius, 4px)",
|
|
102
|
+
color: "var(--ds-text, #172B4D)",
|
|
103
|
+
padding: "var(--ds-space-025, 2px)",
|
|
104
|
+
marginRight: "var(--ds-space-025, 2px)",
|
|
105
|
+
':focus-visible': {
|
|
106
|
+
outlineOffset: "var(--ds-space-negative-025, -2px)"
|
|
107
|
+
},
|
|
108
|
+
':hover': {
|
|
109
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
110
|
+
},
|
|
111
|
+
':active': {
|
|
112
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
117
|
+
const MultiValueGeneric = ({
|
|
118
|
+
children,
|
|
119
|
+
innerProps
|
|
120
|
+
}) => jsx("div", innerProps, children);
|
|
121
|
+
|
|
122
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
123
|
+
export const MultiValueContainer = MultiValueGeneric;
|
|
124
|
+
|
|
125
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
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: "",
|
|
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: "",
|
|
151
|
+
color: "currentColor"
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
return (
|
|
155
|
+
// eslint-disable-next-line @atlaskit/design-system/no-legacy-icons
|
|
156
|
+
jsx(LegacySelectClearIcon, {
|
|
157
|
+
label: "",
|
|
158
|
+
primaryColor: "transparent",
|
|
159
|
+
size: "small",
|
|
160
|
+
secondaryColor: "inherit"
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
export function MultiValueRemove({
|
|
165
|
+
isDisabled,
|
|
166
|
+
innerProps
|
|
167
|
+
}) {
|
|
168
|
+
return (
|
|
169
|
+
// The Remove button is intentionally excluded from the tab order, please avoid assigning a non-negative tabIndex to it. Context: https://hello.atlassian.net/wiki/spaces/A11YKB/pages/3031993460/Clear+Options+on+an+Input+Field
|
|
170
|
+
jsx("div", innerProps, jsx("div", {
|
|
171
|
+
css: isDisabled ? disabledStyles : enabledStyles,
|
|
172
|
+
"data-testid": isDisabled ? 'hide-clear-icon' : 'show-clear-icon'
|
|
173
|
+
}, renderIcon()))
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
const MultiValue = props => {
|
|
177
|
+
const {
|
|
178
|
+
children,
|
|
179
|
+
components,
|
|
180
|
+
data,
|
|
181
|
+
innerProps,
|
|
182
|
+
isDisabled,
|
|
183
|
+
removeProps,
|
|
184
|
+
selectProps
|
|
185
|
+
} = props;
|
|
186
|
+
const {
|
|
187
|
+
Container,
|
|
188
|
+
Label,
|
|
189
|
+
Remove
|
|
190
|
+
} = components;
|
|
191
|
+
const ariaLabel = typeof children === 'string' ? children : data.label;
|
|
192
|
+
return jsx(Container, {
|
|
193
|
+
data: data,
|
|
194
|
+
innerProps: {
|
|
195
|
+
...getStyleProps(props, 'multiValue', {
|
|
196
|
+
'multi-value': true,
|
|
197
|
+
'multi-value--is-disabled': isDisabled
|
|
198
|
+
}),
|
|
199
|
+
...innerProps
|
|
200
|
+
},
|
|
201
|
+
selectProps: selectProps
|
|
202
|
+
}, jsx(Label, {
|
|
203
|
+
data: data,
|
|
204
|
+
innerProps: {
|
|
205
|
+
...getStyleProps(props, 'multiValueLabel', {
|
|
206
|
+
'multi-value__label': true
|
|
207
|
+
})
|
|
208
|
+
},
|
|
209
|
+
selectProps: selectProps
|
|
210
|
+
}, children), jsx(Remove, {
|
|
211
|
+
data: data,
|
|
212
|
+
innerProps: {
|
|
213
|
+
...getStyleProps(props, 'multiValueRemove', {
|
|
214
|
+
'multi-value__remove': true
|
|
215
|
+
}),
|
|
216
|
+
role: 'button',
|
|
217
|
+
tabIndex: -1,
|
|
218
|
+
'aria-label': `${ariaLabel || 'option'}, remove`,
|
|
219
|
+
...removeProps
|
|
220
|
+
},
|
|
221
|
+
isDisabled: isDisabled,
|
|
222
|
+
selectProps: selectProps
|
|
223
|
+
}));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
227
|
+
export default MultiValue;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jsx } from '@emotion/react';
|
|
8
|
+
import { getStyleProps } from '../../utils';
|
|
9
|
+
export const optionCSS = ({
|
|
10
|
+
isDisabled,
|
|
11
|
+
isFocused,
|
|
12
|
+
isSelected
|
|
13
|
+
}) => {
|
|
14
|
+
let color = "var(--ds-text, #172B4D)";
|
|
15
|
+
if (isDisabled) {
|
|
16
|
+
color = "var(--ds-text-disabled, #091E424F)";
|
|
17
|
+
} else if (isSelected) {
|
|
18
|
+
color = "var(--ds-text-selected, #0C66E4)";
|
|
19
|
+
}
|
|
20
|
+
let boxShadow;
|
|
21
|
+
let backgroundColor;
|
|
22
|
+
if (isDisabled) {
|
|
23
|
+
backgroundColor = undefined;
|
|
24
|
+
} else if (isSelected && isFocused) {
|
|
25
|
+
backgroundColor = "var(--ds-background-selected-hovered, #CCE0FF)";
|
|
26
|
+
} else if (isSelected) {
|
|
27
|
+
backgroundColor = "var(--ds-background-selected, #E9F2FF)";
|
|
28
|
+
} else if (isFocused) {
|
|
29
|
+
backgroundColor = "var(--ds-background-neutral-subtle-hovered, #091E420F)";
|
|
30
|
+
}
|
|
31
|
+
if (!isDisabled && (isFocused || isSelected)) {
|
|
32
|
+
boxShadow = `inset 2px 0px 0px ${"var(--ds-border-selected, #0C66E4)"}`;
|
|
33
|
+
}
|
|
34
|
+
const cursor = isDisabled ? 'not-allowed' : 'default';
|
|
35
|
+
return {
|
|
36
|
+
label: 'option',
|
|
37
|
+
display: 'block',
|
|
38
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
39
|
+
fontSize: 'inherit',
|
|
40
|
+
width: '100%',
|
|
41
|
+
userSelect: 'none',
|
|
42
|
+
WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
|
|
43
|
+
padding: `${"var(--ds-space-075, 6px)"} ${"var(--ds-space-150, 12px)"}`,
|
|
44
|
+
backgroundColor,
|
|
45
|
+
color,
|
|
46
|
+
cursor,
|
|
47
|
+
boxShadow,
|
|
48
|
+
':active': {
|
|
49
|
+
backgroundColor: !isDisabled ? isSelected ? "var(--ds-background-selected-pressed, #85B8FF)" : "var(--ds-background-neutral-subtle-pressed, #091E4224)" : undefined
|
|
50
|
+
},
|
|
51
|
+
'@media screen and (-ms-high-contrast: active)': {
|
|
52
|
+
borderLeft: !isDisabled && (isFocused || isSelected) ? '2px solid transparent' : ''
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const Option = props => {
|
|
57
|
+
const {
|
|
58
|
+
children,
|
|
59
|
+
isDisabled,
|
|
60
|
+
isFocused,
|
|
61
|
+
isSelected,
|
|
62
|
+
innerRef,
|
|
63
|
+
innerProps
|
|
64
|
+
} = props;
|
|
65
|
+
return jsx("div", _extends({}, getStyleProps(props, 'option', {
|
|
66
|
+
option: true,
|
|
67
|
+
'option--is-disabled': isDisabled,
|
|
68
|
+
'option--is-focused': isFocused,
|
|
69
|
+
'option--is-selected': isSelected
|
|
70
|
+
}), {
|
|
71
|
+
ref: innerRef
|
|
72
|
+
}, innerProps, {
|
|
73
|
+
tabIndex: -1
|
|
74
|
+
}), children);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
78
|
+
export default Option;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jsx } from '@emotion/react';
|
|
8
|
+
import { getStyleProps } from '../../utils';
|
|
9
|
+
export const placeholderCSS = ({
|
|
10
|
+
isDisabled
|
|
11
|
+
}) => ({
|
|
12
|
+
label: 'placeholder',
|
|
13
|
+
gridArea: '1 / 1 / 2 / 3',
|
|
14
|
+
margin: `0 ${"var(--ds-space-025, 2px)"}`,
|
|
15
|
+
color: isDisabled ? "var(--ds-text-disabled, #091E424F)" : "var(--ds-text-subtlest, #626F86)"
|
|
16
|
+
});
|
|
17
|
+
const Placeholder = props => {
|
|
18
|
+
const {
|
|
19
|
+
children,
|
|
20
|
+
innerProps
|
|
21
|
+
} = props;
|
|
22
|
+
return jsx("div", _extends({}, getStyleProps(props, 'placeholder', {
|
|
23
|
+
placeholder: true
|
|
24
|
+
}), innerProps), children);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
28
|
+
export default Placeholder;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jsx } from '@emotion/react';
|
|
8
|
+
import { getStyleProps } from '../../utils';
|
|
9
|
+
export const css = ({
|
|
10
|
+
isDisabled
|
|
11
|
+
}) => ({
|
|
12
|
+
label: 'singleValue',
|
|
13
|
+
gridArea: '1 / 1 / 2 / 3',
|
|
14
|
+
maxWidth: '100%',
|
|
15
|
+
overflow: 'hidden',
|
|
16
|
+
textOverflow: 'ellipsis',
|
|
17
|
+
whiteSpace: 'nowrap',
|
|
18
|
+
margin: `0 ${"var(--ds-space-025, 2px)"}`,
|
|
19
|
+
color: isDisabled ? "var(--ds-text-disabled, #091E424F)" : "var(--ds-text, #172B4D)"
|
|
20
|
+
});
|
|
21
|
+
const SingleValue = props => {
|
|
22
|
+
const {
|
|
23
|
+
children,
|
|
24
|
+
isDisabled,
|
|
25
|
+
innerProps
|
|
26
|
+
} = props;
|
|
27
|
+
return jsx("div", _extends({}, getStyleProps(props, 'singleValue', {
|
|
28
|
+
'single-value': true,
|
|
29
|
+
'single-value--is-disabled': isDisabled
|
|
30
|
+
}), innerProps), children);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
34
|
+
export default SingleValue;
|
package/dist/es2019/select.js
CHANGED
|
@@ -55,7 +55,8 @@ export const defaultProps = {
|
|
|
55
55
|
}) => `${count} result${count !== 1 ? 's' : ''} available`,
|
|
56
56
|
styles: {},
|
|
57
57
|
tabIndex: 0,
|
|
58
|
-
tabSelectsValue: true
|
|
58
|
+
tabSelectsValue: true,
|
|
59
|
+
UNSAFE_is_experimental_generic: false
|
|
59
60
|
};
|
|
60
61
|
function toCategorizedOption(props, option, selectValue, index) {
|
|
61
62
|
const isDisabled = isOptionDisabled(props, option, selectValue);
|
|
@@ -1279,14 +1280,14 @@ export default class Select extends Component {
|
|
|
1279
1280
|
'aria-errormessage': this.props['aria-errormessage'],
|
|
1280
1281
|
'aria-expanded': menuIsOpen,
|
|
1281
1282
|
// TODO: aria-haspopup is implied as listbox with role="combobox" and was deprecated for aria 1.2, we still might need to keep it for back compat
|
|
1282
|
-
'aria-haspopup': 'listbox',
|
|
1283
|
+
'aria-haspopup': this.props['UNSAFE_is_experimental_generic'] ? 'dialog' : 'listbox',
|
|
1283
1284
|
'aria-describedby': this.props['aria-describedby'] || descriptionId,
|
|
1284
1285
|
'aria-invalid': this.props['aria-invalid'] || isInvalid,
|
|
1285
1286
|
'aria-label': this.props['aria-label'] || label,
|
|
1286
1287
|
'aria-labelledby': this.props['aria-labelledby'] || labelId,
|
|
1287
1288
|
'aria-required': required || isRequired,
|
|
1288
1289
|
role: 'combobox',
|
|
1289
|
-
'aria-activedescendant': this.state.focusedOptionId || this.state.focusedValueId || undefined,
|
|
1290
|
+
'aria-activedescendant': this.props['UNSAFE_is_experimental_generic'] ? undefined : this.state.focusedOptionId || this.state.focusedValueId || undefined,
|
|
1290
1291
|
...(menuIsOpen && {
|
|
1291
1292
|
'aria-controls': this.getElementId('listbox')
|
|
1292
1293
|
}),
|
|
@@ -1572,8 +1573,8 @@ export default class Select extends Component {
|
|
|
1572
1573
|
onClick: onSelect,
|
|
1573
1574
|
onMouseMove: onHover,
|
|
1574
1575
|
onMouseOver: onHover,
|
|
1575
|
-
role: 'option',
|
|
1576
|
-
'aria-selected': isSelected,
|
|
1576
|
+
role: this.props['UNSAFE_is_experimental_generic'] ? 'listitem' : 'option',
|
|
1577
|
+
'aria-selected': this.props['UNSAFE_is_experimental_generic'] ? undefined : isSelected,
|
|
1577
1578
|
// We don't want aria-disabled if it's false. It's just noisy.
|
|
1578
1579
|
'aria-disabled': !isDisabled && fg('design_system_select-a11y-improvement') ? undefined : isDisabled,
|
|
1579
1580
|
'aria-describedby': fg('design_system_select-a11y-improvement') ? headingId : undefined,
|
|
@@ -1703,8 +1704,8 @@ export default class Select extends Component {
|
|
|
1703
1704
|
scrollTargetRef(instance);
|
|
1704
1705
|
},
|
|
1705
1706
|
innerProps: {
|
|
1706
|
-
role: 'listbox',
|
|
1707
|
-
'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
|
|
1707
|
+
role: this.props['UNSAFE_is_experimental_generic'] ? 'dialog' : 'listbox',
|
|
1708
|
+
'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') || this.props['UNSAFE_is_experimental_generic'] ? undefined : commonProps.isMulti,
|
|
1708
1709
|
id: this.getElementId('listbox'),
|
|
1709
1710
|
...(testId && {
|
|
1710
1711
|
'data-testid': `${testId}-select--listbox`
|
|
@@ -1715,7 +1716,9 @@ export default class Select extends Component {
|
|
|
1715
1716
|
isLoading: isLoading,
|
|
1716
1717
|
maxHeight: maxHeight,
|
|
1717
1718
|
focusedOption: focusedOption
|
|
1718
|
-
}),
|
|
1719
|
+
}), this.props['UNSAFE_is_experimental_generic'] ? /*#__PURE__*/React.createElement("div", {
|
|
1720
|
+
role: "list"
|
|
1721
|
+
}, menuUI) : menuUI))));
|
|
1719
1722
|
|
|
1720
1723
|
// positioning behaviour is almost identical for portalled and fixed,
|
|
1721
1724
|
// so we use the same component. the actual portalling logic is forked
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
/**
|
|
4
|
+
* @jsxRuntime classic
|
|
5
|
+
* @jsx jsx
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { jsx } from '@emotion/react';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
+
import { media } from '@atlaskit/primitives';
|
|
11
|
+
import { getStyleProps } from '../../utils';
|
|
12
|
+
|
|
13
|
+
// ==============================
|
|
14
|
+
// Root Container
|
|
15
|
+
// ==============================
|
|
16
|
+
|
|
17
|
+
export var containerCSS = function containerCSS(_ref) {
|
|
18
|
+
var isDisabled = _ref.isDisabled,
|
|
19
|
+
isRtl = _ref.isRtl;
|
|
20
|
+
return _defineProperty({
|
|
21
|
+
label: 'container',
|
|
22
|
+
direction: isRtl ? 'rtl' : undefined,
|
|
23
|
+
position: 'relative',
|
|
24
|
+
font: fg('platform_design_system_team_safari_input_fix') ? "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)" : "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
25
|
+
pointerEvents: 'all',
|
|
26
|
+
cursor: isDisabled ? 'not-allowed' : undefined
|
|
27
|
+
}, "".concat(media.above.xs), {
|
|
28
|
+
font: fg('platform_design_system_team_safari_input_fix') ? "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)" : undefined
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
33
|
+
export var SelectContainer = function SelectContainer(props) {
|
|
34
|
+
var children = props.children,
|
|
35
|
+
innerProps = props.innerProps,
|
|
36
|
+
isDisabled = props.isDisabled,
|
|
37
|
+
isRtl = props.isRtl;
|
|
38
|
+
return jsx("div", _extends({}, getStyleProps(props, 'container', {
|
|
39
|
+
'--is-disabled': isDisabled,
|
|
40
|
+
'--is-rtl': isRtl
|
|
41
|
+
}), innerProps), children);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// ==============================
|
|
45
|
+
// Value Container
|
|
46
|
+
// ==============================
|
|
47
|
+
|
|
48
|
+
export var valueContainerCSS = function valueContainerCSS(_ref3) {
|
|
49
|
+
var isMulti = _ref3.isMulti,
|
|
50
|
+
hasValue = _ref3.hasValue,
|
|
51
|
+
isCompact = _ref3.isCompact,
|
|
52
|
+
controlShouldRenderValue = _ref3.selectProps.controlShouldRenderValue;
|
|
53
|
+
return {
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
display: isMulti && hasValue && controlShouldRenderValue ? 'flex' : 'grid',
|
|
56
|
+
flex: 1,
|
|
57
|
+
flexWrap: 'wrap',
|
|
58
|
+
WebkitOverflowScrolling: 'touch',
|
|
59
|
+
position: 'relative',
|
|
60
|
+
overflow: 'hidden',
|
|
61
|
+
padding: "".concat(isCompact ? 0 : "var(--ds-space-025, 2px)", " ", "var(--ds-space-075, 6px)")
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
66
|
+
export var ValueContainer = function ValueContainer(props) {
|
|
67
|
+
var children = props.children,
|
|
68
|
+
innerProps = props.innerProps,
|
|
69
|
+
isMulti = props.isMulti,
|
|
70
|
+
hasValue = props.hasValue;
|
|
71
|
+
var styles = getStyleProps(props, 'valueContainer', {
|
|
72
|
+
'value-container': true,
|
|
73
|
+
'value-container--is-multi': isMulti,
|
|
74
|
+
'value-container--has-value': hasValue
|
|
75
|
+
});
|
|
76
|
+
return jsx("div", _extends({
|
|
77
|
+
css: styles.css
|
|
78
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
79
|
+
,
|
|
80
|
+
className: styles.className || 'value-container'
|
|
81
|
+
}, innerProps), children);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// ==============================
|
|
85
|
+
// Indicator Container
|
|
86
|
+
// ==============================
|
|
87
|
+
|
|
88
|
+
export var indicatorsContainerCSS = function indicatorsContainerCSS() {
|
|
89
|
+
return {
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
alignSelf: 'stretch',
|
|
92
|
+
display: 'flex',
|
|
93
|
+
flexShrink: 0,
|
|
94
|
+
paddingRight: "var(--ds-space-050, 4px)"
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
99
|
+
export var IndicatorsContainer = function IndicatorsContainer(props) {
|
|
100
|
+
var children = props.children,
|
|
101
|
+
innerProps = props.innerProps;
|
|
102
|
+
return jsx("div", _extends({}, getStyleProps(props, 'indicatorsContainer', {
|
|
103
|
+
indicators: true
|
|
104
|
+
}), innerProps), children);
|
|
105
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jsx } from '@emotion/react';
|
|
8
|
+
import { getStyleProps } from '../../utils';
|
|
9
|
+
export var css = function css(_ref) {
|
|
10
|
+
var isDisabled = _ref.isDisabled,
|
|
11
|
+
isFocused = _ref.isFocused,
|
|
12
|
+
isInvalid = _ref.isInvalid,
|
|
13
|
+
isCompact = _ref.isCompact,
|
|
14
|
+
appearance = _ref.appearance;
|
|
15
|
+
var borderColor = isFocused ? "var(--ds-border-focused, #388BFF)" : "var(--ds-border-input, #8590A2)";
|
|
16
|
+
var backgroundColor = isFocused ? "var(--ds-background-input-pressed, #FFFFFF)" : "var(--ds-background-input, #FFFFFF)";
|
|
17
|
+
var backgroundColorHover = isFocused ? "var(--ds-background-input-pressed, #FFFFFF)" : "var(--ds-background-input-hovered, #F7F8F9)";
|
|
18
|
+
var borderColorHover = isFocused ? "var(--ds-border-focused, #388BFF)" : "var(--ds-border-input, #8590A2)";
|
|
19
|
+
if (isDisabled) {
|
|
20
|
+
backgroundColor = "var(--ds-background-disabled, #091E4208)";
|
|
21
|
+
borderColor = "var(--ds-background-disabled, #091E4208)";
|
|
22
|
+
}
|
|
23
|
+
if (isInvalid) {
|
|
24
|
+
borderColor = "var(--ds-border-danger, #E2483D)";
|
|
25
|
+
borderColorHover = "var(--ds-border-danger, #E2483D)";
|
|
26
|
+
}
|
|
27
|
+
var transitionDuration = '200ms';
|
|
28
|
+
if (appearance === 'subtle') {
|
|
29
|
+
borderColor = isFocused ? "var(--ds-border-focused, #388BFF)" : 'transparent';
|
|
30
|
+
backgroundColor = isFocused ? "var(--ds-surface, #FFFFFF)" : 'transparent';
|
|
31
|
+
backgroundColorHover = isFocused ? "var(--ds-background-input-pressed, #FFFFFF)" : "var(--ds-background-input-hovered, #F7F8F9)";
|
|
32
|
+
}
|
|
33
|
+
if (appearance === 'none') {
|
|
34
|
+
borderColor = 'transparent';
|
|
35
|
+
backgroundColor = 'transparent';
|
|
36
|
+
backgroundColorHover = 'transparent';
|
|
37
|
+
borderColorHover = 'transparent';
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
label: 'control',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
cursor: 'default',
|
|
43
|
+
display: 'flex',
|
|
44
|
+
flexWrap: 'wrap',
|
|
45
|
+
justifyContent: 'space-between',
|
|
46
|
+
outline: '0 !important',
|
|
47
|
+
position: 'relative',
|
|
48
|
+
// Turn pointer events off when disabled - this makes it so hover etc don't work.
|
|
49
|
+
pointerEvents: isDisabled ? 'none' : undefined,
|
|
50
|
+
backgroundColor: backgroundColor,
|
|
51
|
+
borderColor: borderColor,
|
|
52
|
+
borderStyle: 'solid',
|
|
53
|
+
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
54
|
+
borderWidth: "var(--ds-border-width, 1px)",
|
|
55
|
+
boxShadow: isInvalid ? "inset 0 0 0 ".concat("var(--ds-border-width, 1px)", " ", borderColor) : 'none',
|
|
56
|
+
'&:focus-within': {
|
|
57
|
+
boxShadow: "inset 0 0 0 ".concat("var(--ds-border-width, 1px)", " ", borderColor)
|
|
58
|
+
},
|
|
59
|
+
minHeight: isCompact ? 32 : 40,
|
|
60
|
+
padding: 0,
|
|
61
|
+
transition: "background-color ".concat(transitionDuration, " ease-in-out,\nborder-color ").concat(transitionDuration, " ease-in-out"),
|
|
62
|
+
'::-webkit-scrollbar': {
|
|
63
|
+
height: 8,
|
|
64
|
+
width: 8
|
|
65
|
+
},
|
|
66
|
+
'::-webkit-scrollbar-corner': {
|
|
67
|
+
display: 'none'
|
|
68
|
+
},
|
|
69
|
+
':hover': {
|
|
70
|
+
'::-webkit-scrollbar-thumb': {
|
|
71
|
+
// scrollbars occur only if the user passes in a custom component with overflow: scroll
|
|
72
|
+
backgroundColor: 'rgba(0,0,0,0.2)'
|
|
73
|
+
},
|
|
74
|
+
cursor: 'pointer',
|
|
75
|
+
backgroundColor: backgroundColorHover,
|
|
76
|
+
borderColor: borderColorHover
|
|
77
|
+
},
|
|
78
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
79
|
+
backgroundColor: 'rgba(0,0,0,0.4)'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
var Control = function Control(props) {
|
|
84
|
+
var children = props.children,
|
|
85
|
+
isDisabled = props.isDisabled,
|
|
86
|
+
isFocused = props.isFocused,
|
|
87
|
+
innerRef = props.innerRef,
|
|
88
|
+
innerProps = props.innerProps,
|
|
89
|
+
menuIsOpen = props.menuIsOpen;
|
|
90
|
+
return jsx("div", _extends({
|
|
91
|
+
ref: innerRef
|
|
92
|
+
}, getStyleProps(props, 'control', {
|
|
93
|
+
control: true,
|
|
94
|
+
'control--is-disabled': isDisabled,
|
|
95
|
+
'control--is-focused': isFocused,
|
|
96
|
+
'control--menu-is-open': menuIsOpen
|
|
97
|
+
}), innerProps, {
|
|
98
|
+
"aria-disabled": isDisabled || undefined
|
|
99
|
+
}), children);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
103
|
+
export default Control;
|