@councilbox/councilbox-ui 2.0.56 → 2.0.57

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.
@@ -219,7 +219,7 @@ var DrawerPanel = function DrawerPanel(_ref) {
219
219
  className: prefixClass('cbx-drawerPanel-moreButton')
220
220
  }, moreButton)), /*#__PURE__*/_react["default"].createElement("div", {
221
221
  className: prefixClass('cbx-drawerPanel-tabs-container')
222
- }, tabs.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
222
+ }, Array.isArray(tabs) && tabs.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
223
223
  className: prefixClass(isMobile ? 'cbx-drawerPanel-tabs-block-mobile' : 'cbx-drawerPanel-tabs-block')
224
224
  }, /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
225
225
  onChange: function onChange(index, e) {
@@ -37,7 +37,7 @@ var GridItem = function GridItem(_ref) {
37
37
  dynamicPrefixClass = _useDynamicStyles.prefixClass;
38
38
  var prefixClass = propPrefixClass || dynamicPrefixClass;
39
39
  return /*#__PURE__*/_react["default"].createElement("div", _extends({
40
- className: prefixClass("cbx-grid-container-item xs-".concat(xs, " sm-").concat(sm, " md-").concat(md, " lg-").concat(lg, " xl-").concat(xl, " ").concat(className)),
40
+ className: prefixClass("cbx-grid-container-item xs-".concat(xs, " sm-").concat(sm, " md-").concat(md, " lg-").concat(lg, " xl-").concat(xl, " ").concat(className || '')),
41
41
  style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, spacingStyle), style), stylesInLine), {}, {
42
42
  alignContent: alignContent
43
43
  }),
@@ -19,10 +19,14 @@ var _autoDetectScroll = require("../../utils/autoDetectScroll");
19
19
  var _utils = require("../../utils");
20
20
  var _useFallbackId = _interopRequireDefault(require("../../utils/useFallbackId"));
21
21
  var _useA11yGuard2 = require("../../HOCs/useA11yGuard");
22
- var _excluded = ["children", "className", "onChange", "onInputChange", "label", "value", "autoComplete", "inputValue", "style", "styles", "sx", "loadingText", "loading", "prefixClass", "options", "disabled", "getOptionLabel", "clearable", "getOptionSelected", "defaultValue", "filterOptions", "freeSolo", "InputProps", "clearOnBlur", "selectOnFocus", "id"];
22
+ var _excluded = ["children", "className", "onChange", "onInputChange", "label", "value", "autoComplete", "inputValue", "style", "styles", "sx", "loadingText", "loading", "prefixClass", "options", "disabled", "getOptionLabel", "clearable", "multiple", "getOptionValue", "renderValue", "getOptionSelected", "defaultValue", "filterOptions", "freeSolo", "InputProps", "clearOnBlur", "selectOnFocus", "id"];
23
23
  /* eslint-disable no-tabs */
24
24
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
25
25
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
26
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
27
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
28
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
29
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
26
30
  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; }
27
31
  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; }
