@atlaskit/select 16.1.0 → 16.1.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 (66) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/AsyncCreatableSelect.js +0 -5
  3. package/dist/cjs/AsyncSelect.js +0 -5
  4. package/dist/cjs/CheckboxSelect.js +1 -15
  5. package/dist/cjs/CountrySelect.js +20 -29
  6. package/dist/cjs/CreatableSelect.js +0 -5
  7. package/dist/cjs/PopupSelect/PopupSelect.js +36 -113
  8. package/dist/cjs/PopupSelect/components.js +15 -31
  9. package/dist/cjs/PopupSelect/index.js +0 -2
  10. package/dist/cjs/RadioSelect.js +1 -13
  11. package/dist/cjs/Select.js +1 -8
  12. package/dist/cjs/components/index.js +0 -10
  13. package/dist/cjs/components/indicators.js +1 -13
  14. package/dist/cjs/components/input-options.js +43 -84
  15. package/dist/cjs/createSelect.js +12 -42
  16. package/dist/cjs/data/countries.js +3 -2
  17. package/dist/cjs/entry-points/async-creatable-select.js +0 -2
  18. package/dist/cjs/entry-points/async-select.js +0 -2
  19. package/dist/cjs/entry-points/creatable-select.js +0 -2
  20. package/dist/cjs/entry-points/select.js +0 -4
  21. package/dist/cjs/extract-react-types/ert.js +0 -1
  22. package/dist/cjs/extract-react-types/react-popper-props.js +1 -1
  23. package/dist/cjs/extract-react-types/react-select-async.js +1 -1
  24. package/dist/cjs/extract-react-types/react-select-creatable.js +1 -1
  25. package/dist/cjs/extract-react-types/react-select-props.js +1 -1
  26. package/dist/cjs/index.js +0 -16
  27. package/dist/cjs/styles.js +4 -29
  28. package/dist/cjs/version.json +1 -1
  29. package/dist/es2019/CheckboxSelect.js +2 -3
  30. package/dist/es2019/CountrySelect.js +14 -18
  31. package/dist/es2019/PopupSelect/PopupSelect.js +29 -85
  32. package/dist/es2019/PopupSelect/components.js +6 -6
  33. package/dist/es2019/RadioSelect.js +2 -3
  34. package/dist/es2019/Select.js +1 -1
  35. package/dist/es2019/components/indicators.js +0 -1
  36. package/dist/es2019/components/input-options.js +23 -29
  37. package/dist/es2019/createSelect.js +6 -14
  38. package/dist/es2019/data/countries.js +3 -1
  39. package/dist/es2019/extract-react-types/react-popper-props.js +1 -0
  40. package/dist/es2019/extract-react-types/react-select-async.js +1 -0
  41. package/dist/es2019/extract-react-types/react-select-creatable.js +1 -0
  42. package/dist/es2019/extract-react-types/react-select-props.js +1 -0
  43. package/dist/es2019/index.js +1 -0
  44. package/dist/es2019/styles.js +33 -34
  45. package/dist/es2019/version.json +1 -1
  46. package/dist/esm/CheckboxSelect.js +1 -8
  47. package/dist/esm/CountrySelect.js +20 -24
  48. package/dist/esm/PopupSelect/PopupSelect.js +36 -114
  49. package/dist/esm/PopupSelect/components.js +16 -18
  50. package/dist/esm/RadioSelect.js +1 -7
  51. package/dist/esm/Select.js +1 -1
  52. package/dist/esm/components/index.js +0 -2
  53. package/dist/esm/components/indicators.js +0 -1
  54. package/dist/esm/components/input-options.js +43 -72
  55. package/dist/esm/createSelect.js +12 -30
  56. package/dist/esm/data/countries.js +3 -1
  57. package/dist/esm/extract-react-types/react-popper-props.js +1 -0
  58. package/dist/esm/extract-react-types/react-select-async.js +1 -0
  59. package/dist/esm/extract-react-types/react-select-creatable.js +1 -0
  60. package/dist/esm/extract-react-types/react-select-props.js +1 -0
  61. package/dist/esm/index.js +1 -0
  62. package/dist/esm/styles.js +4 -24
  63. package/dist/esm/version.json +1 -1
  64. package/dist/types/index.d.ts +1 -1
  65. package/package.json +1 -1
  66. package/report.api.md +14 -0
