@atlaskit/react-select 0.0.2

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 (197) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE.md +11 -0
  3. package/README.md +10 -0
  4. package/async/package.json +15 -0
  5. package/base/package.json +15 -0
  6. package/creatable/package.json +15 -0
  7. package/dist/cjs/accessibility/helpers.js +34 -0
  8. package/dist/cjs/accessibility/index.js +74 -0
  9. package/dist/cjs/async-creatable.js +27 -0
  10. package/dist/cjs/async.js +30 -0
  11. package/dist/cjs/builtins.js +18 -0
  12. package/dist/cjs/components/containers.js +100 -0
  13. package/dist/cjs/components/control.js +67 -0
  14. package/dist/cjs/components/group.js +79 -0
  15. package/dist/cjs/components/index.js +53 -0
  16. package/dist/cjs/components/indicators.js +214 -0
  17. package/dist/cjs/components/input.js +93 -0
  18. package/dist/cjs/components/internal/a11y-text.js +34 -0
  19. package/dist/cjs/components/internal/dummy-input.js +43 -0
  20. package/dist/cjs/components/internal/index.js +34 -0
  21. package/dist/cjs/components/internal/required-input.js +43 -0
  22. package/dist/cjs/components/internal/scroll-manager.js +57 -0
  23. package/dist/cjs/components/internal/use-scroll-capture.js +132 -0
  24. package/dist/cjs/components/internal/use-scroll-lock.js +149 -0
  25. package/dist/cjs/components/live-region.js +153 -0
  26. package/dist/cjs/components/menu.js +464 -0
  27. package/dist/cjs/components/multi-value.js +129 -0
  28. package/dist/cjs/components/option.js +62 -0
  29. package/dist/cjs/components/placeholder.js +39 -0
  30. package/dist/cjs/components/single-value.js +46 -0
  31. package/dist/cjs/creatable.js +30 -0
  32. package/dist/cjs/diacritics.js +274 -0
  33. package/dist/cjs/filters.js +50 -0
  34. package/dist/cjs/index.js +55 -0
  35. package/dist/cjs/nonce-provider.js +30 -0
  36. package/dist/cjs/select.js +1803 -0
  37. package/dist/cjs/state-manager.js +31 -0
  38. package/dist/cjs/styles.js +66 -0
  39. package/dist/cjs/theme.js +42 -0
  40. package/dist/cjs/types.js +5 -0
  41. package/dist/cjs/use-async.js +156 -0
  42. package/dist/cjs/use-creatable.js +114 -0
  43. package/dist/cjs/use-state-manager.js +83 -0
  44. package/dist/cjs/utils.js +357 -0
  45. package/dist/es2019/accessibility/helpers.js +24 -0
  46. package/dist/es2019/accessibility/index.js +72 -0
  47. package/dist/es2019/async-creatable.js +17 -0
  48. package/dist/es2019/async.js +16 -0
  49. package/dist/es2019/builtins.js +4 -0
  50. package/dist/es2019/components/containers.js +100 -0
  51. package/dist/es2019/components/control.js +62 -0
  52. package/dist/es2019/components/group.js +74 -0
  53. package/dist/es2019/components/index.js +41 -0
  54. package/dist/es2019/components/indicators.js +211 -0
  55. package/dist/es2019/components/input.js +88 -0
  56. package/dist/es2019/components/internal/a11y-text.js +25 -0
  57. package/dist/es2019/components/internal/dummy-input.js +36 -0
  58. package/dist/es2019/components/internal/index.js +4 -0
  59. package/dist/es2019/components/internal/required-input.js +35 -0
  60. package/dist/es2019/components/internal/scroll-manager.js +49 -0
  61. package/dist/es2019/components/internal/use-scroll-capture.js +128 -0
  62. package/dist/es2019/components/internal/use-scroll-lock.js +143 -0
  63. package/dist/es2019/components/live-region.js +151 -0
  64. package/dist/es2019/components/menu.js +466 -0
  65. package/dist/es2019/components/multi-value.js +134 -0
  66. package/dist/es2019/components/option.js +57 -0
  67. package/dist/es2019/components/placeholder.js +34 -0
  68. package/dist/es2019/components/single-value.js +41 -0
  69. package/dist/es2019/creatable.js +15 -0
  70. package/dist/es2019/diacritics.js +264 -0
  71. package/dist/es2019/filters.js +36 -0
  72. package/dist/es2019/index.js +8 -0
  73. package/dist/es2019/nonce-provider.js +19 -0
  74. package/dist/es2019/select.js +1766 -0
  75. package/dist/es2019/state-manager.js +22 -0
  76. package/dist/es2019/styles.js +56 -0
  77. package/dist/es2019/theme.js +36 -0
  78. package/dist/es2019/types.js +1 -0
  79. package/dist/es2019/use-async.js +117 -0
  80. package/dist/es2019/use-creatable.js +81 -0
  81. package/dist/es2019/use-state-manager.js +60 -0
  82. package/dist/es2019/utils.js +309 -0
  83. package/dist/esm/accessibility/helpers.js +24 -0
  84. package/dist/esm/accessibility/index.js +68 -0
  85. package/dist/esm/async-creatable.js +17 -0
  86. package/dist/esm/async.js +16 -0
  87. package/dist/esm/builtins.js +12 -0
  88. package/dist/esm/components/containers.js +96 -0
  89. package/dist/esm/components/control.js +62 -0
  90. package/dist/esm/components/group.js +74 -0
  91. package/dist/esm/components/index.js +43 -0
  92. package/dist/esm/components/indicators.js +209 -0
  93. package/dist/esm/components/input.js +88 -0
  94. package/dist/esm/components/internal/a11y-text.js +27 -0
  95. package/dist/esm/components/internal/dummy-input.js +37 -0
  96. package/dist/esm/components/internal/index.js +4 -0
  97. package/dist/esm/components/internal/required-input.js +36 -0
  98. package/dist/esm/components/internal/scroll-manager.js +49 -0
  99. package/dist/esm/components/internal/use-scroll-capture.js +126 -0
  100. package/dist/esm/components/internal/use-scroll-lock.js +143 -0
  101. package/dist/esm/components/live-region.js +148 -0
  102. package/dist/esm/components/menu.js +460 -0
  103. package/dist/esm/components/multi-value.js +122 -0
  104. package/dist/esm/components/option.js +57 -0
  105. package/dist/esm/components/placeholder.js +34 -0
  106. package/dist/esm/components/single-value.js +41 -0
  107. package/dist/esm/creatable.js +15 -0
  108. package/dist/esm/diacritics.js +268 -0
  109. package/dist/esm/filters.js +43 -0
  110. package/dist/esm/index.js +8 -0
  111. package/dist/esm/nonce-provider.js +20 -0
  112. package/dist/esm/select.js +1794 -0
  113. package/dist/esm/state-manager.js +22 -0
  114. package/dist/esm/styles.js +58 -0
  115. package/dist/esm/theme.js +36 -0
  116. package/dist/esm/types.js +1 -0
  117. package/dist/esm/use-async.js +149 -0
  118. package/dist/esm/use-creatable.js +107 -0
  119. package/dist/esm/use-state-manager.js +76 -0
  120. package/dist/esm/utils.js +328 -0
  121. package/dist/types/accessibility/helpers.d.ts +5 -0
  122. package/dist/types/accessibility/index.d.ts +125 -0
  123. package/dist/types/async-creatable.d.ts +10 -0
  124. package/dist/types/async.d.ts +9 -0
  125. package/dist/types/builtins.d.ts +5 -0
  126. package/dist/types/components/containers.d.ts +50 -0
  127. package/dist/types/components/control.d.ts +33 -0
  128. package/dist/types/components/group.d.ts +53 -0
  129. package/dist/types/components/index.d.ts +73 -0
  130. package/dist/types/components/indicators.d.ts +72 -0
  131. package/dist/types/components/input.d.ts +33 -0
  132. package/dist/types/components/internal/a11y-text.d.ts +8 -0
  133. package/dist/types/components/internal/dummy-input.d.ts +9 -0
  134. package/dist/types/components/internal/index.d.ts +4 -0
  135. package/dist/types/components/internal/required-input.d.ts +10 -0
  136. package/dist/types/components/internal/scroll-manager.d.ts +17 -0
  137. package/dist/types/components/internal/use-scroll-capture.d.ts +12 -0
  138. package/dist/types/components/internal/use-scroll-lock.d.ts +9 -0
  139. package/dist/types/components/live-region.d.ts +24 -0
  140. package/dist/types/components/menu.d.ts +130 -0
  141. package/dist/types/components/multi-value.d.ts +47 -0
  142. package/dist/types/components/option.d.ts +49 -0
  143. package/dist/types/components/placeholder.d.ts +22 -0
  144. package/dist/types/components/single-value.d.ts +28 -0
  145. package/dist/types/creatable.d.ts +10 -0
  146. package/dist/types/diacritics.d.ts +1 -0
  147. package/dist/types/filters.d.ts +15 -0
  148. package/dist/types/index.d.ts +28 -0
  149. package/dist/types/nonce-provider.d.ts +8 -0
  150. package/dist/types/select.d.ts +616 -0
  151. package/dist/types/state-manager.d.ts +17 -0
  152. package/dist/types/styles.d.ts +68 -0
  153. package/dist/types/theme.d.ts +27 -0
  154. package/dist/types/types.d.ts +134 -0
  155. package/dist/types/use-async.d.ts +31 -0
  156. package/dist/types/use-creatable.d.ts +46 -0
  157. package/dist/types/use-state-manager.d.ts +15 -0
  158. package/dist/types/utils.d.ts +44 -0
  159. package/dist/types-ts4.5/accessibility/helpers.d.ts +5 -0
  160. package/dist/types-ts4.5/accessibility/index.d.ts +125 -0
  161. package/dist/types-ts4.5/async-creatable.d.ts +10 -0
  162. package/dist/types-ts4.5/async.d.ts +9 -0
  163. package/dist/types-ts4.5/builtins.d.ts +5 -0
  164. package/dist/types-ts4.5/components/containers.d.ts +50 -0
  165. package/dist/types-ts4.5/components/control.d.ts +33 -0
  166. package/dist/types-ts4.5/components/group.d.ts +53 -0
  167. package/dist/types-ts4.5/components/index.d.ts +73 -0
  168. package/dist/types-ts4.5/components/indicators.d.ts +72 -0
  169. package/dist/types-ts4.5/components/input.d.ts +33 -0
  170. package/dist/types-ts4.5/components/internal/a11y-text.d.ts +8 -0
  171. package/dist/types-ts4.5/components/internal/dummy-input.d.ts +9 -0
  172. package/dist/types-ts4.5/components/internal/index.d.ts +4 -0
  173. package/dist/types-ts4.5/components/internal/required-input.d.ts +10 -0
  174. package/dist/types-ts4.5/components/internal/scroll-manager.d.ts +17 -0
  175. package/dist/types-ts4.5/components/internal/use-scroll-capture.d.ts +12 -0
  176. package/dist/types-ts4.5/components/internal/use-scroll-lock.d.ts +9 -0
  177. package/dist/types-ts4.5/components/live-region.d.ts +24 -0
  178. package/dist/types-ts4.5/components/menu.d.ts +130 -0
  179. package/dist/types-ts4.5/components/multi-value.d.ts +47 -0
  180. package/dist/types-ts4.5/components/option.d.ts +49 -0
  181. package/dist/types-ts4.5/components/placeholder.d.ts +22 -0
  182. package/dist/types-ts4.5/components/single-value.d.ts +28 -0
  183. package/dist/types-ts4.5/creatable.d.ts +10 -0
  184. package/dist/types-ts4.5/diacritics.d.ts +1 -0
  185. package/dist/types-ts4.5/filters.d.ts +15 -0
  186. package/dist/types-ts4.5/index.d.ts +28 -0
  187. package/dist/types-ts4.5/nonce-provider.d.ts +8 -0
  188. package/dist/types-ts4.5/select.d.ts +616 -0
  189. package/dist/types-ts4.5/state-manager.d.ts +17 -0
  190. package/dist/types-ts4.5/styles.d.ts +68 -0
  191. package/dist/types-ts4.5/theme.d.ts +27 -0
  192. package/dist/types-ts4.5/types.d.ts +134 -0
  193. package/dist/types-ts4.5/use-async.d.ts +31 -0
  194. package/dist/types-ts4.5/use-creatable.d.ts +46 -0
  195. package/dist/types-ts4.5/use-state-manager.d.ts +15 -0
  196. package/dist/types-ts4.5/utils.d.ts +44 -0
  197. package/package.json +83 -0