28
32
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -36,6 +40,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
36
40
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
37
41
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) { o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } } return i; }
38
42
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) { if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } } return t; }
43
+ var EMPTY_OPTIONS = [];
39
44
  var InputAutocomplete = function InputAutocomplete(_ref) {
40
45
  var children = _ref.children,
41
46
  className = _ref.className,
@@ -54,7 +59,7 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
54
59
  _ref$loading = _ref.loading,
55
60
  loading = _ref$loading === void 0 ? false : _ref$loading,
56
61
  propPrefixClass = _ref.prefixClass,
57
- options = _ref.options,
62
+ optionsProp = _ref.options,
58
63
  disabled = _ref.disabled,
59
64
  _ref$getOptionLabel = _ref.getOptionLabel,
60
65
  getOptionLabel = _ref$getOptionLabel === void 0 ? function (option) {
@@ -68,9 +73,17 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
68
73
  } : _ref$getOptionLabel,
69
74
  _ref$clearable = _ref.clearable,
70
75
  clearable = _ref$clearable === void 0 ? true : _ref$clearable,
76
+ _ref$multiple = _ref.multiple,
77
+ multiple = _ref$multiple === void 0 ? false : _ref$multiple,
78
+ _ref$getOptionValue = _ref.getOptionValue,
79
+ getOptionValue = _ref$getOptionValue === void 0 ? function (option) {
80
+ var _ref2, _option$value;
81
+ return (_ref2 = (_option$value = option === null || option === void 0 ? void 0 : option.value) !== null && _option$value !== void 0 ? _option$value : option === null || option === void 0 ? void 0 : option.id) !== null && _ref2 !== void 0 ? _ref2 : option;
82
+ } : _ref$getOptionValue,
83
+ renderValue = _ref.renderValue,
71
84
  _ref$getOptionSelecte = _ref.getOptionSelected,
72
85
  getOptionSelected = _ref$getOptionSelecte === void 0 ? function (option, valueSelected) {
73
- return option === valueSelected;
86
+ return multiple ? Array.isArray(valueSelected) && valueSelected.includes(getOptionValue(option)) : option === valueSelected;
74
87
  } : _ref$getOptionSelecte,
75
88
  defaultValue = _ref.defaultValue,
76
89
  filterOptions = _ref.filterOptions,
@@ -84,6 +97,21 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
84
97
  selectOnFocus = _ref$selectOnFocus === void 0 ? !freeSolo : _ref$selectOnFocus,
85
98
  id = _ref.id,
86
99
  props = _objectWithoutProperties(_ref, _excluded);
100
+ var options = Array.isArray(optionsProp) ? optionsProp : EMPTY_OPTIONS;
101
+ var getDisplayLabel = function getDisplayLabel(val) {
102
+ if (multiple) {
103
+ if (renderValue) {
104
+ return renderValue(val) || '';
105
+ }
106
+ return (Array.isArray(val) ? val : []).map(function (v) {
107
+ var matchedOption = options.find(function (option) {
108
+ return getOptionValue(option) === v;
109
+ });
110
+ return matchedOption ? getOptionLabel(matchedOption) : v;
111
+ }).join(', ');
112
+ }
113
+ return val ? getOptionLabel(val) : '';
114
+ };
87
115
  var _React$useState = _react["default"].useState(false),
88
116
  _React$useState2 = _slicedToArray(_React$useState, 2),
89
117
  isOpen = _React$useState2[0],
@@ -126,11 +154,11 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
126
154
  _React$useState8 = _slicedToArray(_React$useState7, 2),
127
155
  isClosing = _React$useState8[0],
128
156
  setIsClosing = _React$useState8[1];
129
- var _React$useState9 = _react["default"].useState(value || null),
157
+ var _React$useState9 = _react["default"].useState(value || (multiple ? [] : null)),
130
158
  _React$useState0 = _slicedToArray(_React$useState9, 2),
131
159
  internalValue = _React$useState0[0],
132
160
  setInternalValue = _React$useState0[1];
133
- var _React$useState1 = _react["default"].useState(propInputValue || value && getOptionLabel(value) || ''),
161
+ var _React$useState1 = _react["default"].useState(propInputValue || getDisplayLabel(value) || ''),
134
162
  _React$useState10 = _slicedToArray(_React$useState1, 2),
135
163
  internalInputValue = _React$useState10[0],
136
164
  setInternalInputValue = _React$useState10[1];
@@ -202,6 +230,26 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
202
230
  }
203
231
  };
204
232
  var handleOptionClick = function handleOptionClick(e, option) {
233
+ if (multiple) {
234
+ var optionValue = getOptionValue(option);
235
+ var currentValues = Array.isArray(selectedValue) ? selectedValue : [];
236
+ var isSelected = currentValues.includes(optionValue);
237
+ var newValues = isSelected ? currentValues.filter(function (v) {
238
+ return v !== optionValue;
239
+ }) : [].concat(_toConsumableArray(currentValues), [optionValue]);
240
+ if (onChange) {
241
+ onChange(_objectSpread(_objectSpread({}, e), {}, {
242
+ preventDefault: function preventDefault() {},
243
+ stopPropagation: function stopPropagation() {},
244
+ target: {
245
+ value: newValues
246
+ }
247
+ }));
248
+ } else {
249
+ setInternalValue(newValues);
250
+ }
251
+ return;
252
+ }
205
253
  var optionLabel = getOptionLabel(option);
206
254
  updateInputValue(e, optionLabel);
207
255
  updateValue(e, option);
@@ -216,10 +264,10 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
216
264
  updateInputValue(e, newInputValue);
217
265
  };
