@cashub/ui 0.9.6 → 0.9.8

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.
@@ -75,8 +75,6 @@ var ImageDropzone = function ImageDropzone(_ref) {
75
75
  addedFiles = _useState6[0],
76
76
  setAddedFiles = _useState6[1];
77
77
 
78
- var refWrapper = (0, _react.useRef)(null);
79
-
80
78
  var _useState7 = (0, _react.useState)(false),
81
79
  _useState8 = _slicedToArray(_useState7, 2),
82
80
  focus = _useState8[0],
@@ -103,7 +101,7 @@ var ImageDropzone = function ImageDropzone(_ref) {
103
101
  var handleDragLeave = function handleDragLeave(event) {
104
102
  event.preventDefault();
105
103
  event.stopPropagation();
106
- if (files.length < maxFiles) setDragging(false);
104
+ setDragging(false);
107
105
  };
108
106
 
109
107
  var handleDrop = function handleDrop(event) {
@@ -225,7 +223,10 @@ var ImageDropzone = function ImageDropzone(_ref) {
225
223
 
226
224
  var handleBlur = function handleBlur() {
227
225
  if (focus) {
228
- onBlur();
226
+ if (onBlur) {
227
+ onBlur();
228
+ }
229
+
229
230
  setFocus(false);
230
231
  }
231
232
  };
@@ -256,6 +257,8 @@ var ImageDropzone = function ImageDropzone(_ref) {
256
257
  })]
257
258
  });
258
259
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, {
260
+ tabIndex: "-1",
261
+ dragging: dragging,
259
262
  onClick: handleClick,
260
263
  onDragEnter: handleDragEnter,
261
264
  onDragLeave: handleDragLeave,
@@ -266,8 +269,6 @@ var ImageDropzone = function ImageDropzone(_ref) {
266
269
  onFocus: function onFocus() {
267
270
  setFocus(true);
268
271
  },
269
- ref: refWrapper,
270
- tabIndex: "-1",
271
272
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_HiddenFileInput.default, {
272
273
  multiple: true,
273
274
  ref: inputRef,
@@ -277,9 +278,12 @@ var ImageDropzone = function ImageDropzone(_ref) {
277
278
  });
278
279
  };
279
280
 
280
- var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-height: 200px;\n border: 4px dashed var(--border-color);\n border-radius: var(--border-radius-l);\n color: var(--font-on-primary);\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n padding: var(--spacing-xs);\n cursor: ", ";\n"])), function (_ref2) {
281
+ var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-height: 200px;\n border: 4px dashed var(--border-color);\n border-radius: var(--border-radius-l);\n color: var(--font-on-primary);\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n padding: var(--spacing-xs);\n cursor: ", ";\n\n ", ";\n\n &:focus {\n border-color: var(--color-primary);\n }\n"])), function (_ref2) {
281
282
  var reachedLimit = _ref2.reachedLimit;
282
283
  return reachedLimit ? 'default' : 'pointer';
284
+ }, function (_ref3) {
285
+ var dragging = _ref3.dragging;
286
+ return dragging && 'border-color: var(--color-primary);';
283
287
  });
284
288
 
285
289
  var Image = _styledComponents.default.figure(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 180px;\n height: 320px;\n position: relative;\n margin: var(--spacing-xs);\n\n > img {\n width: 100%;\n height: 100%;\n border-radius: var(--border-radius);\n }\n"])));
@@ -290,8 +294,8 @@ var Button = _styledComponents.default.div.attrs(function () {
290
294
  return {
291
295
  role: 'button'
292
296
  };
293
- })(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n width: 32px;\n height: 32px;\n color: var(--color-white);\n background: var(--color-primary);\n border-radius: var(--border-radius-round);\n cursor: pointer;\n\n > svg {\n color: var(--color-white);\n margin: 0 auto;\n position: relative;\n top: 50%;\n transform: translateY(-50%);\n margin: 0 auto;\n display: block;\n }\n\n &:not(:first-child) {\n margin-left: var(--spacing-xs);\n }\n\n ", "\n"])), function (_ref3) {
294
- var danger = _ref3.danger;
297
+ })(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n width: 32px;\n height: 32px;\n color: var(--color-white);\n background: var(--color-primary);\n border-radius: var(--border-radius-round);\n cursor: pointer;\n\n > svg {\n color: var(--color-white);\n margin: 0 auto;\n position: relative;\n top: 50%;\n transform: translateY(-50%);\n margin: 0 auto;\n display: block;\n }\n\n &:not(:first-child) {\n margin-left: var(--spacing-xs);\n }\n\n ", "\n"])), function (_ref4) {
298
+ var danger = _ref4.danger;
295
299
  return danger && 'background: var(--color-danger);';
296
300
  });