@@ -0,0 +1,357 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.animatedScrollTo = animatedScrollTo;
8
+ exports.classNames = classNames;
9
+ exports.emptyString = exports.cleanValue = exports.cleanCommonProps = void 0;
10
+ exports.getBoundingClientObj = getBoundingClientObj;
11
+ exports.getScrollParent = getScrollParent;
12
+ exports.getScrollTop = getScrollTop;
13
+ exports.getStyleProps = void 0;
14
+ exports.handleInputChange = handleInputChange;
15
+ exports.isArray = isArray;
16
+ exports.isDocumentElement = isDocumentElement;
17
+ exports.isMobileDevice = isMobileDevice;
18
+ exports.isTouchCapable = isTouchCapable;
19
+ exports.multiValueAsValue = multiValueAsValue;
20
+ exports.noop = void 0;
21
+ exports.normalizedHeight = normalizedHeight;
22
+ exports.notNullish = notNullish;
23
+ exports.removeProps = void 0;
24
+ exports.scrollIntoView = scrollIntoView;
25
+ exports.scrollTo = scrollTo;
26
+ exports.singleValueAsValue = singleValueAsValue;
27
+ exports.supportsPassiveEvents = void 0;
28
+ exports.toKey = toKey;
29
+ exports.valueTernary = valueTernary;
30
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
31
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
32
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
33
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
34
+ var _excluded = ["className", "clearValue", "cx", "getStyles", "getClassNames", "getValue", "hasValue", "isMulti", "isRtl", "options", "selectOption", "selectProps", "setValue", "theme"];
35
+ 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; }
36
+ 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) { (0, _defineProperty2.default)(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; }
37
+ // ==============================
38
+ // NO OP
39
+ // ==============================
40
+
41
+ var noop = exports.noop = function noop() {};
42
+ var emptyString = exports.emptyString = function emptyString() {
43
+ return '';
44
+ };
45
+
46
+ // ==============================
47
+ // Class Name Prefixer
48
+ // ==============================
49
+
50
+ /**
51
+ * String representation of component state for styling with class names.
52
+ *
53
+ * Expects an array of strings OR a string/object pair:
54
+ * - className(['comp', 'comp-arg', 'comp-arg-2'])
55
+ * @returns 'react-select__comp react-select__comp-arg react-select__comp-arg-2'
56
+ * - className('comp', { some: true, state: false })
57
+ * @returns 'react-select__comp react-select__comp--some'
58
+ */
59
+ function applyPrefixToName(prefix, name) {
60
+ if (!name) {
61
+ return prefix;
62
+ } else if (name[0] === '-') {
63
+ return prefix + name;
64
+ } else {
65
+ return prefix + '__' + name;
66
+ }
67
+ }
68
+ function classNames(prefix, state) {
69
+ for (var _len = arguments.length, classNameList = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
70
+ classNameList[_key - 2] = arguments[_key];
71
+ }
72
+ var arr = [].concat(classNameList);
73
+ if (state && prefix) {
74
+ for (var key in state) {
75
+ if (state.hasOwnProperty(key) && state[key]) {
76
+ arr.push("".concat(applyPrefixToName(prefix, key)));
77
+ }
78
+ }
79
+ }
80
+ return arr.filter(function (i) {
81
+ return i;
82
+ }).map(function (i) {
83
+ return String(i).trim();
84
+ }).join(' ');
85
+ }
86
+ // ==============================
87
+ // Clean Value
88
+ // ==============================
89
+
90
+ var cleanValue = exports.cleanValue = function cleanValue(value) {
91
+ if (isArray(value)) {
92
+ return value.filter(Boolean);
93
+ }
94
+ if ((0, _typeof2.default)(value) === 'object' && value !== null) {
95
+ return [value];
96
+ }
97
+ return [];
98
+ };
99
+
100
+ // ==============================
101
+ // Clean Common Props
102
+ // ==============================
103
+
104
+ var cleanCommonProps = exports.cleanCommonProps = function cleanCommonProps(props) {
105
+ //className
106
+ var className = props.className,
107
+ clearValue = props.clearValue,
108
+ cx = props.cx,
109
+ getStyles = props.getStyles,
110
+ getClassNames = props.getClassNames,
111
+ getValue = props.getValue,
112
+ hasValue = props.hasValue,
113
+ isMulti = props.isMulti,
114
+ isRtl = props.isRtl,
115
+ options = props.options,
116
+ selectOption = props.selectOption,
117
+ selectProps = props.selectProps,
118
+ setValue = props.setValue,
119
+ theme = props.theme,
120
+ innerProps = (0, _objectWithoutProperties2.default)(props, _excluded);
121
+ return _objectSpread({}, innerProps);
122
+ };
123
+
124
+ // ==============================
125
+ // Get Style Props
126
+ // ==============================
127
+
128
+ var getStyleProps = exports.getStyleProps = function getStyleProps(props, name, classNamesState) {
129
+ var cx = props.cx,
130
+ getStyles = props.getStyles,
131
+ getClassNames = props.getClassNames,
132
+ className = props.className;
133
+ return {
134
+ css: getStyles(name, props),
135
+ className: cx(classNamesState !== null && classNamesState !== void 0 ? classNamesState : {}, getClassNames(name, props), className)
136
+ };
137
+ };
138
+
139
+ // ==============================
140
+ // Handle Input Change
141
+ // ==============================
142
+
143
+ function handleInputChange(inputValue, actionMeta, onInputChange) {
144
+ if (onInputChange) {
145
+ var _newValue = onInputChange(inputValue, actionMeta);
146
+ if (typeof _newValue === 'string') {
147
+ return _newValue;
148
+ }
149
+ }
150
+ return inputValue;
151
+ }
152
+
153
+ // ==============================
154
+ // Scroll Helpers
155
+ // ==============================
156
+
157
+ function isDocumentElement(el) {
158
+ return [document.documentElement, document.body, window].indexOf(el) > -1;
159
+ }
160
+
161
+ // Normalized Scroll Top
162
+ // ------------------------------
163
+
164
+ function normalizedHeight(el) {
165
+ if (isDocumentElement(el)) {
166
+ return window.innerHeight;
167
+ }
168
+ return el.clientHeight;
169
+ }
170
+
171
+ // Normalized scrollTo & scrollTop
172
+ // ------------------------------
173
+
174
+ function getScrollTop(el) {
175
+ if (isDocumentElement(el)) {
176
+ return window.pageYOffset;
177
+ }
178
+ return el.scrollTop;
179
+ }
180
+ function scrollTo(el, top) {
181
+ // with a scroll distance, we perform scroll on the element
182
+ if (isDocumentElement(el)) {
183
+ window.scrollTo(0, top);
184
+ return;
185
+ }
186
+ el.scrollTop = top;
187
+ }
188
+
189
+ // Get Scroll Parent
190
+ // ------------------------------
191
+
192
+ function getScrollParent(element) {
193
+ var style = getComputedStyle(element);
194
+ var excludeStaticParent = style.position === 'absolute';
195
+ var overflowRx = /(auto|scroll)/;
196
+ if (style.position === 'fixed') {
197
+ return document.documentElement;
198
+ }
199
+ for (var parent = element; parent = parent.parentElement;) {
200
+ style = getComputedStyle(parent);
201
+ if (excludeStaticParent && style.position === 'static') {
202
+ continue;
203
+ }
204
+ if (overflowRx.test(style.overflow + style.overflowY + style.overflowX)) {
205
+ return parent;
206
+ }
207
+ }
208
+ return document.documentElement;
209
+ }
210
+
211
+ // Animated Scroll To
212
+ // ------------------------------
213
+
214
+ /**
215
+ * @param t: time (elapsed)
216
+ * @param b: initial value
217
+ * @param c: amount of change
218
+ * @param d: duration
219
+ */
220
+ function easeOutCubic(t, b, c, d) {
221
+ return c * ((t = t / d - 1) * t * t + 1) + b;
222
+ }
223
+ function animatedScrollTo(element, to) {
224
+ var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
225
+ var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
226
+ var start = getScrollTop(element);
227
+ var change = to - start;
228
+ var increment = 10;
229
+ var currentTime = 0;
230
+ function animateScroll() {
231
+ currentTime += increment;
232
+ var val = easeOutCubic(currentTime, start, change, duration);
233
+ scrollTo(element, val);
234
+ if (currentTime < duration) {
235
+ window.requestAnimationFrame(animateScroll);
236
+ } else {
237
+ callback(element);
238
+ }
239
+ }
240
+ animateScroll();
241
+ }
242
+
243
+ // Scroll Into View
244
+ // ------------------------------
245
+
246
+ function scrollIntoView(menuEl, focusedEl) {
247
+ var menuRect = menuEl.getBoundingClientRect();
248
+ var focusedRect = focusedEl.getBoundingClientRect();
249
+ var overScroll = focusedEl.offsetHeight / 3;
250
+ if (focusedRect.bottom + overScroll > menuRect.bottom) {
251
+ scrollTo(menuEl, Math.min(focusedEl.offsetTop + focusedEl.clientHeight - menuEl.offsetHeight + overScroll, menuEl.scrollHeight));
252
+ } else if (focusedRect.top - overScroll < menuRect.top) {
253
+ scrollTo(menuEl, Math.max(focusedEl.offsetTop - overScroll, 0));
254
+ }
255
+ }
256
+
257
+ // ==============================
258
+ // Get bounding client object
259
+ // ==============================
260
+
261
+ // cannot get keys using array notation with DOMRect
262
+ function getBoundingClientObj(element) {
263
+ var rect = element.getBoundingClientRect();
264
+ return {
265
+ bottom: rect.bottom,
266
+ height: rect.height,
267
+ left: rect.left,
268
+ right: rect.right,
269
+ top: rect.top,
270
+ width: rect.width
271
+ };
272
+ }
273
+ // ==============================
274
+ // String to Key (kebabify)
275
+ // ==============================
276
+
277
+ function toKey(str) {
278
+ return str.replace(/\W/g, '-');
279
+ }
280
+
281
+ // ==============================
282
+ // Touch Capability Detector
283
+ // ==============================
284
+
285
+ function isTouchCapable() {
286
+ try {
287
+ document.createEvent('TouchEvent');
288
+ return true;
289
+ } catch (e) {
290
+ return false;
291
+ }
292
+ }
293
+
294
+ // ==============================
295
+ // Mobile Device Detector
296
+ // ==============================
297
+
298
+ function isMobileDevice() {
299
+ try {
300
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
301
+ } catch (e) {
302
+ return false;
303
+ }
304
+ }
305
+
306
+ // ==============================
307
+ // Passive Event Detector
308
+ // ==============================
309
+
310
+ // https://github.com/rafgraph/detect-it/blob/main/src/index.ts#L19-L36
311
+ var passiveOptionAccessed = false;
312
+ var options = {
313
+ get passive() {
314
+ return passiveOptionAccessed = true;
315
+ }
316
+ };
317
+ // check for SSR
318
+ var w = typeof window !== 'undefined' ? window : {};
319
+ if (w.addEventListener && w.removeEventListener) {
320
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
321
+ w.addEventListener('p', noop, options);
322
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
323
+ w.removeEventListener('p', noop, false);
324
+ }
325
+ var supportsPassiveEvents = exports.supportsPassiveEvents = passiveOptionAccessed;
326
+ function notNullish(item) {
327
+ return item != null;
328
+ }
329
+ function isArray(arg) {
330
+ return Array.isArray(arg);
331
+ }
332
+ function valueTernary(isMulti, multiValue, singleValue) {
333
+ return isMulti ? multiValue : singleValue;
334
+ }
335
+ function singleValueAsValue(singleValue) {
336
+ return singleValue;
337
+ }
338
+ function multiValueAsValue(multiValue) {
339
+ return multiValue;
340
+ }
341
+ var removeProps = exports.removeProps = function removeProps(propsObj) {
342
+ for (var _len2 = arguments.length, properties = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
343
+ properties[_key2 - 1] = arguments[_key2];
344
+ }
345
+ var propsMap = Object.entries(propsObj).filter(function (_ref) {
346
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 1),
347
+ key = _ref2[0];
348
+ return !properties.includes(key);
349
+ });
350
+ return propsMap.reduce(function (newProps, _ref3) {
351
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
352
+ key = _ref4[0],
353
+ val = _ref4[1];
354
+ newProps[key] = val;
355
+ return newProps;
356
+ }, {});
357
+ };
@@ -0,0 +1,24 @@
1
+ /// <reference types="user-agent-data-types" />
2
+
3
+ function testPlatform(re) {
4
+ var _window$navigator$use;
5
+ return typeof window !== 'undefined' && window.navigator != null ? re.test(((_window$navigator$use = window.navigator['userAgentData']) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.platform) || window.navigator.platform) : false;
6
+ }
7
+ export function isIPhone() {
8
+ return testPlatform(/^iPhone/i);
9
+ }
10
+ export function isMac() {
11
+ return testPlatform(/^Mac/i);
12
+ }
13
+ export function isIPad() {
14
+ return testPlatform(/^iPad/i) ||
15
+ // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
16
+ // eslint-disable-next-line compat/compat
17
+ isMac() && navigator.maxTouchPoints > 1;
18
+ }
19
+ export function isIOS() {
20
+ return isIPhone() || isIPad();
21
+ }
22
+ export function isAppleDevice() {
23
+ return isMac() || isIOS();
24
+ }
@@ -0,0 +1,72 @@
1
+ export const defaultAriaLiveMessages = {
2
+ guidance: props => {
3
+ const {
4
+ isSearchable,
5
+ isMulti,
6
+ tabSelectsValue,
7
+ context,
8
+ isInitialFocus
9
+ } = props;
10
+ switch (context) {
11
+ case 'menu':
12
+ return `Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu${tabSelectsValue ? ', press Tab to select the option and exit the menu' : ''}.`;
13
+ case 'input':
14
+ return isInitialFocus ? `${props['aria-label'] || 'Select'} is focused ${isSearchable ? ',type to refine list' : ''}, press Down to open the menu, ${isMulti ? ' press left to focus selected values' : ''}` : '';
15
+ case 'value':
16
+ return 'Use left and right to toggle between focused values, press Backspace to remove the currently focused value';
17
+ default:
18
+ return '';
19
+ }
20
+ },
21
+ onChange: props => {
22
+ const {
23
+ action,
24
+ label = '',
25
+ labels,
26
+ isDisabled
27
+ } = props;
28
+ switch (action) {
29
+ case 'deselect-option':
30
+ case 'pop-value':
31
+ case 'remove-value':
32
+ return `option ${label}, deselected.`;
33
+ case 'clear':
34
+ return 'All selected options have been cleared.';
35
+ case 'initial-input-focus':
36
+ return `option${labels.length > 1 ? 's' : ''} ${labels.join(',')}, selected.`;
37
+ case 'select-option':
38
+ return isDisabled ? `option ${label} is disabled. Select another option.` : `option ${label}, selected.`;
39
+ default:
40
+ return '';
41
+ }
42
+ },
43
+ onFocus: props => {
44
+ const {
45
+ context,
46
+ focused,
47
+ options,
48
+ label = '',
49
+ selectValue,
50
+ isDisabled,
51
+ isSelected,
52
+ isAppleDevice
53
+ } = props;
54
+ const getArrayIndex = (arr, item) => arr && arr.length ? `${arr.indexOf(item) + 1} of ${arr.length}` : '';
55
+ if (context === 'value' && selectValue) {
56
+ return `value ${label} focused, ${getArrayIndex(selectValue, focused)}.`;
57
+ }
58
+ if (context === 'menu' && isAppleDevice) {
59
+ const disabled = isDisabled ? ' disabled' : '';
60
+ const status = `${isSelected ? ' selected' : ''}${disabled}`;
61
+ return `${label}${status}, ${getArrayIndex(options, focused)}.`;
62
+ }
63
+ return '';
64
+ },
65
+ onFilter: props => {
66
+ const {
67
+ inputValue,
68
+ resultsMessage
69
+ } = props;
70
+ return `${resultsMessage}${inputValue ? ' for search term ' + inputValue : ''}.`;
71
+ }
72
+ };
@@ -0,0 +1,17 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import Select from './select';
4
+ import useAsync from './use-async';
5
+ import useCreatable from './use-creatable';
6
+ import useStateManager from './use-state-manager';
7
+ const AsyncCreatableSelect = /*#__PURE__*/forwardRef((props, ref) => {
8
+ const stateManagerProps = useAsync(props);
9
+ const creatableProps = useStateManager(stateManagerProps);
10
+ const selectProps = useCreatable(creatableProps);
11
+ return /*#__PURE__*/React.createElement(Select, _extends({
12
+ ref: ref
13
+ }, selectProps));
14
+ });
15
+
16
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
17
+ export default AsyncCreatableSelect;
@@ -0,0 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import Select from './select';
4
+ import useAsync from './use-async';
5
+ import useStateManager from './use-state-manager';
6
+ const AsyncSelect = /*#__PURE__*/forwardRef((props, ref) => {
7
+ const stateManagedProps = useAsync(props);
8
+ const selectProps = useStateManager(stateManagedProps);
9
+ return /*#__PURE__*/React.createElement(Select, _extends({
10
+ ref: ref
11
+ }, selectProps));
12
+ });
13
+ export { useAsync };
14
+
15
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
16
+ export default AsyncSelect;
@@ -0,0 +1,4 @@
1
+ export const formatGroupLabel = group => group.label;
2
+ export const getOptionLabel = option => option.label;
3
+ export const getOptionValue = option => option.value;
4
+ export const isOptionDisabled = option => !!option.isDisabled;
@@ -0,0 +1,100 @@
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
+
10
+ // ==============================
11
+ // Root Container
12
+ // ==============================
13
+
14
+ export const containerCSS = ({
15
+ isDisabled,
16
+ isRtl
17
+ }) => ({
18
+ label: 'container',
19
+ direction: isRtl ? 'rtl' : undefined,
20
+ pointerEvents: isDisabled ? 'none' : undefined,
21
+ // cancel mouse events when disabled
22
+ position: 'relative'
23
+ });
24
+
25
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
26
+ export const SelectContainer = props => {
27
+ const {
28
+ children,
29
+ innerProps,
30
+ isDisabled,
31
+ isRtl
32
+ } = props;
33
+ return jsx("div", _extends({}, getStyleProps(props, 'container', {
34
+ '--is-disabled': isDisabled,
35
+ '--is-rtl': isRtl
36
+ }), innerProps), children);
37
+ };
38
+
39
+ // ==============================
40
+ // Value Container
41
+ // ==============================
42
+
43
+ export const valueContainerCSS = ({
44
+ theme: {
45
+ spacing
46
+ },
47
+ isMulti,
48
+ hasValue,
49
+ selectProps: {
50
+ controlShouldRenderValue
51
+ }
52
+ }, unstyled) => ({
53
+ alignItems: 'center',
54
+ display: isMulti && hasValue && controlShouldRenderValue ? 'flex' : 'grid',
55
+ flex: 1,
56
+ flexWrap: 'wrap',
57
+ WebkitOverflowScrolling: 'touch',
58
+ position: 'relative',
59
+ overflow: 'hidden',
60
+ ...(unstyled ? {} : {
61
+ padding: `${spacing.baseUnit / 2}px ${spacing.baseUnit * 2}px`
62
+ })
63
+ });
64
+
65
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
66
+ export const ValueContainer = props => {
67
+ const {
68
+ children,
69
+ innerProps,
70
+ isMulti,
71
+ hasValue
72
+ } = props;
73
+ return jsx("div", _extends({}, getStyleProps(props, 'valueContainer', {
74
+ 'value-container': true,
75
+ 'value-container--is-multi': isMulti,
76
+ 'value-container--has-value': hasValue
77
+ }), innerProps), children);
78
+ };
79
+
80
+ // ==============================
81
+ // Indicator Container
82
+ // ==============================
83
+
84
+ export const indicatorsContainerCSS = () => ({
85
+ alignItems: 'center',
86
+ alignSelf: 'stretch',
87
+ display: 'flex',
88
+ flexShrink: 0
89
+ });
90
+
91
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
92
+ export const IndicatorsContainer = props => {
93
+ const {
94
+ children,
95
+ innerProps
96
+ } = props;
97
+ return jsx("div", _extends({}, getStyleProps(props, 'indicatorsContainer', {
98
+ indicators: true
99
+ }), innerProps), children);
100
+ };
@@ -0,0 +1,62 @@
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
+ isFocused,
12
+ theme: {
13
+ colors,
14
+ borderRadius,
15
+ spacing
16
+ }
17
+ }, unstyled) => ({
18
+ label: 'control',
19
+ alignItems: 'center',
20
+ cursor: 'default',
21
+ display: 'flex',
22
+ flexWrap: 'wrap',
23
+ justifyContent: 'space-between',
24
+ minHeight: spacing.controlHeight,
25
+ outline: '0 !important',
26
+ position: 'relative',
27
+ transition: 'all 100ms',
28
+ ...(unstyled ? {} : {
29
+ backgroundColor: isDisabled ? colors.neutral5 : colors.neutral0,
30
+ borderColor: isDisabled ? colors.neutral10 : isFocused ? colors.primary : colors.neutral20,
31
+ borderRadius: borderRadius,
32
+ borderStyle: 'solid',
33
+ borderWidth: 1,
34
+ boxShadow: isFocused ? `0 0 0 1px ${colors.primary}` : undefined,
35
+ '&:hover': {
36
+ borderColor: isFocused ? colors.primary : colors.neutral30
37
+ }
38
+ })
39
+ });
40
+ const Control = props => {
41
+ const {
42
+ children,
43
+ isDisabled,
44
+ isFocused,
45
+ innerRef,
46
+ innerProps,
47
+ menuIsOpen
48
+ } = props;
49
+ return jsx("div", _extends({
50
+ ref: innerRef
51
+ }, getStyleProps(props, 'control', {
52
+ control: true,
53
+ 'control--is-disabled': isDisabled,
54
+ 'control--is-focused': isFocused,
55
+ 'control--menu-is-open': menuIsOpen
56
+ }), innerProps, {
57
+ "aria-disabled": isDisabled || undefined
58
+ }), children);
59
+ };
60
+
61
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
62
+ export default Control;