218
266
  var handleInputBlur = function handleInputBlur(e) {
219
- handleInputChange(e, selectedValue ? getOptionLabel(selectedValue) : '');
267
+ handleInputChange(e, getDisplayLabel(selectedValue));
220
268
  if (clearOnBlur) {
221
269
  if (!freeSolo) {
222
- handleInputChange(e, selectedValue ? getOptionLabel(selectedValue) : '');
270
+ handleInputChange(e, getDisplayLabel(selectedValue));
223
271
  }
224
272
  }
225
273
  closeDropdown(false);
@@ -260,7 +308,7 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
260
308
  var updateDropdownPosition = function updateDropdownPosition() {
261
309
  var _selectRef$current, _selectRef$current2, _selectRef$current2$c;
262
310
  if (selectRef.current && selectRef !== null && selectRef !== void 0 && (_selectRef$current = selectRef.current) !== null && _selectRef$current !== void 0 && _selectRef$current.children[0] && selectRef !== null && selectRef !== void 0 && (_selectRef$current2 = selectRef.current) !== null && _selectRef$current2 !== void 0 && (_selectRef$current2$c = _selectRef$current2.children[0]) !== null && _selectRef$current2$c !== void 0 && _selectRef$current2$c.children[0]) {
263
- var _selectRef$current3, _selectRef$current3$c, _selectRef$current3$c2;
311
+ var _selectRef$current3, _selectRef$current3$c, _selectRef$current3$c2, _dropdownRef$current;
264
312
  var selectRect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current3 = selectRef.current) === null || _selectRef$current3 === void 0 ? void 0 : (_selectRef$current3$c = _selectRef$current3.children[0]) === null || _selectRef$current3$c === void 0 ? void 0 : (_selectRef$current3$c2 = _selectRef$current3$c.children[0]) === null || _selectRef$current3$c2 === void 0 ? void 0 : _selectRef$current3$c2.getBoundingClientRect();
265
313
  var isOverflowingBelow = selectRect.bottom > window.innerHeight * 0.60;
266
314
  var newPositions = _objectSpread({}, positions);
@@ -271,7 +319,11 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
271
319
  delete newPositions.bottom;
272
320
  newPositions.top = "".concat(selectRect.bottom, "px");
273
321
  }
274
- newPositions.left = "".concat(selectRect.left, "px");
322
+ var viewportMargin = 16;
323
+ var dropdownWidth = ((_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.offsetWidth) || selectRect.width;
324
+ var isOverflowingRight = selectRect.left + dropdownWidth > window.innerWidth - viewportMargin;
325
+ var leftPosition = Math.max(viewportMargin, Math.min(isOverflowingRight ? selectRect.right - dropdownWidth : selectRect.left, window.innerWidth - dropdownWidth - viewportMargin));
326
+ newPositions.left = "".concat(leftPosition, "px");
275
327
  newPositions.width = "".concat(selectRect.width, "px");
276
328
  setPositions(_objectSpread({}, newPositions));
277
329
  }
@@ -279,6 +331,11 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
279
331
  _react["default"].useEffect(function () {
280
332
  updateDropdownPosition();
281
333
  }, [shouldShowDropdown, document.body.clientHeight > window.innerHeight]);
334
+ _react["default"].useLayoutEffect(function () {
335
+ if (shouldShowDropdown && dropdownRef.current) {
336
+ updateDropdownPosition();
337
+ }
338
+ }, [shouldShowDropdown, positions.top, positions.bottom]);
282
339
  _react["default"].useEffect(function () {
283
340
  var referenceEl = (0, _autoDetectScroll.unwrapElement)(inputRef.current);
284
341
  var ancestors = (0, _autoDetectScroll.getOverflowAncestors)(referenceEl) || [];
@@ -291,14 +348,18 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
291
348
  }, [inputRef.current]);
292
349
  _react["default"].useEffect(function () {
293
350
  if (propInputValue === undefined) {
294
- if (value) {
351
+ if (multiple) {
352
+ if (!searchTextRef.current) {
353
+ setInternalInputValue(getDisplayLabel(value) || '');
354
+ }
355
+ } else if (value) {
295
356
  var newLabel = getOptionLabel(value);
296
357
  setInternalInputValue(newLabel || '');
297
358
  } else {
298
359
  setInternalInputValue('');
299
360
  }
300
361
  }
301
- }, [value]);
362
+ }, [value, multiple]);
302
363
  return /*#__PURE__*/_react["default"].createElement("div", {
303
364
  className: prefixClass("cbx-inputAutocomplete-container ".concat(isOpen ? 'cbx-inputAutocomplete-container-open' : '', " ").concat(uiState.showSearchInput ? 'cbx-inputAutocomplete-container-open' : '')),
304
365
  style: _objectSpread(_objectSpread(_objectSpread({
@@ -367,8 +428,18 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
367
428
  e.stopPropagation();
368
429
  e.preventDefault();
369
430
  searchTextRef.current = '';
370
- updateInputValue(e, '');
371
- updateValue(e, null);
431
+ if (multiple) {
432
+ var summary = getDisplayLabel(selectedValue);
433
+ if (props.inputValue === undefined) {
434
+ setInternalInputValue(summary);
435
+ }
436
+ if (onInputChange) {
437
+ onInputChange(e, summary);
438
+ }
439
+ } else {
440
+ updateInputValue(e, '');
441
+ updateValue(e, null);
442
+ }
372
443
  inputRef.current.focus();
373
444
  },
374
445
  icon: /*#__PURE__*/_react["default"].createElement("i", {
@@ -428,10 +499,10 @@ var InputAutocomplete = function InputAutocomplete(_ref) {
428
499
  }, loadingText))))), document.body));