297
301
 
@@ -154,22 +154,22 @@ var UploadImage = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
154
154
  });
155
155
  }, [cropperHandler, handleImageFile]);
156
156
 
157
- var handleFocus = function handleFocus(e) {
158
- e.preventDefault();
159
- e.stopPropagation();
157
+ var handleFocus = function handleFocus(event) {
158
+ event.preventDefault();
159
+ event.stopPropagation();
160
160
 
161
- if (e.target.tagName === 'BUTTON') {
161
+ if (event.target.tagName === 'BUTTON') {
162
162
  setFocusCount(focusCount + 1);
163
163
  }
164
164
  };
165
165
 
166
- var handleBlur = function handleBlur(e) {
167
- e.preventDefault();
168
- e.stopPropagation(); // if click figure,after click button
166
+ var handleBlur = function handleBlur(event) {
167
+ event.preventDefault();
168
+ event.stopPropagation(); // if click figure,after click button
169
169
 
170
- if (refWrapper.current.contains(e.relatedTarget)) return;
170
+ if (refWrapper.current.contains(event.relatedTarget)) return;
171
171
 
172
- if (e.target === refWrapper.current && onBlur) {
172
+ if (event.target === refWrapper.current && onBlur) {
173
173
  onBlur();
174
174
  }
175
175
  };
@@ -215,8 +215,8 @@ var UploadImage = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
215
215
  ref: ref && ref,
216
216
  id: id,
217
217
  accept: ".jpeg, .bmp, .jpg, .png",
218
- onChange: function onChange(e) {
219
- return handleOnChange(e.target.files);
218
+ onChange: function onChange(event) {
219
+ return handleOnChange(event.target.files);
220
220
  }
221
221
  }), ref && ref.current && ref.current.files && ref.current.files.length !== 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(RemoveIcon, {
222
222
  onClick: handleAvatarRemove,
@@ -31,6 +31,18 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
31
31
 
32
32
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
33
33
 
34
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
35
+
36
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
37
+
38
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
39
+
40
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
41
+
42
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
43
+
44
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
45
+
34
46
  var eventHandlers = {
35
47
  onEdited: 'draw:edited',
36
48
  onDrawStart: 'draw:drawstart',
@@ -57,9 +69,9 @@ var DrawControl = function DrawControl(props) {
57
69
 
58
70
  var drawRef = (0, _react.useRef)();
59
71
  var propsRef = (0, _react.useRef)(props);
60
- var onDrawCreate = (0, _react.useCallback)(function (e) {
72
+ var onDrawCreate = (0, _react.useCallback)(function (event) {
61
73
  var container = layerContainer;
62
- container.addLayer(e.layer);
74
+ container.addLayer(event.layer);
63
75
  }, [layerContainer]);
64
76
  var enableEdit = (0, _react.useCallback)(function () {
65
77
  // programatically enable edit mode
@@ -85,7 +97,9 @@ var DrawControl = function DrawControl(props) {
85
97
  });
86
98
 
87
99
  if (handlers.length === 1) {
88
- var handler = handlers[0];
100
+ var _handlers = _slicedToArray(handlers, 1),
101
+ handler = _handlers[0];
102
+
89
103
  props[handler] && props[handler](evt);
90
104
  }
91
105
  });
package/map/LeafletMap.js CHANGED
@@ -94,26 +94,29 @@ var LeafletMap = function LeafletMap(_ref) {
94
94
  return;
95
95
  }
96
96
 
97
- locations.forEach(function (e, index) {
98
- if (!e.latitude && e.latitude !== 0 || !e.longitude && e.longitude !== 0 || e.latitude === 0 && e.longitude === 0 || e.latitude === '0' && e.longitude === '0') {
97
+ locations.forEach(function (location, index) {
98
+ var latitude = location.latitude,
99
+ longitude = location.longitude;
100
+
101
+ if (!latitude && latitude !== 0 || !longitude && longitude !== 0 || latitude === 0 && longitude === 0 || latitude === '0' && longitude === '0') {
99
102
  return;
100
103
  } // prevent duplicate LatLngBounds
101
104
 
102
105
 
103
106
  if (!bounds.some(function (LatLng) {
104
- return e.latitude === LatLng[0] && e.longitude === LatLng[1];
107
+ return latitude === LatLng[0] && longitude === LatLng[1];
105
108
  })) {
106
- bounds.push([e.latitude, e.longitude]);
109
+ bounds.push([latitude, longitude]);
107
110
  }
108
111
 
109
- arrLatLngs.push([e.latitude, e.longitude]);
112
+ arrLatLngs.push([latitude, longitude]);
110
113
  var popupContent = null;
111
114
 
112
115
  if (customPopup) {
113
116
  popupContent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactLeaflet.Popup, {
114
117
  maxWidth: 400,
115
118
  closeButton: false,
116
- children: customPopup(e)
119
+ children: customPopup(location)
117
120
  });
118
121
  }
119
122
 
@@ -122,7 +125,7 @@ var LeafletMap = function LeafletMap(_ref) {
122
125
  iconSize: [40, 50]
123
126
  });
124
127
 
125
- if (checkPrimaryLocation && checkPrimaryLocation(e)) {
128
+ if (checkPrimaryLocation && checkPrimaryLocation(location)) {
126
129
  Icon = _leaflet.default.icon({
127
130
  iconUrl: _map_icon.default,
128
131
  iconSize: [40, 50]
@@ -130,7 +133,7 @@ var LeafletMap = function LeafletMap(_ref) {
130
133
  }
131
134
 
132
135
  markers.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactLeaflet.Marker, {
133
- position: [e.latitude, e.longitude],
136
+ position: [latitude, longitude],
134
137
  icon: Icon,
135
138
  children: popupContent
136
139
  }, index));
@@ -188,8 +191,8 @@ var MapInteractor = function MapInteractor(_ref2) {
188
191
  defaultPosition = _ref2.defaultPosition,
189
192
  position = _ref2.position;
190
193
  var map = (0, _reactLeaflet.useMapEvents)({
191
- click: function click(e) {
192
- e.originalEvent.stopPropagation();
194
+ click: function click(event) {
195
+ event.originalEvent.stopPropagation();
193
196
  },
194
197
  focus: function focus() {
195
198
  map.scrollWheelZoom.enable();
@@ -129,7 +129,9 @@ var ModalContent = function ModalContent(_ref2) {
129
129
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
130
130
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(Body, {
131
131
  type: type,
132
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Title, {
132
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
133
+ role: "img"
134
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Title, {
133
135
  children: title
134
136
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Message, {
135
137
  children: text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cashub/ui",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "private": false,
5
5
  "author": "CASHUB Team",
6
6
  "description": "CASHUB UI components library",
@@ -16,6 +16,8 @@
16
16
  "@yaireo/tagify": "^4.12.0",
17
17
  "chart.js": "^3.8.0",
18
18
  "cropperjs": "^1.5.12",
19
+ "jsoneditor": "^9.8.0",
20
+ "jsoneditor-react": "^3.1.2",
19
21
  "leaflet": "^1.7.1",
20
22
  "leaflet-draw": "^1.0.4",
21
23
  "lodash.uniqueid": "^4.0.1",
@@ -15,7 +15,7 @@ var _hooks = require("@cashub/hooks");
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
18
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
19
19
 
20
20
  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); }
21
21
 
@@ -91,20 +91,19 @@ var Container = _styledComponents.default.ul(_templateObject || (_templateObject
91
91
  return alignRight && 'justify-content: flex-end';
92
92
  });
93
93
 
94
- var Link = _styledComponents.default.li(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 36px;\n line-height: 37px;\n font-size: var(--font-body1);\n color: var(--font-on-primary);\n border-radius: var(--border-radius-round);\n cursor: pointer;\n transition: 0.3s;\n\n &:not(:last-child) {\n margin-right: var(--spacing-xs);\n }\n\n ", ";\n\n ", "\n\n &:hover {\n ", "\n }\n &.paginationDots {\n cursor: default;\n }\n"])), function (_ref2) {
94
+ var Link = _styledComponents.default.li(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 36px;\n line-height: 37px;\n font-size: var(--font-body1);\n color: var(--font-on-primary);\n border-radius: var(--border-radius-round);\n cursor: pointer;\n transition: 0.3s;\n\n &:not(:last-child) {\n margin-right: var(--spacing-xs);\n }\n\n ", ";\n\n ", ";\n\n &:hover {\n ", "\n }\n\n &.paginationDots {\n cursor: default;\n }\n"])), function (_ref2) {
95
95
  var disabled = _ref2.disabled;
96
96
  return disabled && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n opacity: 0.5;\n cursor: no-drop;\n "])));
97
97
  }, function (_ref3) {
98
- var disabled = _ref3.disabled,
99
- active = _ref3.active;
100
- return !disabled && active && (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-color: var(--color-primary);\n "])));
98
+ var active = _ref3.active;
99
+ return active && 'background-color: var(--color-primary)';
101
100
  }, function (_ref4) {
102
101
  var disabled = _ref4.disabled,
103
102
  className = _ref4.className;
104
- return !disabled && !className && (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n background-color: var(--color-primary);\n "])));
103
+ return !disabled && !className && (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-color: var(--color-primary);\n "])));
105
104
  });
106
105
 
107
- var Icon = _styledComponents.default.span(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n font-size: var(--font-body1);\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n"])));
106
+ var Icon = _styledComponents.default.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: var(--font-body1);\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n"])));
108
107
 
109
108
  var _default = Paginate;
110
109
  exports.default = _default;
@@ -23,7 +23,7 @@ var _Options = _interopRequireDefault(require("./subComponent/Options"));
23
23
 
24
24
  var _jsxRuntime = require("react/jsx-runtime");
25
25
 
26
- var _excluded = ["options", "onSelect", "value", "disabled", "onChange"];
26
+ var _excluded = ["options", "value", "disabled", "onChange", "onSelect"];
27
27
 
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
29
 
@@ -62,10 +62,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
62
62
  var InputSelect = function InputSelect(_ref) {
63
63
  var _ref$options = _ref.options,
64
64
  options = _ref$options === void 0 ? [] : _ref$options,
65
- onSelect = _ref.onSelect,
66
65
  value = _ref.value,
67
66
  disabled = _ref.disabled,
68
67
  _onChange = _ref.onChange,
68
+ onSelect = _ref.onSelect,
69
69
  props = _objectWithoutProperties(_ref, _excluded);
70
70
 
71
71
  var _useState = (0, _react.useState)(false),
@@ -76,8 +76,7 @@ var InputSelect = function InputSelect(_ref) {
76
76
  var _useState3 = (0, _react.useState)([]),
77
77
  _useState4 = _slicedToArray(_useState3, 2),
78
78
  filteredOptions = _useState4[0],
79
- setFilteredOptions = _useState4[1]; // render時使用的資料
80
-
79
+ setFilteredOptions = _useState4[1];
81
80
 
82
81
  var _useState5 = (0, _react.useState)([]),
83
82
  _useState6 = _slicedToArray(_useState5, 2),
@@ -112,8 +111,8 @@ var InputSelect = function InputSelect(_ref) {
112
111
  state = _useCustomPopper.state,
113
112
  update = _useCustomPopper.update;
114
113
 
115
- var handleKeyUp = function handleKeyUp(e) {
116
- var key = e.keyCode;
114
+ var handleKeyUp = function handleKeyUp(event) {
115
+ var key = event.keyCode;
117
116
 
118
117
  switch (key) {
119
118
  case _utils.KEY_CODE.ENTER:
@@ -154,13 +153,13 @@ var InputSelect = function InputSelect(_ref) {
154
153
  }
155
154
 
156
155
  case _utils.KEY_CODE.HOME:
157
- e.preventDefault();
156
+ event.preventDefault();
158
157
  focusFirstItem();
159
158
  break;
160
159
 
161
160
  case _utils.KEY_CODE.END:
162
161
  {
163
- e.preventDefault();
162
+ event.preventDefault();
164
163
  var lastItem = dropdownElement.querySelectorAll('[role="option"]');
165
164
 
166
165
  if (lastItem.length) {
@@ -175,8 +174,8 @@ var InputSelect = function InputSelect(_ref) {
175
174
  }
176
175
  };
177
176
 
178
- var handleKeyDown = function handleKeyDown(e) {
179
- var key = e.keyCode;
177
+ var handleKeyDown = function handleKeyDown(event) {
178
+ var key = event.keyCode;
180
179
 
181
180
  switch (key) {
182
181
  case _utils.KEY_CODE.ENTER:
@@ -185,7 +184,7 @@ var InputSelect = function InputSelect(_ref) {
185
184
  case _utils.KEY_CODE.DOWN:
186
185
  case _utils.KEY_CODE.END:
187
186
  case _utils.KEY_CODE.HOME:
188
- e.preventDefault();
187
+ event.preventDefault();
189
188
  break;
190
189
 
191
190
  default:
@@ -216,7 +215,7 @@ var InputSelect = function InputSelect(_ref) {
216
215
  }
217
216
 
218
217
  return nextItem;
219
- }, [dropdownElement]); //set focused option
218
+ }, [dropdownElement]); // set focused option
220
219
 
221
220
  var handleFocusItem = (0, _react.useCallback)(function (element) {
222
221
  if (!optionsElementRef.current) return;
@@ -280,7 +279,7 @@ var InputSelect = function InputSelect(_ref) {
280
279
  (0, _react.useEffect)(function () {
281
280
  if (!listBoxElement) return;
282
281
  setListBoxWidth(listBoxElement.clientWidth);
283
- }, [listBoxElement]); //過濾搜尋關鍵字資料
282
+ }, [listBoxElement]); // 過濾搜尋關鍵字資料
284
283
 
285
284
  (0, _react.useEffect)(function () {
286
285
  if (!options.length) return;
@@ -349,8 +348,8 @@ var InputSelect = function InputSelect(_ref) {
349
348
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, _objectSpread(_objectSpread(_objectSpread({
350
349
  autoComplete: "off"
351
350
  }, props), {}, {
352
- onChange: function onChange(e) {
353
- _onChange(e);
351
+ onChange: function onChange(event) {
352
+ _onChange(event);
354
353
 
355
354
  if (!displayListBox) setDisplayListBox(true);
356
355
  },
package/select/Select.js CHANGED
@@ -104,13 +104,13 @@ var Select = function Select(_ref) {
104
104
 
105
105
  var _useState5 = (0, _react.useState)(null),
106
106
  _useState6 = _slicedToArray(_useState5, 2),
107
- listBoxElement = _useState6[0],
108
- setListBoxElement = _useState6[1];
107
+ comboboxElement = _useState6[0],
108
+ setComboboxElement = _useState6[1];
109
109
 
110
110
  var _useState7 = (0, _react.useState)(null),
111
111
  _useState8 = _slicedToArray(_useState7, 2),
112
- dropdownElement = _useState8[0],
113
- setDropdownElement = _useState8[1];
112
+ listBoxElement = _useState8[0],
113
+ setListBoxElement = _useState8[1];
114
114
 
115
115
  var optionsElementRef = (0, _react.useRef)(null);
116
116
  var searchBoxElement = (0, _react.useRef)(null);
@@ -150,7 +150,7 @@ var Select = function Select(_ref) {
150
150
  search = _useState22[0],
151
151
  setSearch = _useState22[1];
152
152
 
153
- var _useCustomPopper = (0, _hooks.useCustomPopper)(listBoxElement, dropdownElement),
153
+ var _useCustomPopper = (0, _hooks.useCustomPopper)(comboboxElement, listBoxElement),
154
154
  styles = _useCustomPopper.styles,
155
155
  attributes = _useCustomPopper.attributes,
156
156
  state = _useCustomPopper.state,
@@ -159,17 +159,15 @@ var Select = function Select(_ref) {
159
159
 
160
160
 
161
161
  var parsedSelected = (0, _react.useMemo)(function () {
162
- if (selected || selected === 0) {
163
- // multiple value
164
- if (Array.isArray(selected) && selected.length > 0) {
165
- return selected.map(function (value) {
166
- return value.toString();
167
- });
168
- } // single value
162
+ // multiple value
163
+ if (Array.isArray(selected)) {
164
+ return selected.map(function (value) {
165
+ return value.toString();
166
+ });
167
+ } // single value
169
168
 
170
169
 
171
- return selected.toString();
172
- }
170
+ return selected.toString();
173
171
  }, [selected]); // set focused option
174
172
 
175
173
  var handleFocusItem = (0, _react.useCallback)(function (element) {
@@ -189,15 +187,15 @@ var Select = function Select(_ref) {
189
187
  }
190
188
  }, []);
191
189
  var focusFirstItem = (0, _react.useCallback)(function () {
192
- var firstItem = dropdownElement.querySelector('[role="option"]');
190
+ var firstItem = listBoxElement.querySelector('[role="option"]');
193
191
 
194
192
  if (firstItem) {
195
193
  handleFocusItem(firstItem);
196
194
  }
197
- }, [dropdownElement, handleFocusItem]);
195
+ }, [listBoxElement, handleFocusItem]);
198
196
  var setupFocus = (0, _react.useCallback)(function () {
199
- if (!dropdownElement) return;
200
- var selectedItem = dropdownElement.querySelector('[aria-selected="true"]');
197
+ if (!listBoxElement) return;
198
+ var selectedItem = listBoxElement.querySelector('[aria-selected="true"]');
201
199
 
202
200
  if (selectedItem) {
203
201
  handleFocusItem(selectedItem);
@@ -206,9 +204,9 @@ var Select = function Select(_ref) {
206
204
  } else {
207
205
  setFocusedOption(null);
208
206
  }
209
- }, [dropdownElement, handleFocusItem, focusFirstItem, optionList]);
207
+ }, [listBoxElement, handleFocusItem, focusFirstItem, optionList]);
210
208
  var findPreviousItem = (0, _react.useCallback)(function (currentItem) {
211
- var allItem = _toConsumableArray(dropdownElement.querySelectorAll('[role="option"]'));
209
+ var allItem = _toConsumableArray(listBoxElement.querySelectorAll('[role="option"]'));
212
210
 
213
211
  var currentItemIndex = allItem.indexOf(currentItem);
214
212
  var previousItem = null;
@@ -218,9 +216,9 @@ var Select = function Select(_ref) {
218
216
  }
219
217
 
220
218
  return previousItem;
221
- }, [dropdownElement]);
219
+ }, [listBoxElement]);
222
220
  var findNextItem = (0, _react.useCallback)(function (currentItem) {
223
- var allItem = _toConsumableArray(dropdownElement.querySelectorAll('[role="option"]'));
221
+ var allItem = _toConsumableArray(listBoxElement.querySelectorAll('[role="option"]'));
224
222
 
225
223
  var currentItemIndex = allItem.indexOf(currentItem);
226
224
  var nextItem = null;
@@ -230,15 +228,15 @@ var Select = function Select(_ref) {
230
228
  }
231
229
 
232
230
  return nextItem;
233
- }, [dropdownElement]);
231
+ }, [listBoxElement]);
234
232
  var handleOnSelect = (0, _react.useCallback)(function (event, value) {
235
233
  event.stopPropagation();
236
234
  if (disabled === true) return;
237
235
  onSelect(value);
238
- listBoxElement.focus();
236
+ comboboxElement.focus();
239
237
  setSearch('');
240
238
  setDisplay(false);
241
- }, [disabled, onSelect, listBoxElement]);
239
+ }, [disabled, onSelect, comboboxElement]);
242
240
  var handleOnDeselect = (0, _react.useCallback)(function (event, value) {
243
241
  event.stopPropagation();
244
242
  if (disabled === true) return;
@@ -305,8 +303,8 @@ var Select = function Select(_ref) {
305
303
  children: option.text
306
304
  }, option.id);
307
305
  });
308
- }, [optionList, focusedOption, handleOnSelect]); // show or hide dropdown
309
- // and set dropdown width according to listbox current width
306
+ }, [optionList, focusedOption, handleOnSelect]); // show or hide listbox
307
+ // and set listbox width according to combobox current width
310
308
 
311
309
  var handleToggle = function handleToggle() {
312
310
  if (disabled === true) return;
@@ -374,7 +372,7 @@ var Select = function Select(_ref) {
374
372
  case _utils.KEY_CODE.END:
375
373
  {
376
374
  event.preventDefault();
377
- var itemList = dropdownElement.querySelectorAll('[role="option"]');
375
+ var itemList = listBoxElement.querySelectorAll('[role="option"]');
378
376
 
379
377
  if (itemList.length) {
380
378
  handleFocusItem(itemList[itemList.length - 1]);
@@ -416,9 +414,9 @@ var Select = function Select(_ref) {
416
414
  setSearch(event.target.value);
417
415
  };
418
416
 
419
- var handleFocus = function handleFocus(e) {
420
- e.preventDefault();
421
- e.stopPropagation();
417
+ var handleFocus = function handleFocus(event) {
418
+ event.preventDefault();
419
+ event.stopPropagation();
422
420
  setIsFocusCombobox(true);
423
421
  }; // determine selected option(s)
424
422
 
@@ -456,7 +454,7 @@ var Select = function Select(_ref) {
456
454
  }, [update, listBoxWidth]); // observe element resized
457
455
 
458
456
  (0, _react.useEffect)(function () {
459
- if (!listBoxElement) return;
457
+ if (!comboboxElement) return;
460
458
  var resizeObserverInstance = new ResizeObserver(function (entries) {
461
459
  var _iterator = _createForOfIteratorHelper(entries),
462
460
  _step;
@@ -476,12 +474,12 @@ var Select = function Select(_ref) {
476
474
  _iterator.f();
477
475
  }
478
476
  });
479
- resizeObserverInstance.observe(listBoxElement);
477
+ resizeObserverInstance.observe(comboboxElement);
480
478
  return function () {
481
479
  // unobserve element
482
- resizeObserverInstance.unobserve(listBoxElement);
480
+ resizeObserverInstance.unobserve(comboboxElement);
483
481
  };
484
- }, [listBoxElement]); // re-setup focus when option list changed and update popper position
482
+ }, [comboboxElement]); // re-setup focus when option list changed and update popper position
485
483
 
486
484
  (0, _react.useEffect)(function () {
487
485
  setupFocus();
@@ -564,7 +562,7 @@ var Select = function Select(_ref) {
564
562
  "aria-haspopup": "listbox",
565
563
  "aria-expanded": display,
566
564
  "aria-owns": id,
567
- ref: setListBoxElement,
565
+ ref: setComboboxElement,
568
566
  onClick: handleToggle,
569
567
  onKeyUp: handleKeyUp,
570
568
  onKeyDown: handleKeyDown,
@@ -587,7 +585,7 @@ var Select = function Select(_ref) {
587
585
  role: "listbox",
588
586
  tabIndex: "0",
589
587
  id: id,
590
- ref: setDropdownElement,
588
+ ref: setListBoxElement,
591
589
  onKeyUp: handleKeyUp,
592
590
  onKeyDown: handleKeyDown,
593
591
  width: listBoxWidth,