@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.
Files changed (109) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/emotion/components/containers.js +111 -0
  3. package/dist/cjs/emotion/components/control.js +110 -0
  4. package/dist/cjs/emotion/components/group.js +71 -0
  5. package/dist/cjs/emotion/components/index.js +52 -0
  6. package/dist/cjs/emotion/components/indicators.js +137 -0
  7. package/dist/cjs/emotion/components/input.js +94 -0
  8. package/dist/cjs/emotion/components/internal/a11y-text.js +36 -0
  9. package/dist/cjs/emotion/components/internal/dummy-input.js +44 -0
  10. package/dist/cjs/emotion/components/internal/index.js +34 -0
  11. package/dist/cjs/emotion/components/internal/notify-open-layer-observer.js +21 -0
  12. package/dist/cjs/emotion/components/internal/required-input.js +43 -0
  13. package/dist/cjs/emotion/components/internal/scroll-manager.js +57 -0
  14. package/dist/cjs/emotion/components/internal/use-scroll-capture.js +132 -0
  15. package/dist/cjs/emotion/components/internal/use-scroll-lock.js +149 -0
  16. package/dist/cjs/emotion/components/live-region.js +182 -0
  17. package/dist/cjs/emotion/components/menu.js +456 -0
  18. package/dist/cjs/emotion/components/multi-value.js +224 -0
  19. package/dist/cjs/emotion/components/option.js +82 -0
  20. package/dist/cjs/emotion/components/placeholder.js +34 -0
  21. package/dist/cjs/emotion/components/single-value.js +40 -0
  22. package/dist/cjs/select.js +11 -8
  23. package/dist/es2019/emotion/components/containers.js +109 -0
  24. package/dist/es2019/emotion/components/control.js +107 -0
  25. package/dist/es2019/emotion/components/group.js +59 -0
  26. package/dist/es2019/emotion/components/index.js +41 -0
  27. package/dist/es2019/emotion/components/indicators.js +128 -0
  28. package/dist/es2019/emotion/components/input.js +86 -0
  29. package/dist/es2019/emotion/components/internal/a11y-text.js +27 -0
  30. package/dist/es2019/emotion/components/internal/dummy-input.js +37 -0
  31. package/dist/es2019/emotion/components/internal/index.js +4 -0
  32. package/dist/es2019/emotion/components/internal/notify-open-layer-observer.js +16 -0
  33. package/dist/es2019/emotion/components/internal/required-input.js +35 -0
  34. package/dist/es2019/emotion/components/internal/scroll-manager.js +49 -0
  35. package/dist/es2019/emotion/components/internal/use-scroll-capture.js +128 -0
  36. package/dist/es2019/emotion/components/internal/use-scroll-lock.js +143 -0
  37. package/dist/es2019/emotion/components/live-region.js +178 -0
  38. package/dist/es2019/emotion/components/menu.js +450 -0
  39. package/dist/es2019/emotion/components/multi-value.js +227 -0
  40. package/dist/es2019/emotion/components/option.js +78 -0
  41. package/dist/es2019/emotion/components/placeholder.js +28 -0
  42. package/dist/es2019/emotion/components/single-value.js +34 -0
  43. package/dist/es2019/select.js +11 -8
  44. package/dist/esm/emotion/components/containers.js +105 -0
  45. package/dist/esm/emotion/components/control.js +103 -0
  46. package/dist/esm/emotion/components/group.js +65 -0
  47. package/dist/esm/emotion/components/index.js +43 -0
  48. package/dist/esm/emotion/components/indicators.js +132 -0
  49. package/dist/esm/emotion/components/input.js +89 -0
  50. package/dist/esm/emotion/components/internal/a11y-text.js +29 -0
  51. package/dist/esm/emotion/components/internal/dummy-input.js +38 -0
  52. package/dist/esm/emotion/components/internal/index.js +4 -0
  53. package/dist/esm/emotion/components/internal/notify-open-layer-observer.js +15 -0
  54. package/dist/esm/emotion/components/internal/required-input.js +36 -0
  55. package/dist/esm/emotion/components/internal/scroll-manager.js +49 -0
  56. package/dist/esm/emotion/components/internal/use-scroll-capture.js +126 -0
  57. package/dist/esm/emotion/components/internal/use-scroll-lock.js +143 -0
  58. package/dist/esm/emotion/components/live-region.js +175 -0
  59. package/dist/esm/emotion/components/menu.js +454 -0
  60. package/dist/esm/emotion/components/multi-value.js +217 -0
  61. package/dist/esm/emotion/components/option.js +75 -0
  62. package/dist/esm/emotion/components/placeholder.js +27 -0
  63. package/dist/esm/emotion/components/single-value.js +33 -0
  64. package/dist/esm/select.js +11 -8
  65. package/dist/types/components/internal/notify-open-layer-observer.d.ts +4 -2
  66. package/dist/types/emotion/components/containers.d.ts +54 -0
  67. package/dist/types/emotion/components/control.d.ts +42 -0
  68. package/dist/types/emotion/components/group.d.ts +52 -0
  69. package/dist/types/emotion/components/index.d.ts +67 -0
  70. package/dist/types/emotion/components/indicators.d.ts +73 -0
  71. package/dist/types/emotion/components/input.d.ts +37 -0
  72. package/dist/types/emotion/components/internal/a11y-text.d.ts +8 -0
  73. package/dist/types/emotion/components/internal/dummy-input.d.ts +9 -0
  74. package/dist/types/emotion/components/internal/index.d.ts +4 -0
  75. package/dist/types/emotion/components/internal/notify-open-layer-observer.d.ts +11 -0
  76. package/dist/types/emotion/components/internal/required-input.d.ts +10 -0
  77. package/dist/types/emotion/components/internal/scroll-manager.d.ts +17 -0
  78. package/dist/types/emotion/components/internal/use-scroll-capture.d.ts +12 -0
  79. package/dist/types/emotion/components/internal/use-scroll-lock.d.ts +9 -0
  80. package/dist/types/emotion/components/live-region.d.ts +25 -0
  81. package/dist/types/emotion/components/menu.d.ts +116 -0
  82. package/dist/types/emotion/components/multi-value.d.ts +47 -0
  83. package/dist/types/emotion/components/option.d.ts +49 -0
  84. package/dist/types/emotion/components/placeholder.d.ts +22 -0
  85. package/dist/types/emotion/components/single-value.d.ts +28 -0
  86. package/dist/types/select.d.ts +7 -4
  87. package/dist/types-ts4.5/components/internal/notify-open-layer-observer.d.ts +4 -2
  88. package/dist/types-ts4.5/emotion/components/containers.d.ts +54 -0
  89. package/dist/types-ts4.5/emotion/components/control.d.ts +42 -0
  90. package/dist/types-ts4.5/emotion/components/group.d.ts +52 -0
  91. package/dist/types-ts4.5/emotion/components/index.d.ts +67 -0
  92. package/dist/types-ts4.5/emotion/components/indicators.d.ts +73 -0
  93. package/dist/types-ts4.5/emotion/components/input.d.ts +37 -0
  94. package/dist/types-ts4.5/emotion/components/internal/a11y-text.d.ts +8 -0
  95. package/dist/types-ts4.5/emotion/components/internal/dummy-input.d.ts +9 -0
  96. package/dist/types-ts4.5/emotion/components/internal/index.d.ts +4 -0
  97. package/dist/types-ts4.5/emotion/components/internal/notify-open-layer-observer.d.ts +11 -0
  98. package/dist/types-ts4.5/emotion/components/internal/required-input.d.ts +10 -0
  99. package/dist/types-ts4.5/emotion/components/internal/scroll-manager.d.ts +17 -0
  100. package/dist/types-ts4.5/emotion/components/internal/use-scroll-capture.d.ts +12 -0
  101. package/dist/types-ts4.5/emotion/components/internal/use-scroll-lock.d.ts +9 -0
  102. package/dist/types-ts4.5/emotion/components/live-region.d.ts +25 -0
  103. package/dist/types-ts4.5/emotion/components/menu.d.ts +116 -0
  104. package/dist/types-ts4.5/emotion/components/multi-value.d.ts +47 -0
  105. package/dist/types-ts4.5/emotion/components/option.d.ts +49 -0
  106. package/dist/types-ts4.5/emotion/components/placeholder.d.ts +22 -0
  107. package/dist/types-ts4.5/emotion/components/single-value.d.ts +28 -0
  108. package/dist/types-ts4.5/select.d.ts +7 -4
  109. package/package.json +3 -3