429
500
  };
430
501
  InputAutocomplete.displayName = "InputAutocomplete";
431
- var OutsideClickHandler = function OutsideClickHandler(_ref2) {
432
- var children = _ref2.children,
433
- excludedRefs = _ref2.excludedRefs,
434
- onOutsideClick = _ref2.onOutsideClick;
502
+ var OutsideClickHandler = function OutsideClickHandler(_ref3) {
503
+ var children = _ref3.children,
504
+ excludedRefs = _ref3.excludedRefs,
505
+ onOutsideClick = _ref3.onOutsideClick;
435
506
  var wrapperRef = _react["default"].useRef(null);
436
507
  _react["default"].useEffect(function () {
437
508
  var handleClickOutside = function handleClickOutside(event) {
@@ -462,7 +533,10 @@ InputAutocomplete.propTypes = {
462
533
  disabled: _propTypes["default"].bool,
463
534
  error: _propTypes["default"].node,
464
535
  success: _propTypes["default"].bool,
465
- fullWidth: _propTypes["default"].bool
536
+ fullWidth: _propTypes["default"].bool,
537
+ multiple: _propTypes["default"].bool,
538
+ getOptionValue: _propTypes["default"].func,
539
+ renderValue: _propTypes["default"].func
466
540
  };
467
541
  InputAutocomplete.defaultProps = {
468
542
  label: '',
@@ -3,10 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.Success = exports.Helper = exports.ErrorTemplate = exports.Disabled = exports.Default = void 0;
6
+ exports["default"] = exports.Success = exports.Multiple = exports.Helper = exports.ErrorTemplate = exports.Disabled = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _InputAutocomplete = _interopRequireDefault(require("./InputAutocomplete"));
9
+ var _Checkbox = _interopRequireDefault(require("../Checkbox/Checkbox"));
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
12
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
13
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
15
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
16
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
17
+ 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."); }
18
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
19
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
20
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
21
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
10
22
  var _default = {
11
23
  title: 'Components/Input Autocomplete',
12
24
  component: _InputAutocomplete["default"],
@@ -180,4 +192,81 @@ ErrorTemplate.args = {
180
192
  label: 'Pulp Fiction',
181
193
  value: 1994
182
194
  }]
195
+ };
196
+ var ALL = '__all__';
197
+ var PEOPLE = [{
198
+ id: 1,
199
+ name: 'Ada Lovelace'
200
+ }, {
201
+ id: 2,
202
+ name: 'Alan Turing'
203
+ }, {
204
+ id: 3,
205
+ name: 'Grace Hopper'
206
+ }, {
207
+ id: 4,
208
+ name: 'Katherine Johnson'
209
+ }, {
210
+ id: 5,
211
+ name: 'Linus Torvalds'
212
+ }];
213
+ var multipleRowStyle = {
214
+ display: 'flex',
215
+ alignItems: 'center',
216
+ width: '100%'
217
+ };
218
+ var MultipleTemplate = function MultipleTemplate(args) {
219
+ var _React$useState = _react["default"].useState(args.value || []),
220
+ _React$useState2 = _slicedToArray(_React$useState, 2),
221
+ value = _React$useState2[0],
222
+ setValue = _React$useState2[1];
223
+ var allSelected = value.length === PEOPLE.length;
224
+ var options = [].concat(_toConsumableArray(allSelected ? [] : [{
225
+ id: ALL,
226
+ isAllOption: true
227
+ }]), PEOPLE);
228
+ var handleChange = function handleChange(ev) {
229
+ var newValues = ev.target.value;
230
+ setValue(newValues.includes(ALL) ? PEOPLE.map(function (person) {
231
+ return person.id;
232
+ }) : newValues);
233
+ };
234
+ return /*#__PURE__*/_react["default"].createElement(_InputAutocomplete["default"], _extends({}, args, {
235
+ multiple: true,
236
+ options: options,
237
+ value: value,
238
+ onChange: handleChange,
239
+ getOptionLabel: function getOptionLabel(option) {
240
+ return option.isAllOption ? 'Select all' : option.name;
241
+ },
242
+ getOptionSelected: function getOptionSelected(option) {
243
+ return option.isAllOption ? allSelected : value.includes(option.id);
244
+ },
245
+ renderValue: function renderValue(selected) {
246
+ return selected.length === PEOPLE.length ? 'All' : selected.map(function (id) {
247
+ var _PEOPLE$find;
248
+ return (_PEOPLE$find = PEOPLE.find(function (person) {
249
+ return person.id === id;
250
+ })) === null || _PEOPLE$find === void 0 ? void 0 : _PEOPLE$find.name;
251
+ }).join(', ');
252
+ },
253
+ renderOption: function renderOption(option) {
254
+ var checked = option.isAllOption ? allSelected : value.includes(option.id);
255
+ return /*#__PURE__*/_react["default"].createElement("div", {
256
+ style: multipleRowStyle
257
+ }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
258
+ checked: checked,
259
+ label: option.isAllOption ? 'Select all' : option.name
260
+ }));
261
+ }
262
+ }));
263
+ };
264
+ MultipleTemplate.displayName = "MultipleTemplate";
265
+ var Multiple = MultipleTemplate.bind({});
266
+ exports.Multiple = Multiple;
267
+ Multiple.args = {
268
+ variant: 'outlined',
269
+ label: 'People',
270
+ noOptionsText: 'No results',
271
+ value: [1, 3]
183
272
  };
@@ -432,16 +432,6 @@ textarea.cbx-inputText.cbx-inputText-standard~.cbx-inputText-fieldset-standard {
432
432
  transform: translate(40px, 13px) scale(1);
433
433
  }
434
434
 
435
- .cbx-inputText-icon-startAdornment .cbx-input:focus~.cbx-inputText-label,
436
- .cbx-inputText-icon-startAdornment .cbx-input.shrink~.cbx-inputText-label,
437
- .cbx-inputText-icon-startAdornment .cbx-input:not(:placeholder-shown)~.cbx-inputText-label {
438
- transform: translate(40px, -9px) scale(0.75);
439
- }
440
-
441
- .cbx-inputText-icon-startAdornment .cbx-inputText-fieldset legend {
442
- margin-left: 1.625rem;
443
- }
444
-
445
435
  .cbx-inputText-autocomplete-button-open {
446
436
  position: absolute;
447
437
  right: 0.313rem;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.Success = exports.Helper = exports.ErrorTemplate = exports.Disabled = exports.Default = void 0;
6
+ exports["default"] = exports.Success = exports.StartAdornment = exports.Helper = exports.ErrorTemplate = exports.EndAdornment = exports.Disabled = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _InputText = _interopRequireDefault(require("./InputText"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -83,4 +83,18 @@ ErrorTemplate.args = {
83
83
  value: 'Occaecat',
84
84
  // placeholder: 'Occaecat',
85
85
  error: 'Error'
86
+ };
87
+ var StartAdornment = Template.bind({});
88
+ exports.StartAdornment = StartAdornment;
89
+ StartAdornment.args = {
90
+ label: 'Occaecat',
91
+ placeholder: 'Occaecat',
92
+ startAdornment: 'ri-search-line'
93
+ };
94
+ var EndAdornment = Template.bind({});
95
+ exports.EndAdornment = EndAdornment;
96
+ EndAdornment.args = {
97
+ label: 'Occaecat',
98
+ placeholder: 'Occaecat',
99
+ endAdornment: 'ri-search-line'
86
100
  };
@@ -107,7 +107,7 @@ var Modal = function Modal(_ref) {
107
107
  var contentRef = _react["default"].useRef(null);
108
108
  var adjustedScrollbarHeight = _react["default"].useMemo(function () {
109
109
  if (isFirefox) {
110
- if (scrollbarHeight && scrollbarHeight.endsWith('%')) {
110
+ if (typeof scrollbarHeight === 'string' && scrollbarHeight.endsWith('%')) {
111
111
  return "".concat(parseFloat(scrollbarHeight) * 1, "vh");
112
112
  }
113
113
  }
@@ -62,10 +62,12 @@ var Scrollbar = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
62
62
  children = props.children,
63
63
  showX = props.showX,
64
64
  onScrollStop = props.onScrollStop,
65
- _props$classFix = props.classFix,
66
- classFix = _props$classFix === void 0 ? '' : _props$classFix,
65
+ classFixProp = props.classFix,
67
66
  _props$horizontalScro = props.horizontalScroll,
68
67
  horizontalScroll = _props$horizontalScro === void 0 ? false : _props$horizontalScro;
68
+
69
+ // Consumers often pass `isMobile && 'ScrollbarMobile'`, which yields false/null instead of a string
70
+ var classFix = typeof classFixProp === 'string' ? classFixProp : '';
69
71
  var isMobileMode = classFix.split(' ').filter(Boolean).includes('ScrollbarMobile');
70
72
  var showHorizontalThumb = horizontalScroll && showX && !isMobileMode;
71
73
  var viewRef = _react["default"].useRef(null);
@@ -65,10 +65,10 @@ var ScrollbarOld = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
65
65
  children = props.children,
66
66
  showX = props.showX,
67
67
  onScrollStop = props.onScrollStop,
68
- _props$classFix = props.classFix,
69
- classFix = _props$classFix === void 0 ? '' : _props$classFix,
68
+ classFixProp = props.classFix,
70
69
  _props$horizontalScro = props.horizontalScroll,
71
70
  horizontalScroll = _props$horizontalScro === void 0 ? false : _props$horizontalScro;
71
+ var classFix = typeof classFixProp === 'string' ? classFixProp : '';
72
72
  var extraClass = '';
73
73
  if (classFix === 'scrollflex' && !(0, _getScrollbarWidth["default"])()) {
74
74
  extraClass = 'macOSFlexFix';
@@ -164,18 +164,22 @@ var SelectInput = function SelectInput(_ref) {
164
164
  var updateDropdownPosition = function updateDropdownPosition() {
165
165
  if (selectRef.current && dropdownRef.current) {
166
166
  var _selectRef$current$cl;
167
+ var viewportMargin = 16;
167
168
  var inputText = selectRef.current;
168
169
  var inputRect = inputText.getBoundingClientRect();
169
- var dropdownHeight = dropdownRef.current.offsetHeight;
170
- var isOverflowingBelow = inputRect.bottom + dropdownHeight > window.innerHeight;
171
- var topPosition = isOverflowingBelow ? window.innerHeight - dropdownHeight : inputRect.bottom;
172
170
  var containerRect = ((_selectRef$current$cl = selectRef.current.closest('.cbx-selectInput-options-container')) === null || _selectRef$current$cl === void 0 ? void 0 : _selectRef$current$cl.getBoundingClientRect()) || {
173
171
  top: 0,
174
172
  left: 0
175
173
  };
176
- dropdownRef.current.style.top = "".concat(topPosition - containerRect.top, "px");
177
- dropdownRef.current.style.left = "".concat(inputRect.left - containerRect.left, "px");
178
174
  dropdownRef.current.style.width = "".concat(inputRect.width, "px");
175
+ var dropdownHeight = dropdownRef.current.offsetHeight;
176
+ var dropdownWidth = dropdownRef.current.offsetWidth;
177
+ var isOverflowingBelow = inputRect.bottom + dropdownHeight > window.innerHeight - viewportMargin;
178
+ var topPosition = Math.max(viewportMargin, isOverflowingBelow ? window.innerHeight - dropdownHeight - viewportMargin : inputRect.bottom);
179
+ var isOverflowingRight = inputRect.left + dropdownWidth > window.innerWidth - viewportMargin;
180
+ var leftPosition = Math.max(viewportMargin, Math.min(isOverflowingRight ? inputRect.right - dropdownWidth : inputRect.left, window.innerWidth - dropdownWidth - viewportMargin));
181
+ dropdownRef.current.style.top = "".concat(topPosition - containerRect.top, "px");
182
+ dropdownRef.current.style.left = "".concat(leftPosition - containerRect.left, "px");
179
183
  }
180
184
  };
181
185
  _react["default"].useEffect(function () {
@@ -239,7 +243,9 @@ var SelectInput = function SelectInput(_ref) {
239
243
  return renderValue(value);
240
244
  }
241
245
  if (multiple && Array.isArray(selectedOption)) {
242
- return value.join(', ');
246
+ return Array.isArray(value) ? value.join(', ') : selectedOption.map(function (option) {
247
+ return option.value;
248
+ }).join(', ');
243
249
  }
244
250
  return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.children) || '';
245
251
  };
@@ -43,7 +43,7 @@ var extractText = function extractText(child) {
43
43
  }, '');
44
44
  };
45
45
  var Stepper = function Stepper(_ref) {
46
- var items = _ref.items,
46
+ var itemsProp = _ref.items,
47
47
  active = _ref.active,
48
48
  onClick = _ref.onClick,
49
49
  _ref$freeNavigation = _ref.freeNavigation,
@@ -58,6 +58,7 @@ var Stepper = function Stepper(_ref) {
58
58
  prefixClass = _useDynamicStyles.prefixClass;
59
59
  var _useA11yGuard = (0, _useA11yGuard2.useA11yGuard)(),
60
60
  requireAccessibleText = _useA11yGuard.requireAccessibleText;
61
+ var items = Array.isArray(itemsProp) ? itemsProp : [];
61
62
  requireAccessibleText(ariaLabel, {
62
63
  component: 'Stepper',
63
64
  prop: '"ariaLabel"',
@@ -105,7 +105,7 @@ var Toggle = function Toggle(_ref) {
105
105
  }, label);
106
106
  };
107
107
  var hasVisibleLabel = Boolean(label);
108
- var resolvedName = ariaLabel && ariaLabel.trim() || (typeof label === 'string' && label.trim() ? label : undefined) || 'toggle';
108
+ var resolvedName = typeof ariaLabel === 'string' && ariaLabel.trim() || (typeof label === 'string' && label.trim() ? label : undefined) || 'toggle';
109
109
  var focusInput = function focusInput() {
110
110
  var _document$getElementB;
111
111
  return (_document$getElementB = document.getElementById(inputId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.click();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@councilbox/councilbox-ui",
3
- "version": "2.0.56",
3
+ "version": "2.0.57",
4
4
  "main": "dist/build-index.js",
5
5
  "files": [
6
6
  "dist",