@@ -8,45 +8,36 @@ import * as defaultComponents from './components';
8
8
  import baseStyles from './styles';
9
9
  export default function createSelect(WrappedComponent) {
10
10
  var _class;
11
-
12
11
  return _class = class AtlaskitSelect extends Component {
13
12
  constructor(props) {
14
13
  super(props);
15
-
16
14
  _defineProperty(this, "components", {});
17
-
18
15
  _defineProperty(this, "select", null);
19
-
20
16
  _defineProperty(this, "cacheComponents", components => {
21
- this.components = { ...defaultComponents,
17
+ this.components = {
18
+ ...defaultComponents,
22
19
  ...components
23
20
  };
24
21
  });
25
-
26
22
  _defineProperty(this, "onSelectRef", ref => {
27
23
  this.select = ref;
28
24
  });
29
-
30
25
  this.cacheComponents = memoizeOne(this.cacheComponents, isEqual).bind(this);
31
26
  this.cacheComponents(props.components || {});
32
27
  }
33
-
34
28
  UNSAFE_componentWillReceiveProps(nextProps) {
35
29
  this.cacheComponents(nextProps.components);
36
30
  }
37
-
38
31
  focus() {
39
32
  if (this.select) {
40
33
  this.select.focus();
41
34
  }
42
35
  }
43
-
44
36
  blur() {
45
37
  if (this.select) {
46
38
  this.select.blur();
47
39
  }
48
40
  }
49
-
50
41
  render() {
51
42
  const {
52
43
  styles,
@@ -57,19 +48,20 @@ export default function createSelect(WrappedComponent) {
57
48
  appearance,
58
49
  ...props
59
50
  } = this.props;
60
- const isCompact = spacing === 'compact'; // props must be spread first to stop `components` being overridden
51
+ const isCompact = spacing === 'compact';
61
52
 
53
+ // props must be spread first to stop `components` being overridden
62
54
  return /*#__PURE__*/React.createElement(WrappedComponent, _extends({
63
55
  ref: this.onSelectRef,
64
56
  isMulti: isMulti,
65
57
  "aria-live": "assertive"
66
58
  }, props, {
67
59
  components: this.components,
68
- styles: mergeStyles(baseStyles( // This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
60
+ styles: mergeStyles(baseStyles(
61
+ // This will cover both props for invalid state while giving priority to isInvalid. When cleaning up validationState, we can just keep the inner condition.
69
62
  typeof isInvalid !== 'undefined' ? isInvalid ? 'error' : 'default' : validationState, isCompact, this.props.appearance || 'default'), styles)
70
63
  }));
71
64
  }
72
-
73
65
  }, _defineProperty(_class, "defaultProps", {
74
66
  validationState: 'default',
75
67
  // TODO: uncomment the next line when cleaning up validationState prop so it has a default value
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
+
2
3
  export const allCountries = [{
3
4
  icon: '🇦🇫',
4
5
  name: 'Afghanistan',
@@ -1245,8 +1246,9 @@ export const allCountries = [{
1245
1246
  name: 'Zimbabwe',
1246
1247
  abbr: 'ZW',
1247
1248
  code: '263'
1248
- }]; // separate countries into groups
1249
+ }];
1249
1250
 
1251
+ // separate countries into groups
1250
1252
  export const groupedCountries = [{
1251
1253
  label: 'Suggested',
1252
1254
  options: allCountries.filter(c => c.suggested)
@@ -1,2 +1,3 @@
1
1
  // this is to DOCUMENT/display the underlying react popper props, for our atlaskit/select documentation
2
+
2
3
  export default function ertHackForPopper(_) {}
@@ -1,2 +1,3 @@
1
1
  // for documentation ONLY
2
+
2
3
  export default function ertHackForPopper(_) {}
@@ -1,2 +1,3 @@
1
1
  // for documentation purposes ONLY
2
+
2
3
  export default function ertHackForSelect(_) {}
@@ -1,2 +1,3 @@
1
1
  // this is to DOCUMENT/display the underlying react select props, for our atlaskit/select documentation
2
+
2
3
  export default function ertHackForSelect(_) {}
@@ -10,6 +10,7 @@ export { default as CheckboxSelect } from './CheckboxSelect';
10
10
  export { default as CountrySelect } from './CountrySelect';
11
11
  export { default as RadioSelect } from './RadioSelect';
12
12
  export { default as PopupSelect } from './PopupSelect';
13
+
13
14
  /**
14
15
  * Types not exported on the public API, didn't find usages in sourcegraph
15
16
  *
@@ -7,14 +7,16 @@ export default function baseStyles(validationState, isCompact = false, appearanc
7
7
  return {
8
8
  container: (css, {
9
9
  isDisabled
10
- }) => ({ ...css,
10
+ }) => ({
11
+ ...css,
11
12
  fontFamily: fontFamily(),
12
13
  // react-select disables pointer events when isDisabled is true.
13
14
  // We override this and make the inner container turn it off instead.
14
15
  pointerEvents: 'all',
15
16
  cursor: isDisabled ? 'not-allowed' : css.cursor
16
17
  }),
17
- input: css => ({ ...css,
18
+ input: css => ({
19
+ ...css,
18
20
  color: "var(--ds-text, hsl(0, 0%, 20%))"
19
21
  }),
20
22
  control: (css, {
@@ -24,46 +26,37 @@ export default function baseStyles(validationState, isCompact = false, appearanc
24
26
  let borderColor = isFocused ? `var(--ds-border-focused, ${B100})` : `var(--ds-border-input, ${N20})`;
25
27
  let backgroundColor = isFocused ? `var(--ds-background-input-pressed, ${N0})` : `var(--ds-background-input, ${N20})`;
26
28
  let backgroundColorHover = isFocused ? `var(--ds-background-input-pressed, ${N0})` : `var(--ds-background-input-hovered, ${N30})`;
27
-
28
29
  if (isDisabled) {
29
30
  backgroundColor = `var(--ds-background-disabled, ${N20})`;
30
31
  borderColor = `var(--ds-background-disabled, ${N20})`;
31
32
  }
32
-
33
33
  if (validationState === 'error') {
34
34
  borderColor = `var(--ds-border-danger, ${R400})`;
35
35
  }
36
-
37
36
  if (validationState === 'success') {
38
37
  borderColor = `var(--ds-border-success, ${G400})`;
39
38
  }
40
-
41
39
  let borderColorHover = isFocused ? `var(--ds-border-focused, ${B100})` : `var(--ds-border-input, ${N30})`;
42
-
43
40
  if (validationState === 'error') {
44
41
  borderColorHover = `var(--ds-border-danger, ${R400})`;
45
42
  }
46
-
47
43
  if (validationState === 'success') {
48
44
  borderColorHover = `var(--ds-border-success, ${G400})`;
49
45
  }
50
-
51
46
  const transitionDuration = '200ms';
52
-
53
47
  if (appearance === 'subtle') {
54
48
  borderColor = isFocused ? `var(--ds-border-focused, ${B100})` : 'transparent';
55
49
  backgroundColor = isFocused ? `var(--ds-surface, ${N0})` : 'transparent';
56
50
  backgroundColorHover = isFocused ? `var(--ds-background-input-pressed, ${N0})` : `var(--ds-background-input-hovered, ${N30})`;
57
51
  }
58
-
59
52
  if (appearance === 'none') {
60
53
  borderColor = 'transparent';
61
54
  backgroundColor = 'transparent';
62
55
  backgroundColorHover = 'transparent';
63
56
  borderColorHover = 'transparent';
64
57
  }
65
-
66
- return { ...css,
58
+ return {
59
+ ...css,
67
60
  // Turn pointer events off when disabled - this makes it so hover etc don't work.
68
61
  pointerEvents: isDisabled ? 'none' : undefined,
69
62
  backgroundColor,
@@ -99,13 +92,15 @@ export default function baseStyles(validationState, isCompact = false, appearanc
99
92
  }
100
93
  };
101
94
  },
102
- valueContainer: css => ({ ...css,
95
+ valueContainer: css => ({
96
+ ...css,
103
97
  paddingLeft: paddingExcludingBorder,
104
98
  paddingRight: paddingExcludingBorder,
105
99
  paddingBottom: isCompact ? 0 : 2,
106
100
  paddingTop: isCompact ? 0 : 2
107
101
  }),
108
- clearIndicator: css => ({ ...css,
102
+ clearIndicator: css => ({
103
+ ...css,
109
104
  color: `var(--ds-text-subtlest, ${N70})`,
110
105
  paddingLeft: ICON_PADDING,
111
106
  paddingRight: ICON_PADDING,
@@ -115,7 +110,8 @@ export default function baseStyles(validationState, isCompact = false, appearanc
115
110
  color: `var(--ds-text-subtle, ${N500})`
116
111
  }
117
112
  }),
118
- loadingIndicator: css => ({ ...css,
113
+ loadingIndicator: css => ({
114
+ ...css,
119
115
  paddingBottom: isCompact ? 0 : 6,
120
116
  paddingTop: isCompact ? 0 : 6
121
117
  }),
@@ -123,12 +119,11 @@ export default function baseStyles(validationState, isCompact = false, appearanc
123
119
  isDisabled
124
120
  }) => {
125
121
  let color = `var(--ds-text-subtle, ${N500})`;
126
-
127
122
  if (isDisabled) {
128
123
  color = `var(--ds-text-disabled, ${N70})`;
129
124
  }
130
-
131
- return { ...css,
125
+ return {
126
+ ...css,
132
127
  color,
133
128
  paddingLeft: ICON_PADDING,
134
129
  paddingRight: ICON_PADDING,
@@ -139,7 +134,8 @@ export default function baseStyles(validationState, isCompact = false, appearanc
139
134
  }
140
135
  };
141
136
  },
142
- indicatorsContainer: css => ({ ...css,
137
+ indicatorsContainer: css => ({
138
+ ...css,
143
139
  paddingRight: paddingExcludingBorder - ICON_PADDING
144
140
  }),
145
141
  option: (css, {
@@ -148,16 +144,13 @@ export default function baseStyles(validationState, isCompact = false, appearanc
148
144
  isDisabled
149
145
  }) => {
150
146
  let color = `var(--ds-text, ${N800})`;
151
-
152
147
  if (isDisabled) {
153
148
  color = `var(--ds-text-disabled, ${N70})`;
154
149
  } else if (isSelected) {
155
150
  color = `var(--ds-text-selected, ${B400})`;
156
151
  }
157
-
158
152
  let boxShadow;
159
153
  let backgroundColor;
160
-
161
154
  if (isDisabled) {
162
155
  backgroundColor = undefined;
163
156
  } else if (isSelected && isFocused) {
@@ -167,13 +160,12 @@ export default function baseStyles(validationState, isCompact = false, appearanc
167
160
  } else if (isFocused) {
168
161
  backgroundColor = `var(--ds-background-neutral-subtle-hovered, ${N20})`;
169
162
  }
170
-
171
163
  if (!isDisabled && (isFocused || isSelected)) {
172
164
  boxShadow = `inset 2px 0px 0px ${`var(--ds-border-selected, ${B400})`}`;
173
165
  }
174
-
175
166
  const cursor = isDisabled ? 'not-allowed' : css.cursor;
176
- return { ...css,
167
+ return {
168
+ ...css,
177
169
  padding: '6px 12px',
178
170
  backgroundColor,
179
171
  color,
@@ -189,27 +181,32 @@ export default function baseStyles(validationState, isCompact = false, appearanc
189
181
  },
190
182
  placeholder: (css, {
191
183
  isDisabled
192
- }) => ({ ...css,
184
+ }) => ({
185
+ ...css,
193
186
  color: isDisabled ? `var(--ds-text-disabled, ${N300})` : `var(--ds-text-subtlest, ${N300})`
194
187
  }),
195
188
  singleValue: (css, {
196
189
  isDisabled
197
- }) => ({ ...css,
190
+ }) => ({
191
+ ...css,
198
192
  color: isDisabled ? `var(--ds-text-disabled, ${N70})` : `var(--ds-text, ${N800})`,
199
193
  lineHeight: `${gridSize() * 2}px` // 16px
200
-
201
194
  }),
202
- menu: css => ({ ...css,
195
+
196
+ menu: css => ({
197
+ ...css,
203
198
  backgroundColor: "var(--ds-surface-overlay, white)",
204
199
  boxShadow: "var(--ds-shadow-overlay, 0 0 0 1px hsl(0deg 0% 0% / 10%), 0 4px 11px hsl(0deg 0% 0% / 10%))"
205
200
  }),
206
- menuList: css => ({ ...css,
201
+ menuList: css => ({
202
+ ...css,
207
203
  paddingTop: gridSize(),
208
204
  paddingBottom: gridSize()
209
205
  }),
210
206
  multiValue: (css, {
211
207
  isFocused
212
- }) => ({ ...css,
208
+ }) => ({
209
+ ...css,
213
210
  borderRadius: '2px',
214
211
  backgroundColor: isFocused ? `var(--ds-background-selected, ${N40})` : `var(--ds-background-neutral, ${N40})`,
215
212
  boxShadow: isFocused ? `0 0 0 2px ${"var(--ds-surface, transparent)"}, 0 0 0 4px ${"var(--ds-border-focused, transparent)"}` : 'none',
@@ -219,14 +216,16 @@ export default function baseStyles(validationState, isCompact = false, appearanc
219
216
  },
220
217
  color: isFocused ? "var(--ds-text-selected, hsl(0, 0%, 20%))" : "var(--ds-text, hsl(0, 0%, 20%))"
221
218
  }),
222
- multiValueLabel: css => ({ ...css,
219
+ multiValueLabel: css => ({
220
+ ...css,
223
221
  padding: '2px',
224
222
  color: 'inherit',
225
223
  paddingRight: '2px'
226
224
  }),
227
225
  multiValueRemove: (css, {
228
226
  isFocused
229
- }) => ({ ...css,
227
+ }) => ({
228
+ ...css,
230
229
  backgroundColor: isFocused ? `var(--ds-UNSAFE_util-transparent, ${R75})` : undefined,
231
230
  fill: isFocused ? "var(--ds-text-selected, #000)" : "var(--ds-text, #000)",
232
231
  paddingLeft: '2px',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/select",
3
- "version": "16.1.0",
3
+ "version": "16.1.2",
4
4
  "sideEffects": false
5
5
  }
@@ -2,23 +2,17 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["components"];
5
-
6
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
-
8
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
-
10
7
  import React from 'react';
11
8
  import Select from './Select';
12
9
  import { CheckboxOption } from './components/input-options';
13
-
14
10
  var CheckboxSelect = function CheckboxSelect(_ref) {
15
11
  var components = _ref.components,
16
- props = _objectWithoutProperties(_ref, _excluded);
17
-
12
+ props = _objectWithoutProperties(_ref, _excluded);
18
13
  var temp = _objectSpread(_objectSpread({}, components), {}, {
19
14
  Option: CheckboxOption
20
15
  });
21
-
22
16
  return /*#__PURE__*/React.createElement(Select, _extends({
23
17
  closeMenuOnSelect: false,
24
18
  hideSelectedOptions: false,
@@ -26,5 +20,4 @@ var CheckboxSelect = function CheckboxSelect(_ref) {
26
20
  components: temp
27
21
  }, props));
28
22
  };
29
-
30
23
  export default CheckboxSelect;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { jsx, css } from '@emotion/react';
5
5
  import { groupedCountries } from './data/countries';
6
6
  import Select from './Select';
@@ -12,46 +12,43 @@ var labelStyles = css({
12
12
  });
13
13
  var flagStyles = css({
14
14
  fontSize: '18px',
15
- // TODO Delete this comment after verifying spacing token -> previous value `'8px'`
16
- marginRight: "var(--ds-scale-100, 8px)"
15
+ marginRight: "var(--ds-space-100, 8px)"
17
16
  });
18
-
19
17
  var Opt = function Opt(_ref) {
20
18
  var children = _ref.children,
21
- icon = _ref.icon;
19
+ icon = _ref.icon;
22
20
  return jsx("div", {
23
21
  css: labelStyles
24
22
  }, jsx("span", {
25
23
  css: flagStyles
26
24
  }, icon), children);
27
- }; // return the country name; used for searching
28
-
25
+ };
29
26
 
27
+ // return the country name; used for searching
30
28
  var getOptionLabel = function getOptionLabel(_ref2) {
31
29
  var abbr = _ref2.abbr,
32
- code = _ref2.code,
33
- name = _ref2.name;
30
+ code = _ref2.code,
31
+ name = _ref2.name;
34
32
  return "".concat(name, " (").concat(abbr.toUpperCase(), ") +").concat(code);
35
- }; // set the country's abbreviation for the option value, (also searchable)
36
-
33
+ };
37
34
 
35
+ // set the country's abbreviation for the option value, (also searchable)
38
36
  var getOptionValue = function getOptionValue(opt) {
39
37
  return opt.abbr;
40
- }; // the text node of the control
41
-
38
+ };
42
39
 
40
+ // the text node of the control
43
41
  var controlLabel = function controlLabel(opt) {
44
42
  return jsx(Opt, {
45
43
  icon: opt.icon
46
44
  }, opt.abbr.toUpperCase());
47
- }; // the text node for an option
48
-
49
-
45
+ };
46
+ // the text node for an option
50
47
  var optionLabel = function optionLabel(_ref3) {
51
48
  var abbr = _ref3.abbr,
52
- code = _ref3.code,
53
- icon = _ref3.icon,
54
- name = _ref3.name;
49
+ code = _ref3.code,
50
+ icon = _ref3.icon,
51
+ name = _ref3.name;
55
52
  return jsx(Opt, {
56
53
  icon: icon
57
54
  }, getOptionLabel({
@@ -59,15 +56,15 @@ var optionLabel = function optionLabel(_ref3) {
59
56
  code: code,
60
57
  name: name
61
58
  }));
62
- }; // switch formatters based on render context (menu | value)
63
-
59
+ };
64
60
 
61
+ // switch formatters based on render context (menu | value)
65
62
  var formatOptionLabel = function formatOptionLabel(opt, _ref4) {
66
63
  var context = _ref4.context;
67
64
  return context === 'value' ? controlLabel(opt) : optionLabel(opt);
68
- }; // put it all together
69
-
65
+ };
70
66
 
67
+ // put it all together
71
68
  var CountrySelect = function CountrySelect(props) {
72
69
  return jsx(Select, _extends({
73
70
  isClearable: false,
@@ -78,5 +75,4 @@ var CountrySelect = function CountrySelect(props) {
78
75
  options: groupedCountries
79
76
  }, props));
80
77
  };
81
-
82
78
  export default CountrySelect;