@@ -0,0 +1,454 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
+ var _excluded = ["children", "innerProps"],
7
+ _excluded2 = ["children", "innerProps"];
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ /**
11
+ * @jsxRuntime classic
12
+ * @jsx jsx
13
+ */
14
+ import { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';
15
+ import { jsx } from '@emotion/react';
16
+ import { autoUpdate } from '@floating-ui/dom';
17
+ import { createPortal } from 'react-dom';
18
+ import useLayoutEffect from 'use-isomorphic-layout-effect';
19
+ import { fg } from '@atlaskit/platform-feature-flags';
20
+ import { Text } from '@atlaskit/primitives';
21
+ import { animatedScrollTo, getBoundingClientObj, getScrollParent, getScrollTop, getStyleProps, normalizedHeight, scrollTo } from '../../utils';
22
+
23
+ // ==============================
24
+ // Menu
25
+ // ==============================
26
+
27
+ // Get Menu Placement
28
+ // ------------------------------
29
+
30
+ function getMenuPlacement(_ref) {
31
+ var preferredMaxHeight = _ref.maxHeight,
32
+ menuEl = _ref.menuEl,
33
+ minHeight = _ref.minHeight,
34
+ preferredPlacement = _ref.placement,
35
+ shouldScroll = _ref.shouldScroll,
36
+ isFixedPosition = _ref.isFixedPosition,
37
+ controlHeight = _ref.controlHeight;
38
+ var scrollParent = getScrollParent(menuEl);
39
+ var defaultState = {
40
+ placement: 'bottom',
41
+ maxHeight: preferredMaxHeight
42
+ };
43
+
44
+ // something went wrong, return default state
45
+ if (!menuEl || !menuEl.offsetParent) {
46
+ return defaultState;
47
+ }
48
+
49
+ // we can't trust `scrollParent.scrollHeight` --> it may increase when
50
+ // the menu is rendered
51
+ var _scrollParent$getBoun = scrollParent.getBoundingClientRect(),
52
+ scrollHeight = _scrollParent$getBoun.height,
53
+ scrollParentTop = _scrollParent$getBoun.top;
54
+ var _menuEl$getBoundingCl = menuEl.getBoundingClientRect(),
55
+ menuBottom = _menuEl$getBoundingCl.bottom,
56
+ menuHeight = _menuEl$getBoundingCl.height,
57
+ menuTop = _menuEl$getBoundingCl.top;
58
+ var _menuEl$offsetParent$ = menuEl.offsetParent.getBoundingClientRect(),
59
+ containerTop = _menuEl$offsetParent$.top;
60
+ var viewHeight = isFixedPosition ? window.innerHeight : normalizedHeight(scrollParent);
61
+ var scrollTop = getScrollTop(scrollParent);
62
+ // use menuTop - scrollParentTop for the actual top space of menu in the scroll container
63
+ var menuTopFromParent = fg('design-system-select-fix-placement') ? menuTop - scrollParentTop : menuTop;
64
+ var marginBottom = parseInt(getComputedStyle(menuEl).marginBottom, 10);
65
+ var marginTop = parseInt(getComputedStyle(menuEl).marginTop, 10);
66
+ var viewSpaceAbove = containerTop - marginTop;
67
+ var viewSpaceBelow = viewHeight - menuTopFromParent;
68
+ var scrollSpaceAbove = viewSpaceAbove + scrollTop;
69
+ var scrollSpaceBelow = scrollHeight - scrollTop - menuTopFromParent;
70
+ var scrollDown = menuBottom - viewHeight + scrollTop + marginBottom;
71
+ var scrollUp = scrollTop + menuTop - marginTop;
72
+ var scrollDuration = 160;
73
+ switch (preferredPlacement) {
74
+ case 'auto':
75
+ case 'bottom':
76
+ // 1: the menu will fit, do nothing
77
+ if (viewSpaceBelow >= menuHeight) {
78
+ return {
79
+ placement: 'bottom',
80
+ maxHeight: preferredMaxHeight
81
+ };
82
+ }
83
+
84
+ // 2: the menu will fit, if scrolled
85
+ if (scrollSpaceBelow >= menuHeight && !isFixedPosition) {
86
+ if (shouldScroll) {
87
+ animatedScrollTo(scrollParent, scrollDown, scrollDuration);
88
+ }
89
+ return {
90
+ placement: 'bottom',
91
+ maxHeight: preferredMaxHeight
92
+ };
93
+ }
94
+
95
+ // 3: the menu will fit, if constrained
96
+ if (!isFixedPosition && scrollSpaceBelow >= minHeight || isFixedPosition && viewSpaceBelow >= minHeight) {
97
+ if (shouldScroll) {
98
+ animatedScrollTo(scrollParent, scrollDown, scrollDuration);
99
+ }
100
+
101
+ // we want to provide as much of the menu as possible to the user,
102
+ // so give them whatever is available below rather than the minHeight.
103
+ var constrainedHeight = isFixedPosition ? viewSpaceBelow - marginBottom : scrollSpaceBelow - marginBottom;
104
+ return {
105
+ placement: 'bottom',
106
+ maxHeight: constrainedHeight
107
+ };
108
+ }
109
+
110
+ // 4. Forked beviour when there isn't enough space below
111
+
112
+ // AUTO: flip the menu, render above
113
+ if (preferredPlacement === 'auto' || isFixedPosition) {
114
+ // may need to be constrained after flipping
115
+ var _constrainedHeight = preferredMaxHeight;
116
+ var spaceAbove = isFixedPosition ? viewSpaceAbove : scrollSpaceAbove;
117
+ if (spaceAbove >= minHeight) {
118
+ _constrainedHeight = Math.min(spaceAbove - marginBottom - controlHeight, preferredMaxHeight);
119
+ }
120
+ return {
121
+ placement: 'top',
122
+ maxHeight: _constrainedHeight
123
+ };
124
+ }
125
+
126
+ // BOTTOM: allow browser to increase scrollable area and immediately set scroll
127
+ if (preferredPlacement === 'bottom') {
128
+ if (shouldScroll) {
129
+ scrollTo(scrollParent, scrollDown);
130
+ }
131
+ return {
132
+ placement: 'bottom',
133
+ maxHeight: preferredMaxHeight
134
+ };
135
+ }
136
+ break;
137
+ case 'top':
138
+ // 1: the menu will fit, do nothing
139
+ if (viewSpaceAbove >= menuHeight) {
140
+ return {
141
+ placement: 'top',
142
+ maxHeight: preferredMaxHeight
143
+ };
144
+ }
145
+
146
+ // 2: the menu will fit, if scrolled
147
+ if (scrollSpaceAbove >= menuHeight && !isFixedPosition) {
148
+ if (shouldScroll) {
149
+ animatedScrollTo(scrollParent, scrollUp, scrollDuration);
150
+ }
151
+ return {
152
+ placement: 'top',
153
+ maxHeight: preferredMaxHeight
154
+ };
155
+ }
156
+
157
+ // 3: the menu will fit, if constrained
158
+ if (!isFixedPosition && scrollSpaceAbove >= minHeight || isFixedPosition && viewSpaceAbove >= minHeight) {
159
+ var _constrainedHeight2 = preferredMaxHeight;
160
+
161
+ // we want to provide as much of the menu as possible to the user,
162
+ // so give them whatever is available below rather than the minHeight.
163
+ if (!isFixedPosition && scrollSpaceAbove >= minHeight || isFixedPosition && viewSpaceAbove >= minHeight) {
164
+ _constrainedHeight2 = isFixedPosition ? viewSpaceAbove - marginTop : scrollSpaceAbove - marginTop;
165
+ }
166
+ if (shouldScroll) {
167
+ animatedScrollTo(scrollParent, scrollUp, scrollDuration);
168
+ }
169
+ return {
170
+ placement: 'top',
171
+ maxHeight: _constrainedHeight2
172
+ };
173
+ }
174
+
175
+ // 4. not enough space, the browser WILL NOT increase scrollable area when
176
+ // absolutely positioned element rendered above the viewport (only below).
177
+ // Flip the menu, render below
178
+ return {
179
+ placement: 'bottom',
180
+ maxHeight: preferredMaxHeight
181
+ };
182
+ default:
183
+ throw new Error("Invalid placement provided \"".concat(preferredPlacement, "\"."));
184
+ }
185
+ return defaultState;
186
+ }
187
+
188
+ // Menu Component
189
+ // ------------------------------
190
+
191
+ function alignToControl(placement) {
192
+ var placementToCSSProp = {
193
+ bottom: 'top',
194
+ top: 'bottom'
195
+ };
196
+ return placement ? placementToCSSProp[placement] : 'bottom';
197
+ }
198
+ var coercePlacement = function coercePlacement(p) {
199
+ return p === 'auto' ? 'bottom' : p;
200
+ };
201
+ export var menuCSS = function menuCSS(_ref2) {
202
+ var placement = _ref2.placement;
203
+ return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
204
+ label: 'menu'
205
+ }, alignToControl(placement), '100%'), "position", 'absolute'), "width", '100%'), "zIndex", 1), "borderRadius", "var(--ds-border-radius, 4px)"), "marginBottom", "var(--ds-space-100, 8px)"), "marginTop", "var(--ds-space-100, 8px)"), "backgroundColor", "var(--ds-surface-overlay, white)"), "boxShadow", "var(--ds-shadow-overlay, 0 0 0 1px hsl(0deg 0% 0% / 10%), 0 4px 11px hsl(0deg 0% 0% / 10%))");
206
+ };
207
+ var PortalPlacementContext = /*#__PURE__*/createContext(null);
208
+
209
+ // NOTE: internal only
210
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
211
+ export var MenuPlacer = function MenuPlacer(props) {
212
+ var children = props.children,
213
+ minMenuHeight = props.minMenuHeight,
214
+ maxMenuHeight = props.maxMenuHeight,
215
+ menuPlacement = props.menuPlacement,
216
+ menuPosition = props.menuPosition,
217
+ menuShouldScrollIntoView = props.menuShouldScrollIntoView;
218
+ var _ref4 = useContext(PortalPlacementContext) || {},
219
+ setPortalPlacement = _ref4.setPortalPlacement;
220
+ var ref = useRef(null);
221
+ var _useState = useState(maxMenuHeight),
222
+ _useState2 = _slicedToArray(_useState, 2),
223
+ maxHeight = _useState2[0],
224
+ setMaxHeight = _useState2[1];
225
+ var _useState3 = useState(null),
226
+ _useState4 = _slicedToArray(_useState3, 2),
227
+ placement = _useState4[0],
228
+ setPlacement = _useState4[1];
229
+ // The minimum height of the control
230
+ var controlHeight = 38;
231
+ useLayoutEffect(function () {
232
+ var menuEl = ref.current;
233
+ if (!menuEl) {
234
+ return;
235
+ }
236
+
237
+ // DO NOT scroll if position is fixed
238
+ var isFixedPosition = menuPosition === 'fixed';
239
+ var shouldScroll = menuShouldScrollIntoView && !isFixedPosition;
240
+ var state = getMenuPlacement({
241
+ maxHeight: maxMenuHeight,
242
+ menuEl: menuEl,
243
+ minHeight: minMenuHeight,
244
+ placement: menuPlacement,
245
+ shouldScroll: shouldScroll,
246
+ isFixedPosition: isFixedPosition,
247
+ controlHeight: controlHeight
248
+ });
249
+ setMaxHeight(state.maxHeight);
250
+ setPlacement(state.placement);
251
+ setPortalPlacement === null || setPortalPlacement === void 0 || setPortalPlacement(state.placement);
252
+ }, [maxMenuHeight, menuPlacement, menuPosition, menuShouldScrollIntoView, minMenuHeight, setPortalPlacement, controlHeight]);
253
+ return children({
254
+ ref: ref,
255
+ placerProps: _objectSpread(_objectSpread({}, props), {}, {
256
+ placement: placement || coercePlacement(menuPlacement),
257
+ maxHeight: maxHeight
258
+ })
259
+ });
260
+ };
261
+ var Menu = function Menu(props) {
262
+ var children = props.children,
263
+ innerRef = props.innerRef,
264
+ innerProps = props.innerProps;
265
+ return jsx("div", _extends({}, getStyleProps(props, 'menu', {
266
+ menu: true
267
+ }), {
268
+ ref: innerRef
269
+ }, innerProps), children);
270
+ };
271
+
272
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
273
+ export default Menu;
274
+
275
+ // ==============================
276
+ // Menu List
277
+ // ==============================
278
+
279
+ export var menuListCSS = function menuListCSS(_ref5) {
280
+ var maxHeight = _ref5.maxHeight;
281
+ return {
282
+ maxHeight: maxHeight,
283
+ overflowY: 'auto',
284
+ position: 'relative',
285
+ // required for offset[Height, Top] > keyboard scroll
286
+ WebkitOverflowScrolling: 'touch',
287
+ paddingTop: "var(--ds-space-100, 8px)",
288
+ paddingBottom: "var(--ds-space-100, 8px)"
289
+ };
290
+ };
291
+
292
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
293
+ export var MenuList = function MenuList(props) {
294
+ var children = props.children,
295
+ innerProps = props.innerProps,
296
+ innerRef = props.innerRef,
297
+ isMulti = props.isMulti;
298
+ return jsx("div", _extends({}, getStyleProps(props, 'menuList', {
299
+ 'menu-list': true,
300
+ 'menu-list--is-multi': isMulti
301
+ }), {
302
+ ref: innerRef
303
+ }, innerProps, {
304
+ tabIndex: -1
305
+ }), children);
306
+ };
307
+
308
+ // ==============================
309
+ // Menu Notices
310
+ // ==============================
311
+
312
+ var noticeCSS = function noticeCSS(_ref6) {
313
+ _objectDestructuringEmpty(_ref6);
314
+ return {
315
+ textAlign: 'center',
316
+ padding: "var(--ds-space-100, 8px)".concat(" ", "var(--ds-space-150, 12px)")
317
+ };
318
+ };
319
+ export var noOptionsMessageCSS = noticeCSS;
320
+ export var loadingMessageCSS = noticeCSS;
321
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
322
+ export var NoOptionsMessage = function NoOptionsMessage(_ref7) {
323
+ var _ref7$children = _ref7.children,
324
+ children = _ref7$children === void 0 ? 'No options' : _ref7$children,
325
+ innerProps = _ref7.innerProps,
326
+ restProps = _objectWithoutProperties(_ref7, _excluded);
327
+ return jsx("div", _extends({}, getStyleProps(_objectSpread(_objectSpread({}, restProps), {}, {
328
+ children: children,
329
+ innerProps: innerProps
330
+ }), 'noOptionsMessage', {
331
+ 'menu-notice': true,
332
+ 'menu-notice--no-options': true
333
+ }), {
334
+ // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
335
+ role: "option"
336
+ }, innerProps), jsx(Text, {
337
+ color: "color.text.subtle"
338
+ }, children));
339
+ };
340
+
341
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
342
+ export var LoadingMessage = function LoadingMessage(_ref8) {
343
+ var _ref8$children = _ref8.children,
344
+ children = _ref8$children === void 0 ? 'Loading...' : _ref8$children,
345
+ innerProps = _ref8.innerProps,
346
+ restProps = _objectWithoutProperties(_ref8, _excluded2);
347
+ return jsx("div", _extends({}, getStyleProps(_objectSpread(_objectSpread({}, restProps), {}, {
348
+ children: children,
349
+ innerProps: innerProps
350
+ }), 'loadingMessage', {
351
+ 'menu-notice': true,
352
+ 'menu-notice--loading': true
353
+ }), innerProps, {
354
+ // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
355
+ role: "option"
356
+ }), jsx(Text, {
357
+ color: "color.text.subtle"
358
+ }, children));
359
+ };
360
+
361
+ // ==============================
362
+ // Menu Portal
363
+ // ==============================
364
+
365
+ export var menuPortalCSS = function menuPortalCSS(_ref9) {
366
+ var rect = _ref9.rect,
367
+ offset = _ref9.offset,
368
+ position = _ref9.position;
369
+ return {
370
+ left: rect.left,
371
+ position: position,
372
+ top: offset,
373
+ width: rect.width,
374
+ zIndex: 1
375
+ };
376
+ };
377
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
378
+ export var MenuPortal = function MenuPortal(props) {
379
+ var appendTo = props.appendTo,
380
+ children = props.children,
381
+ controlElement = props.controlElement,
382
+ innerProps = props.innerProps,
383
+ menuPlacement = props.menuPlacement,
384
+ menuPosition = props.menuPosition;
385
+ var menuPortalRef = useRef(null);
386
+ var cleanupRef = useRef(null);
387
+ var _useState5 = useState(coercePlacement(menuPlacement)),
388
+ _useState6 = _slicedToArray(_useState5, 2),
389
+ placement = _useState6[0],
390
+ setPortalPlacement = _useState6[1];
391
+ var portalPlacementContext = useMemo(function () {
392
+ return {
393
+ setPortalPlacement: setPortalPlacement
394
+ };
395
+ }, []);
396
+ var _useState7 = useState(null),
397
+ _useState8 = _slicedToArray(_useState7, 2),
398
+ computedPosition = _useState8[0],
399
+ setComputedPosition = _useState8[1];
400
+ var updateComputedPosition = useCallback(function () {
401
+ if (!controlElement) {
402
+ return;
403
+ }
404
+ var rect = getBoundingClientObj(controlElement);
405
+ var scrollDistance = menuPosition === 'fixed' ? 0 : window.pageYOffset;
406
+ var offset = rect[placement] + scrollDistance;
407
+ if (offset !== (computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.offset) || rect.left !== (computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.left) || rect.width !== (computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.width)) {
408
+ setComputedPosition({
409
+ offset: offset,
410
+ rect: rect
411
+ });
412
+ }
413
+ }, [controlElement, menuPosition, placement, computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.offset, computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.left, computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.width]);
414
+ useLayoutEffect(function () {
415
+ updateComputedPosition();
416
+ }, [updateComputedPosition]);
417
+ var runAutoUpdate = useCallback(function () {
418
+ if (typeof cleanupRef.current === 'function') {
419
+ cleanupRef.current();
420
+ cleanupRef.current = null;
421
+ }
422
+ if (controlElement && menuPortalRef.current) {
423
+ cleanupRef.current = autoUpdate(controlElement, menuPortalRef.current, updateComputedPosition, {
424
+ elementResize: 'ResizeObserver' in window
425
+ });
426
+ }
427
+ }, [controlElement, updateComputedPosition]);
428
+ useLayoutEffect(function () {
429
+ runAutoUpdate();
430
+ }, [runAutoUpdate]);
431
+ var setMenuPortalElement = useCallback(function (menuPortalElement) {
432
+ menuPortalRef.current = menuPortalElement;
433
+ runAutoUpdate();
434
+ }, [runAutoUpdate]);
435
+
436
+ // bail early if required elements aren't present
437
+ if (!appendTo && menuPosition !== 'fixed' || !computedPosition) {
438
+ return null;
439
+ }
440
+
441
+ // same wrapper element whether fixed or portalled
442
+ var menuWrapper = jsx("div", _extends({
443
+ ref: setMenuPortalElement
444
+ }, getStyleProps(_objectSpread(_objectSpread({}, props), {}, {
445
+ offset: computedPosition.offset,
446
+ position: menuPosition,
447
+ rect: computedPosition.rect
448
+ }), 'menuPortal', {
449
+ 'menu-portal': true
450
+ }), innerProps), children);
451
+ return jsx(PortalPlacementContext.Provider, {
452
+ value: portalPlacementContext
453
+ }, appendTo ? /*#__PURE__*/createPortal(menuWrapper, appendTo) : menuWrapper);
454
+ };
@@ -0,0 +1,217 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ /**
5
+ * @jsxRuntime classic
6
+ * @jsx jsx
7
+ */
8
+
9
+ import { css, jsx } from '@emotion/react';
10
+ import LegacySelectClearIcon from '@atlaskit/icon/glyph/select-clear';
11
+ import CrossIcon from '@atlaskit/icon/utility/cross';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
13
+ import { Inline, xcss } from '@atlaskit/primitives';
14
+ import { getStyleProps } from '../../utils';
15
+ export var multiValueCSS = function multiValueCSS(_ref) {
16
+ var isDisabled = _ref.isDisabled,
17
+ isFocused = _ref.isFocused;
18
+ var backgroundColor;
19
+ var color;
20
+ if (isDisabled) {
21
+ // Use the basic neutral background so it is slightly separate from the
22
+ // field's background
23
+ backgroundColor = "var(--ds-background-neutral, #091E420F)";
24
+ color = "var(--ds-text-disabled, #091E424F)";
25
+ } else if (isFocused) {
26
+ backgroundColor = "var(--ds-background-selected, #E9F2FF)";
27
+ color = "var(--ds-text-selected, hsl(0, 0%, 20%))";
28
+ } else {
29
+ backgroundColor = fg('platform-component-visual-refresh') ? "var(--ds-background-neutral-subtle-hovered, #091E420F)" : "var(--ds-background-neutral, #091E420F)";
30
+ color = "var(--ds-text, hsl(0, 0%, 20%))";
31
+ }
32
+ return _objectSpread({
33
+ label: 'multiValue',
34
+ display: 'flex',
35
+ minWidth: 0,
36
+ // resolves flex/text-overflow bug
37
+ margin: "var(--ds-space-025, 2px)",
38
+ borderRadius: "var(--ds-border-radius-050, 2px)",
39
+ backgroundColor: backgroundColor,
40
+ boxShadow: isFocused ? "0 0 0 2px ".concat("var(--ds-surface, transparent)", ", 0 0 0 4px ", "var(--ds-border-focused, transparent)") : 'none',
41
+ maxWidth: '100%',
42
+ '@media screen and (-ms-high-contrast: active)': {
43
+ border: isFocused ? '1px solid transparent' : 'none'
44
+ },
45
+ color: color
46
+ }, fg('platform-component-visual-refresh') && {
47
+ borderRadius: "var(--ds-border-radius-100, 4px)",
48
+ // Hardcode this color for visual refresh as there is no token color yet
49
+ borderColor: '#B7B9BE',
50
+ borderWidth: "var(--ds-border-width, 1px)",
51
+ borderStyle: 'solid',
52
+ backgroundColor: "var(--ds-background-input, #FFFFFF)"
53
+ });
54
+ };
55
+ export var multiValueLabelCSS = function multiValueLabelCSS(_ref2) {
56
+ var cropWithEllipsis = _ref2.cropWithEllipsis,
57
+ isDisabled = _ref2.isDisabled;
58
+ return _objectSpread({
59
+ overflow: 'hidden',
60
+ textOverflow: cropWithEllipsis || cropWithEllipsis === undefined ? 'ellipsis' : undefined,
61
+ whiteSpace: 'nowrap',
62
+ borderRadius: "var(--ds-border-radius-050, 2px)",
63
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
64
+ fontSize: '85%',
65
+ font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
66
+ padding: "var(--ds-space-025, 2px)",
67
+ color: isDisabled ? "var(--ds-text-disabled, #091E424F)" : 'inherit',
68
+ paddingLeft: "var(--ds-space-075, 6px)"
69
+ }, fg('platform-component-visual-refresh') && {
70
+ font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
71
+ paddingTop: 0,
72
+ paddingBottom: 0,
73
+ paddingLeft: "var(--ds-space-050, 4px)"
74
+ });
75
+ };
76
+ export var multiValueRemoveCSS = function multiValueRemoveCSS(_ref3) {
77
+ var isFocused = _ref3.isFocused;
78
+ return _objectSpread({
79
+ alignItems: 'center',
80
+ display: 'flex',
81
+ backgroundColor: isFocused ? "var(--ds-UNSAFE-transparent, transparent)" : undefined,
82
+ fill: isFocused ? "var(--ds-text-selected, #000)" : "var(--ds-text, #000)",
83
+ paddingLeft: "var(--ds-space-025, 2px)",
84
+ paddingRight: "var(--ds-space-025, 2px)",
85
+ borderRadius: '0px 2px 2px 0px',
86
+ // DSP-6470 we should style like Tag once we have the :has selector
87
+ ':hover': {
88
+ backgroundColor: "var(--ds-background-danger-hovered, #FFD5D2)",
89
+ fill: "var(--ds-text-danger, #000)"
90
+ },
91
+ ':active': {
92
+ backgroundColor: "var(--ds-background-danger-pressed, #FD9891)",
93
+ fill: "var(--ds-text-danger, #000)"
94
+ }
95
+ }, fg('platform-component-visual-refresh') && {
96
+ backgroundColor: "var(--ds-background-neutral-subtle, #00000000)",
97
+ border: 'none',
98
+ alignItems: 'center',
99
+ justifyContent: 'center',
100
+ alignSelf: 'center',
101
+ appearance: 'none',
102
+ borderRadius: "var(--ds-border-radius, 4px)",
103
+ color: "var(--ds-text, #172B4D)",
104
+ padding: "var(--ds-space-025, 2px)",
105
+ marginRight: "var(--ds-space-025, 2px)",
106
+ ':focus-visible': {
107
+ outlineOffset: "var(--ds-space-negative-025, -2px)"
108
+ },
109
+ ':hover': {
110
+ backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
111
+ },
112
+ ':active': {
113
+ backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
114
+ }
115
+ });
116
+ };
117
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
118
+ var MultiValueGeneric = function MultiValueGeneric(_ref4) {
119
+ var children = _ref4.children,
120
+ innerProps = _ref4.innerProps;
121
+ return jsx("div", innerProps, children);
122
+ };
123
+
124
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
125
+ export var MultiValueContainer = MultiValueGeneric;
126
+
127
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
128
+ export var MultiValueLabel = MultiValueGeneric;
129
+ var disabledStyles = css({
130
+ display: 'none'
131
+ });
132
+ var enabledStyles = css({
133
+ display: 'inherit'
134
+ });
135
+ var iconWrapperStyles = xcss({
136
+ padding: 'space.025'
137
+ });
138
+ var renderIcon = function renderIcon() {
139
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
140
+ if (fg('platform-component-visual-refresh')) {
141
+ return jsx(CrossIcon, {
142
+ label: "",
143
+ color: "currentColor"
144
+ });
145
+ }
146
+
147
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
148
+ if (fg('platform-visual-refresh-icons-legacy-facade')) {
149
+ return jsx(Inline, {
150
+ xcss: iconWrapperStyles
151
+ }, jsx(CrossIcon, {
152
+ label: "",
153
+ color: "currentColor"
154
+ }));
155
+ }
156
+ return (
157
+ // eslint-disable-next-line @atlaskit/design-system/no-legacy-icons
158
+ jsx(LegacySelectClearIcon, {
159
+ label: "",
160
+ primaryColor: "transparent",
161
+ size: "small",
162
+ secondaryColor: "inherit"
163
+ })
164
+ );
165
+ };
166
+ export function MultiValueRemove(_ref5) {
167
+ var isDisabled = _ref5.isDisabled,
168
+ innerProps = _ref5.innerProps;
169
+ return (
170
+ // 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
171
+ jsx("div", innerProps, jsx("div", {
172
+ css: isDisabled ? disabledStyles : enabledStyles,
173
+ "data-testid": isDisabled ? 'hide-clear-icon' : 'show-clear-icon'
174
+ }, renderIcon()))
175
+ );
176
+ }
177
+ var MultiValue = function MultiValue(props) {
178
+ var children = props.children,
179
+ components = props.components,
180
+ data = props.data,
181
+ innerProps = props.innerProps,
182
+ isDisabled = props.isDisabled,
183
+ removeProps = props.removeProps,
184
+ selectProps = props.selectProps;
185
+ var Container = components.Container,
186
+ Label = components.Label,
187
+ Remove = components.Remove;
188
+ var ariaLabel = typeof children === 'string' ? children : data.label;
189
+ return jsx(Container, {
190
+ data: data,
191
+ innerProps: _objectSpread(_objectSpread({}, getStyleProps(props, 'multiValue', {
192
+ 'multi-value': true,
193
+ 'multi-value--is-disabled': isDisabled
194
+ })), innerProps),
195
+ selectProps: selectProps
196
+ }, jsx(Label, {
197
+ data: data,
198
+ innerProps: _objectSpread({}, getStyleProps(props, 'multiValueLabel', {
199
+ 'multi-value__label': true
200
+ })),
201
+ selectProps: selectProps
202
+ }, children), jsx(Remove, {
203
+ data: data,
204
+ innerProps: _objectSpread(_objectSpread({}, getStyleProps(props, 'multiValueRemove', {
205
+ 'multi-value__remove': true
206
+ })), {}, {
207
+ role: 'button',
208
+ tabIndex: -1,
209
+ 'aria-label': "".concat(ariaLabel || 'option', ", remove")
210
+ }, removeProps),
211
+ isDisabled: isDisabled,
212
+ selectProps: selectProps
213
+ }));
214
+ };
215
+
216
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
217
+ export default MultiValue;