zds-pickers 3.11.1 → 3.11.3

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.
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/extends";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["channels", "className"];import React, { forwardRef, useCallback, useMemo } from 'react';
1
+ import _extends from "@babel/runtime/helpers/extends";import _slicedToArray from "@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["channels", "className"];import React, { forwardRef, useCallback, useEffect, useState } from 'react';
2
2
  import cl from 'classnames';
3
3
  import PropTypes from 'prop-types';
4
4
  import { arraySequence } from '../utils';
@@ -7,6 +7,7 @@ import Select from './Select';
7
7
  var defaultOptions = arraySequence(16).map(function (value) {return { value: value, label: value };});
8
8
 
9
9
  var ChannelMappingPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {var channels = _ref.channels,className = _ref.className,rest = _objectWithoutProperties(_ref, _excluded);
10
+ var _useState = useState([]),_useState2 = _slicedToArray(_useState, 2),options = _useState2[0],setOptions = _useState2[1];
10
11
  var formatOptionLabel = useCallback(
11
12
  function (_ref2, _ref3) {var value = _ref2.value,label = _ref2.label;var context = _ref3.context;
12
13
  if (value === 'separator') {
@@ -36,7 +37,7 @@ var ChannelMappingPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {var cha
36
37
  [channels]
37
38
  );
38
39
 
39
- var options = useMemo(function () {
40
+ useEffect(function () {
40
41
  var result = defaultOptions.sort(function (a, b) {
41
42
  if (channels[a.value] && !channels[b.value]) {
42
43
  return -1;
@@ -51,12 +52,14 @@ var ChannelMappingPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {var cha
51
52
 
52
53
  var numFilled = result.filter(function (_ref4) {var value = _ref4.value;return !!channels[value];}).length;
53
54
 
54
- if (numFilled && numFilled < 16) {
55
+ var separatorExists = result.some(function (_ref5) {var value = _ref5.value;return value === 'separator';});
56
+
57
+ if (numFilled && numFilled < 16 && !separatorExists) {
55
58
  // insert a separator after the count of filled items
56
59
  result.splice(numFilled, 0, { label: /*#__PURE__*/React.createElement("hr", null), value: 'separator' });
57
60
  }
58
61
 
59
- return result;
62
+ setOptions(result);
60
63
  }, [channels]);
61
64
 
62
65
  return /*#__PURE__*/(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zds-pickers",
3
- "version": "3.11.1",
3
+ "version": "3.11.3",
4
4
  "homepage": "https://github.com/dkadrios/zds-pickers#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",