@automattic/vip-design-system 0.27.4 → 0.27.5

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.
@@ -29,9 +29,11 @@ var _Label = require("../Form/Label");
29
29
 
30
30
  var _FormSelectSearch = require("./FormSelectSearch");
31
31
 
32
+ var _FormSelectLoading = require("./FormSelectLoading");
33
+
32
34
  var _jsxRuntime = require("theme-ui/jsx-runtime");
33
35
 
34
- var _excluded = ["isInline", "forLabel", "options", "label", "getOptionLabel", "getOptionValue", "onChange", "onInputChange", "value", "showAllValues", "searchIcon", "displayMenu", "noOptionsMessage", "id", "className"];
36
+ var _excluded = ["isInline", "forLabel", "options", "label", "getOptionLabel", "getOptionValue", "onChange", "onInputChange", "value", "showAllValues", "searchIcon", "loading", "displayMenu", "noOptionsMessage", "id", "className"];
35
37
 
36
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
39
 
@@ -146,6 +148,8 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
146
148
  showAllValues = _ref$showAllValues === void 0 ? true : _ref$showAllValues,
147
149
  _ref$searchIcon = _ref.searchIcon,
148
150
  searchIcon = _ref$searchIcon === void 0 ? false : _ref$searchIcon,
151
+ _ref$loading = _ref.loading,
152
+ loading = _ref$loading === void 0 ? false : _ref$loading,
149
153
  _ref$displayMenu = _ref.displayMenu,
150
154
  displayMenu = _ref$displayMenu === void 0 ? 'overlay' : _ref$displayMenu,
151
155
  _ref$noOptionsMessage = _ref.noOptionsMessage,
@@ -229,6 +233,7 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
229
233
  label: inlineLabel ? (0, _jsxRuntime.jsx)(SelectLabel, {}) : null,
230
234
  children: [searchIcon && (0, _jsxRuntime.jsx)(_FormSelectSearch.FormSelectSearch, {}), (0, _jsxRuntime.jsx)(_react2["default"], (0, _extends2["default"])({
231
235
  id: id,
236
+ "aria-busy": loading,
232
237
  showAllValues: showAllValues,
233
238
  ref: forwardRef,
234
239
  source: suggest,
@@ -236,7 +241,7 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
236
241
  displayMenu: displayMenu,
237
242
  onConfirm: onValueChange,
238
243
  tNoResults: noOptionsMessage
239
- }, props)), (0, _jsxRuntime.jsx)(_FormSelectArrow.FormSelectArrow, {})]
244
+ }, props)), loading && (0, _jsxRuntime.jsx)(_FormSelectLoading.FormSelectLoading, {}), (0, _jsxRuntime.jsx)(_FormSelectArrow.FormSelectArrow, {})]
240
245
  })
241
246
  })]
242
247
  });
@@ -247,6 +252,7 @@ FormAutocomplete.propTypes = {
247
252
  id: _propTypes["default"].string,
248
253
  showAllValues: _propTypes["default"].bool,
249
254
  searchIcon: _propTypes["default"].bool,
255
+ loading: _propTypes["default"].bool,
250
256
  isInline: _propTypes["default"].bool,
251
257
  forLabel: _propTypes["default"].string,
252
258
  value: _propTypes["default"].string,
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
- exports["default"] = exports.WithSearchIcon = exports.WithDefaultValue = exports.WithCustomMessages = exports.Inline = exports.Default = void 0;
6
+ exports["default"] = exports.WithSearchIcon = exports.WithLoading = exports.WithDefaultValue = exports.WithCustomMessages = exports.Inline = exports.Default = void 0;
7
7
 
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
 
@@ -120,6 +120,17 @@ var WithSearchIcon = function WithSearchIcon() {
120
120
 
121
121
  exports.WithSearchIcon = WithSearchIcon;
122
122
 
123
+ var WithLoading = function WithLoading() {
124
+ var customArgs = (0, _extends2["default"])({}, args, {
125
+ loading: true
126
+ });
127
+ return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
128
+ children: (0, _jsxRuntime.jsx)(DefaultComponent, (0, _extends2["default"])({}, customArgs))
129
+ });
130
+ };
131
+
132
+ exports.WithLoading = WithLoading;
133
+
123
134
  var WithCustomMessages = function WithCustomMessages() {
124
135
  var customArgs = (0, _extends2["default"])({}, args, {
125
136
  noOptionsMessage: function noOptionsMessage() {
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.FormSelectLoading = void 0;
7
+
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _ai = require("react-icons/ai");
13
+
14
+ var _react2 = require("@emotion/react");
15
+
16
+ var _jsxRuntime = require("theme-ui/jsx-runtime");
17
+
18
+ /** @jsxImportSource theme-ui */
19
+
20
+ /**
21
+ * External dependencies
22
+ */
23
+ var kf = (0, _react2.keyframes)({
24
+ from: {
25
+ transform: 'rotate(0deg)'
26
+ },
27
+ to: {
28
+ transform: 'rotate(360deg) '
29
+ }
30
+ });
31
+
32
+ var FormSelectLoading = /*#__PURE__*/_react["default"].forwardRef(function (props, forwardRef) {
33
+ return (0, _jsxRuntime.jsx)(_ai.AiOutlineLoading3Quarters, (0, _extends2["default"])({
34
+ ref: forwardRef,
35
+ "aria-hidden": "true",
36
+ size: 18,
37
+ sx: {
38
+ position: 'absolute',
39
+ right: 40,
40
+ pointerEvents: 'none',
41
+ animation: kf + " 1s infinite linear",
42
+ opacity: 0.5
43
+ }
44
+ }, props));
45
+ });
46
+
47
+ exports.FormSelectLoading = FormSelectLoading;
48
+ FormSelectLoading.displayName = 'FormSelectLoading';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "0.27.4",
3
+ "version": "0.27.5",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "build-storybook",
@@ -16,6 +16,7 @@ import { FormSelectContent } from './FormSelectContent';
16
16
  import { FormSelectArrow } from './FormSelectArrow';
17
17
  import { Label } from '../Form/Label';
18
18
  import { FormSelectSearch } from './FormSelectSearch';
19
+ import { FormSelectLoading } from './FormSelectLoading';
19
20
 
20
21
  const defaultStyles = {
21
22
  width: '100%',
@@ -105,6 +106,7 @@ const FormAutocomplete = React.forwardRef(
105
106
  value,
106
107
  showAllValues = true,
107
108
  searchIcon = false,
109
+ loading = false,
108
110
  displayMenu = 'overlay',
109
111
  noOptionsMessage = () => 'No results found.',
110
112
  id = 'vip-autocomplete',
@@ -203,6 +205,7 @@ const FormAutocomplete = React.forwardRef(
203
205
  { searchIcon && <FormSelectSearch /> }
204
206
  <Autocomplete
205
207
  id={ id }
208
+ aria-busy={ loading }
206
209
  showAllValues={ showAllValues }
207
210
  ref={ forwardRef }
208
211
  source={ suggest }
@@ -212,6 +215,7 @@ const FormAutocomplete = React.forwardRef(
212
215
  tNoResults={ noOptionsMessage }
213
216
  { ...props }
214
217
  />
218
+ { loading && <FormSelectLoading /> }
215
219
  <FormSelectArrow />
216
220
  </FormSelectContent>
217
221
  </div>
@@ -224,6 +228,7 @@ FormAutocomplete.propTypes = {
224
228
  id: PropTypes.string,
225
229
  showAllValues: PropTypes.bool,
226
230
  searchIcon: PropTypes.bool,
231
+ loading: PropTypes.bool,
227
232
  isInline: PropTypes.bool,
228
233
  forLabel: PropTypes.string,
229
234
  value: PropTypes.string,
@@ -88,6 +88,19 @@ export const WithSearchIcon = () => {
88
88
  );
89
89
  };
90
90
 
91
+ export const WithLoading = () => {
92
+ const customArgs = {
93
+ ...args,
94
+ loading: true,
95
+ };
96
+
97
+ return (
98
+ <>
99
+ <DefaultComponent { ...customArgs } />
100
+ </>
101
+ );
102
+ };
103
+
91
104
  export const WithCustomMessages = () => {
92
105
  const customArgs = {
93
106
  ...args,
@@ -0,0 +1,31 @@
1
+ /** @jsxImportSource theme-ui */
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ import React from 'react';
7
+ import { AiOutlineLoading3Quarters } from 'react-icons/ai';
8
+ import { keyframes } from '@emotion/react';
9
+
10
+ const kf = keyframes( {
11
+ from: { transform: 'rotate(0deg)' },
12
+ to: { transform: 'rotate(360deg) ' },
13
+ } );
14
+
15
+ export const FormSelectLoading = React.forwardRef( ( props, forwardRef ) => (
16
+ <AiOutlineLoading3Quarters
17
+ ref={ forwardRef }
18
+ aria-hidden="true"
19
+ size={ 18 }
20
+ sx={ {
21
+ position: 'absolute',
22
+ right: 40,
23
+ pointerEvents: 'none',
24
+ animation: `${ kf } 1s infinite linear`,
25
+ opacity: 0.5,
26
+ } }
27
+ { ...props }
28
+ />
29
+ ) );
30
+
31
+ FormSelectLoading.displayName = 'FormSelectLoading';