@elliemae/ds-pills 2.2.0-alpha.2 → 2.2.0-beta.0

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 (133) hide show
  1. package/cjs/components/Pill.js +49 -56
  2. package/cjs/components/PillButton.js +52 -54
  3. package/cjs/components/PillGroup.js +53 -61
  4. package/cjs/components/index.js +17 -30
  5. package/cjs/components/styled.js +78 -228
  6. package/cjs/components/types/DropdownPill.js +77 -79
  7. package/cjs/components/types/InputPill.js +48 -58
  8. package/cjs/components/types/LabelPill.js +38 -44
  9. package/cjs/components/types/ReadOnlyPill.js +43 -48
  10. package/cjs/components/types/RemovablePill.js +53 -60
  11. package/cjs/components/types/ValuePill.js +43 -48
  12. package/cjs/components/types/index.js +19 -33
  13. package/cjs/deprecated/DropdownPill.js +101 -80
  14. package/cjs/deprecated/InputPill.js +69 -67
  15. package/cjs/deprecated/LabeledDropdownPills.js +96 -92
  16. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +94 -91
  17. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +114 -106
  18. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +127 -119
  19. package/cjs/deprecated/LabeledDropdownPillsTypes/utils.js +15 -39
  20. package/cjs/deprecated/LabeledPills.js +52 -65
  21. package/cjs/deprecated/OverflowPill.js +53 -59
  22. package/cjs/deprecated/Pill.js +82 -67
  23. package/cjs/deprecated/PillGroup.js +68 -68
  24. package/cjs/deprecated/ReadOnlyPill.js +94 -93
  25. package/cjs/deprecated/RemovablePill.js +57 -61
  26. package/cjs/deprecated/index.js +33 -43
  27. package/cjs/index.d.js +2 -27
  28. package/cjs/index.js +43 -37
  29. package/cjs/props.js +46 -72
  30. package/cjs/utils.js +25 -43
  31. package/esm/components/Pill.js +31 -18
  32. package/esm/components/PillButton.js +39 -22
  33. package/esm/components/PillGroup.js +38 -28
  34. package/esm/components/index.js +3 -5
  35. package/esm/components/styled.js +66 -205
  36. package/esm/components/types/DropdownPill.js +67 -50
  37. package/esm/components/types/InputPill.js +35 -25
  38. package/esm/components/types/LabelPill.js +29 -15
  39. package/esm/components/types/ReadOnlyPill.js +34 -19
  40. package/esm/components/types/RemovablePill.js +44 -31
  41. package/esm/components/types/ValuePill.js +34 -19
  42. package/esm/components/types/index.js +6 -8
  43. package/esm/deprecated/DropdownPill.js +86 -49
  44. package/esm/deprecated/InputPill.js +59 -38
  45. package/esm/deprecated/LabeledDropdownPills.js +81 -59
  46. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +84 -60
  47. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +94 -65
  48. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +108 -79
  49. package/esm/deprecated/LabeledDropdownPillsTypes/utils.js +10 -9
  50. package/esm/deprecated/LabeledPills.js +41 -34
  51. package/esm/deprecated/OverflowPill.js +37 -25
  52. package/esm/deprecated/Pill.js +71 -39
  53. package/esm/deprecated/PillGroup.js +56 -39
  54. package/esm/deprecated/ReadOnlyPill.js +79 -60
  55. package/esm/deprecated/RemovablePill.js +45 -30
  56. package/esm/deprecated/index.js +8 -14
  57. package/esm/index.d.js +1 -2
  58. package/esm/index.js +11 -8
  59. package/esm/props.js +36 -42
  60. package/esm/utils.js +23 -16
  61. package/package.json +15 -15
  62. package/types/components/PillGroup.d.ts +1 -1
  63. package/types/deprecated/DropdownPill.d.ts +1 -10
  64. package/types/deprecated/LabeledDropdownPills.d.ts +1 -12
  65. package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.d.ts +1 -3
  66. package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.d.ts +1 -3
  67. package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.d.ts +0 -1
  68. package/types/deprecated/LabeledPills.d.ts +1 -8
  69. package/types/deprecated/OverflowPill.d.ts +1 -5
  70. package/types/deprecated/Pill.d.ts +1 -9
  71. package/types/deprecated/PillGroup.d.ts +1 -7
  72. package/types/deprecated/ReadOnlyPill.d.ts +1 -8
  73. package/types/deprecated/RemovablePill.d.ts +1 -7
  74. package/cjs/components/Pill.js.map +0 -7
  75. package/cjs/components/PillButton.js.map +0 -7
  76. package/cjs/components/PillGroup.js.map +0 -7
  77. package/cjs/components/index.js.map +0 -7
  78. package/cjs/components/styled.js.map +0 -7
  79. package/cjs/components/types/DropdownPill.js.map +0 -7
  80. package/cjs/components/types/InputPill.js.map +0 -7
  81. package/cjs/components/types/LabelPill.js.map +0 -7
  82. package/cjs/components/types/ReadOnlyPill.js.map +0 -7
  83. package/cjs/components/types/RemovablePill.js.map +0 -7
  84. package/cjs/components/types/ValuePill.js.map +0 -7
  85. package/cjs/components/types/index.js.map +0 -7
  86. package/cjs/deprecated/DropdownPill.js.map +0 -7
  87. package/cjs/deprecated/InputPill.js.map +0 -7
  88. package/cjs/deprecated/LabeledDropdownPills.js.map +0 -7
  89. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +0 -7
  90. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +0 -7
  91. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +0 -7
  92. package/cjs/deprecated/LabeledDropdownPillsTypes/utils.js.map +0 -7
  93. package/cjs/deprecated/LabeledPills.js.map +0 -7
  94. package/cjs/deprecated/OverflowPill.js.map +0 -7
  95. package/cjs/deprecated/Pill.js.map +0 -7
  96. package/cjs/deprecated/PillGroup.js.map +0 -7
  97. package/cjs/deprecated/ReadOnlyPill.js.map +0 -7
  98. package/cjs/deprecated/RemovablePill.js.map +0 -7
  99. package/cjs/deprecated/index.js.map +0 -7
  100. package/cjs/index.d.js.map +0 -7
  101. package/cjs/index.js.map +0 -7
  102. package/cjs/props.js.map +0 -7
  103. package/cjs/utils.js.map +0 -7
  104. package/esm/components/Pill.js.map +0 -7
  105. package/esm/components/PillButton.js.map +0 -7
  106. package/esm/components/PillGroup.js.map +0 -7
  107. package/esm/components/index.js.map +0 -7
  108. package/esm/components/styled.js.map +0 -7
  109. package/esm/components/types/DropdownPill.js.map +0 -7
  110. package/esm/components/types/InputPill.js.map +0 -7
  111. package/esm/components/types/LabelPill.js.map +0 -7
  112. package/esm/components/types/ReadOnlyPill.js.map +0 -7
  113. package/esm/components/types/RemovablePill.js.map +0 -7
  114. package/esm/components/types/ValuePill.js.map +0 -7
  115. package/esm/components/types/index.js.map +0 -7
  116. package/esm/deprecated/DropdownPill.js.map +0 -7
  117. package/esm/deprecated/InputPill.js.map +0 -7
  118. package/esm/deprecated/LabeledDropdownPills.js.map +0 -7
  119. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +0 -7
  120. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +0 -7
  121. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +0 -7
  122. package/esm/deprecated/LabeledDropdownPillsTypes/utils.js.map +0 -7
  123. package/esm/deprecated/LabeledPills.js.map +0 -7
  124. package/esm/deprecated/OverflowPill.js.map +0 -7
  125. package/esm/deprecated/Pill.js.map +0 -7
  126. package/esm/deprecated/PillGroup.js.map +0 -7
  127. package/esm/deprecated/ReadOnlyPill.js.map +0 -7
  128. package/esm/deprecated/RemovablePill.js.map +0 -7
  129. package/esm/deprecated/index.js.map +0 -7
  130. package/esm/index.d.js.map +0 -7
  131. package/esm/index.js.map +0 -7
  132. package/esm/props.js.map +0 -7
  133. package/esm/utils.js.map +0 -7
@@ -1,102 +1,126 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { isFunction, addOrRemove } from "@elliemae/ds-utilities";
4
- import { PillGroup } from "../PillGroup";
5
- import { RemovablePill } from "../RemovablePill";
6
- import { DropdownPill } from "../DropdownPill";
1
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
2
+ import 'core-js/modules/esnext.iterator.for-each.js';
3
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
5
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
6
+ import 'core-js/modules/esnext.async-iterator.map.js';
7
+ import 'core-js/modules/esnext.iterator.map.js';
8
+ import 'core-js/modules/web.dom-collections.iterator.js';
9
+ import 'core-js/modules/esnext.async-iterator.filter.js';
10
+ import 'core-js/modules/esnext.iterator.constructor.js';
11
+ import 'core-js/modules/esnext.iterator.filter.js';
12
+ import { createElement } from 'react';
13
+ import { isFunction, addOrRemove } from '@elliemae/ds-utilities';
14
+ import { PillGroup } from '../PillGroup.js';
15
+ import { RemovablePill } from '../RemovablePill.js';
16
+ import { DropdownPill } from '../DropdownPill.js';
17
+ import { jsx } from 'react/jsx-runtime';
18
+
19
+ const _excluded = ["label", "options", "value", "onChange", "onRemove", "value", "placeholder", "onFocusNextGroup", "onFocusPreviousGroup", "onFocusGroupSet", "maxWidth", "minWidth"];
20
+
21
+ 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; }
22
+
23
+ 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; }
24
+
7
25
  function renderMenuItems(options, factory) {
8
26
  return options.map((option, index) => {
9
- const ItemComponent = factory("radio");
10
- if (option.type === "submenu") {
11
- const SubmenuComponent = factory("submenu");
12
- const ChildComponent = factory("selection-group");
13
- return /* @__PURE__ */ React2.createElement(SubmenuComponent, {
14
- ...option,
27
+ const ItemComponent = factory('radio');
28
+
29
+ if (option.type === 'submenu') {
30
+ const SubmenuComponent = factory('submenu');
31
+ const ChildComponent = factory('selection-group');
32
+ return /*#__PURE__*/createElement(SubmenuComponent, _objectSpread(_objectSpread({}, option), {}, {
15
33
  key: option.id,
16
34
  item: option
17
- }, /* @__PURE__ */ React2.createElement(ChildComponent, {
18
- ...option,
35
+ }), /*#__PURE__*/jsx(ChildComponent, _objectSpread(_objectSpread({}, option), {}, {
19
36
  id: option.id,
20
37
  item: option,
21
38
  items: option.items,
22
- itemValueAccessor: (item) => item,
39
+ itemValueAccessor: item => item,
23
40
  multi: true
24
- }));
41
+ })));
25
42
  }
26
- return /* @__PURE__ */ React2.createElement(ItemComponent, {
27
- ...option,
43
+
44
+ return /*#__PURE__*/createElement(ItemComponent, _objectSpread(_objectSpread({}, option), {}, {
28
45
  key: option.id || index,
29
46
  item: option
30
- });
47
+ }));
31
48
  });
32
49
  }
50
+
33
51
  const getSubmenuOptionLabelById = (options, id) => {
34
- const index = options.findIndex((option) => option.id === id);
35
- return index ? options[index].label : "";
52
+ const index = options.findIndex(option => option.id === id);
53
+ return index ? options[index].label : '';
36
54
  };
37
- function LabeledDropdownCascadeMenuPill({
38
- label,
39
- options,
40
- value: optionValue,
41
- onChange,
42
- onRemove,
43
- value: selection = {},
44
- placeholder = "---",
45
- onFocusNextGroup,
46
- onFocusPreviousGroup,
47
- onFocusGroupSet,
48
- maxWidth,
49
- minWidth,
50
- ...menuProps
51
- }) {
55
+
56
+ function LabeledDropdownCascadeMenuPill(_ref) {
57
+ let {
58
+ label,
59
+ options,
60
+ value: optionValue,
61
+ onChange,
62
+ onRemove,
63
+ value: selection = {},
64
+ placeholder = '---',
65
+ onFocusNextGroup,
66
+ onFocusPreviousGroup,
67
+ onFocusGroupSet,
68
+ maxWidth,
69
+ minWidth
70
+ } = _ref,
71
+ menuProps = _objectWithoutProperties(_ref, _excluded);
72
+
52
73
  const selectionId = Object.keys(selection)[0];
53
- const selectionValues = selection[selectionId] || "";
74
+ const selectionValues = selection[selectionId] || '';
54
75
  const dropdownLabel = Array.isArray(selectionValues) ? getSubmenuOptionLabelById(options, selectionId) : selectionValues;
55
- const handleSelectChange = ({ item, group }) => {
76
+
77
+ const handleSelectChange = _ref2 => {
78
+ let {
79
+ item,
80
+ group
81
+ } = _ref2;
82
+
56
83
  if (isFunction(onChange)) {
57
84
  const nextSelection = group ? {
58
- [group.id]: addOrRemove([...selection[group.id] || []], item, (o) => o.id)
85
+ [group.id]: addOrRemove([...(selection[group.id] || [])], item, o => o.id)
59
86
  } : {
60
87
  [item.id]: item.label
61
88
  };
62
89
  onChange(nextSelection);
63
90
  }
64
91
  };
65
- const removeOption = (option) => {
92
+
93
+ const removeOption = option => {
66
94
  if (isFunction(onChange)) {
67
95
  const nextSelection = {
68
- [selectionId]: selectionValues.filter((val) => option.id !== val.id)
96
+ [selectionId]: selectionValues.filter(val => option.id !== val.id)
69
97
  };
70
98
  onChange(nextSelection);
71
99
  }
100
+
72
101
  onRemove(option);
73
102
  };
74
- return /* @__PURE__ */ React2.createElement(PillGroup, {
75
- onFocusGroupSet,
76
- onFocusNextGroup,
77
- onFocusPreviousGroup
78
- }, /* @__PURE__ */ React2.createElement(DropdownPill, {
79
- ...menuProps,
103
+
104
+ return /*#__PURE__*/_jsx(PillGroup, {
105
+ onFocusGroupSet: onFocusGroupSet,
106
+ onFocusNextGroup: onFocusNextGroup,
107
+ onFocusPreviousGroup: onFocusPreviousGroup
108
+ }, void 0, /*#__PURE__*/jsx(DropdownPill, _objectSpread(_objectSpread({}, menuProps), {}, {
80
109
  itemsRenderer: renderMenuItems,
81
110
  label: dropdownLabel || placeholder,
82
- maxWidth,
83
- minWidth,
111
+ maxWidth: maxWidth,
112
+ minWidth: minWidth,
84
113
  onSelectChange: handleSelectChange,
85
- options,
114
+ options: options,
86
115
  selection: {
87
- [selectionId]: Array.isArray(selectionValues) ? selectionValues.map((v) => v.id) : selectionValues
116
+ [selectionId]: Array.isArray(selectionValues) ? selectionValues.map(v => v.id) : selectionValues
88
117
  },
89
118
  singleGroupSelection: true,
90
119
  variant: "title"
91
- }), Array.isArray(selectionValues) && selectionValues.map((option) => /* @__PURE__ */ React2.createElement(RemovablePill, {
92
- key: option.id,
120
+ })), Array.isArray(selectionValues) && selectionValues.map(option => /*#__PURE__*/_jsx(RemovablePill, {
93
121
  label: option.label,
94
122
  onRemove: () => removeOption(option)
95
- })));
123
+ }, option.id)));
96
124
  }
97
- var LabeledDropdownCascadeMenuPill_default = LabeledDropdownCascadeMenuPill;
98
- export {
99
- LabeledDropdownCascadeMenuPill,
100
- LabeledDropdownCascadeMenuPill_default as default
101
- };
102
- //# sourceMappingURL=LabeledDropdownCascadeMenuPill.js.map
125
+
126
+ export { LabeledDropdownCascadeMenuPill as default };
@@ -1,22 +1,42 @@
1
- import * as React from "react";
2
- import React2, { useState, useEffect, useCallback } from "react";
3
- import { find } from "lodash";
4
- import { isFunction, addOrRemove } from "@elliemae/ds-utilities";
5
- import { RemovablePill } from "../RemovablePill";
6
- import { Pill } from "../Pill";
7
- import { OverflowPill } from "../OverflowPill";
8
- import { DropdownPill } from "../DropdownPill";
9
- function LabeledDropdownMultiPills({
10
- label,
11
- options = [],
12
- value = [],
13
- onSelect = () => null,
14
- onRemove = () => null,
15
- onChange,
16
- maxWidth,
17
- minWidth,
18
- ...menuProps
19
- }) {
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
+ import 'core-js/modules/web.dom-collections.iterator.js';
5
+ import 'core-js/modules/esnext.async-iterator.filter.js';
6
+ import 'core-js/modules/esnext.iterator.constructor.js';
7
+ import 'core-js/modules/esnext.iterator.filter.js';
8
+ import 'core-js/modules/esnext.async-iterator.map.js';
9
+ import 'core-js/modules/esnext.iterator.map.js';
10
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
11
+ import 'core-js/modules/esnext.iterator.for-each.js';
12
+ import { useState, useEffect, useCallback } from 'react';
13
+ import { find } from 'lodash';
14
+ import { isFunction, addOrRemove } from '@elliemae/ds-utilities';
15
+ import { RemovablePill } from '../RemovablePill.js';
16
+ import { Pill } from '../Pill.js';
17
+ import { OverflowPill } from '../OverflowPill.js';
18
+ import { DropdownPill } from '../DropdownPill.js';
19
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
20
+
21
+ const _excluded = ["label", "options", "value", "onSelect", "onRemove", "onChange", "maxWidth", "minWidth"];
22
+
23
+ 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; }
24
+
25
+ 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; }
26
+ function LabeledDropdownMultiPills(_ref) {
27
+ let {
28
+ label,
29
+ options = [],
30
+ value = [],
31
+ onSelect = () => null,
32
+ onRemove = () => null,
33
+ onChange,
34
+ // if this is defined, then it's calculating the next result onSelect or onRemove
35
+ maxWidth,
36
+ minWidth
37
+ } = _ref,
38
+ menuProps = _objectWithoutProperties(_ref, _excluded);
39
+
20
40
  const [totalDefaultOptions, setTotalDefaultOptions] = useState(0);
21
41
  const [selectedOptions, setSelectedOptions] = useState(value);
22
42
  const [allOptions, setAllOptions] = useState(options);
@@ -24,19 +44,28 @@ function LabeledDropdownMultiPills({
24
44
  const overflowQuantity = 3;
25
45
  useEffect(() => setSelectedOptions(value), [value]);
26
46
  useEffect(() => {
27
- const newOptions = allOptions.filter((option) => option.fixedItem);
47
+ const newOptions = allOptions.filter(option => option.fixedItem);
48
+
28
49
  if (newOptions.length > 0) {
29
50
  setSelectedOptions(newOptions);
30
51
  }
52
+
31
53
  setTotalDefaultOptions(newOptions.length);
32
54
  }, []);
33
55
  useEffect(() => {
34
56
  if (totalDefaultOptions) {
35
- const newOptions = allOptions.map((opt) => {
36
- if (selectedOptions.length <= totalDefaultOptions && find(selectedOptions, { id: opt.id })) {
37
- return { ...opt, fixedItem: true };
57
+ const newOptions = allOptions.map(opt => {
58
+ if (selectedOptions.length <= totalDefaultOptions && find(selectedOptions, {
59
+ id: opt.id
60
+ })) {
61
+ return _objectSpread(_objectSpread({}, opt), {}, {
62
+ fixedItem: true
63
+ });
38
64
  }
39
- return { ...opt, fixedItem: false };
65
+
66
+ return _objectSpread(_objectSpread({}, opt), {}, {
67
+ fixedItem: false
68
+ });
40
69
  });
41
70
  setAllOptions(newOptions);
42
71
  }
@@ -47,70 +76,70 @@ function LabeledDropdownMultiPills({
47
76
  setOverflowOptions(overflow);
48
77
  }
49
78
  }, [selectedOptions]);
50
- const selectOption = useCallback((option) => {
79
+ const selectOption = useCallback(option => {
51
80
  if (!option.fixedItem) {
52
81
  if (isFunction(onChange)) {
53
- const nextValue = addOrRemove(selectedOptions, option, (item) => item.id);
82
+ const nextValue = addOrRemove(selectedOptions, option, item => item.id);
54
83
  setSelectedOptions(nextValue);
55
84
  onChange(nextValue);
56
85
  }
86
+
57
87
  onSelect(option);
58
88
  }
59
89
  }, [selectedOptions]);
60
- const removeOption = useCallback((option) => {
90
+ const removeOption = useCallback(option => {
61
91
  if (!option.fixedItem || selectedOptions.length > totalDefaultOptions) {
62
92
  if (isFunction(onChange)) {
63
- const nextValue = selectedOptions.filter((val) => option.id !== val.id);
93
+ const nextValue = selectedOptions.filter(val => option.id !== val.id);
64
94
  setSelectedOptions(nextValue);
65
95
  onChange(nextValue);
66
96
  }
97
+
67
98
  onRemove(option);
68
99
  }
69
100
  }, [selectedOptions]);
101
+
70
102
  const typeOfPill = () => {
71
103
  if (selectedOptions.length > totalDefaultOptions) {
72
104
  return RemovablePill;
73
105
  }
106
+
74
107
  return Pill;
75
108
  };
76
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(DropdownPill, {
77
- ...menuProps,
78
- focusOnOpen: false,
79
- label,
80
- maxWidth,
81
- minWidth,
82
- onSelectMenuItem: selectOption,
83
- options: [
84
- {
85
- ...menuProps,
86
- type: "SelectionGroup",
87
- id: "multi-selection-views",
109
+
110
+ return /*#__PURE__*/jsxs(Fragment, {
111
+ children: [/*#__PURE__*/jsx(DropdownPill, _objectSpread(_objectSpread({}, menuProps), {}, {
112
+ focusOnOpen: false,
113
+ label: label,
114
+ maxWidth: maxWidth,
115
+ minWidth: minWidth,
116
+ onSelectMenuItem: selectOption,
117
+ options: [_objectSpread(_objectSpread({}, menuProps), {}, {
118
+ type: 'SelectionGroup',
119
+ id: 'multi-selection-views',
88
120
  multi: true,
89
121
  items: allOptions
122
+ })],
123
+ selection: {
124
+ 'multi-selection-views': selectedOptions ? selectedOptions.map(o => o.id) : ''
125
+ },
126
+ variant: "title"
127
+ })), selectedOptions && selectedOptions.map((option, index) => {
128
+ const TypeOfPill = typeOfPill();
129
+
130
+ if (index < overflowQuantity) {
131
+ return /*#__PURE__*/_jsx(TypeOfPill, {
132
+ label: option.label,
133
+ onRemove: () => removeOption(option)
134
+ }, option.id);
90
135
  }
91
- ],
92
- selection: {
93
- "multi-selection-views": selectedOptions ? selectedOptions.map((o) => o.id) : ""
94
- },
95
- variant: "title"
96
- }), selectedOptions && selectedOptions.map((option, index) => {
97
- const TypeOfPill = typeOfPill();
98
- if (index < overflowQuantity) {
99
- return /* @__PURE__ */ React2.createElement(TypeOfPill, {
100
- key: option.id,
101
- label: option.label,
102
- onRemove: () => removeOption(option)
103
- });
104
- }
105
- return null;
106
- }), selectedOptions && selectedOptions.length > overflowQuantity && /* @__PURE__ */ React2.createElement(OverflowPill, {
107
- label: `+ ${selectedOptions.length - overflowQuantity}`,
108
- options: overflowOptions
109
- }));
136
+
137
+ return null;
138
+ }), selectedOptions && selectedOptions.length > overflowQuantity && /*#__PURE__*/_jsx(OverflowPill, {
139
+ label: "+ ".concat(selectedOptions.length - overflowQuantity),
140
+ options: overflowOptions
141
+ })]
142
+ });
110
143
  }
111
- var LabeledDropdownMultiPill_default = LabeledDropdownMultiPills;
112
- export {
113
- LabeledDropdownMultiPills,
114
- LabeledDropdownMultiPill_default as default
115
- };
116
- //# sourceMappingURL=LabeledDropdownMultiPill.js.map
144
+
145
+ export { LabeledDropdownMultiPills as default };
@@ -1,30 +1,52 @@
1
- import * as React from "react";
2
- import React2, { useCallback, useState, useEffect, useLayoutEffect } from "react";
3
- import PropTypes from "prop-types";
4
- import { isFunction, isString, useShouldRecalculate, usePrevious } from "@elliemae/ds-utilities";
5
- import { DropdownPill } from "../DropdownPill";
6
- import { InputPill } from "../InputPill";
7
- import { Pill } from "../Pill";
8
- import { RemovablePill } from "../RemovablePill";
9
- import { hasOptionChanged } from "./utils";
10
- function LabeledDropdownSinglePill({
11
- label,
12
- labelIsValue = false,
13
- options,
14
- value,
15
- onSelect = () => null,
16
- onChange,
17
- maxWidth,
18
- minWidth,
19
- fixed = false,
20
- ...menuProps
21
- }) {
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
+ import 'core-js/modules/web.dom-collections.iterator.js';
5
+ import 'core-js/modules/esnext.async-iterator.find.js';
6
+ import 'core-js/modules/esnext.iterator.constructor.js';
7
+ import 'core-js/modules/esnext.iterator.find.js';
8
+ import 'core-js/modules/esnext.async-iterator.filter.js';
9
+ import 'core-js/modules/esnext.iterator.filter.js';
10
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
11
+ import 'core-js/modules/esnext.iterator.for-each.js';
12
+ import { useState, useEffect, useLayoutEffect, useCallback } from 'react';
13
+ import { usePrevious, useShouldRecalculate, isFunction, isString } from '@elliemae/ds-utilities';
14
+ import { DropdownPill } from '../DropdownPill.js';
15
+ import { InputPill } from '../InputPill.js';
16
+ import { Pill } from '../Pill.js';
17
+ import { RemovablePill } from '../RemovablePill.js';
18
+ import { hasOptionChanged } from './utils.js';
19
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
20
+
21
+ var _Pill;
22
+
23
+ const _excluded = ["label", "labelIsValue", "options", "value", "onSelect", "onChange", "maxWidth", "minWidth", "fixed"],
24
+ _excluded2 = ["input", "onChangeInput"];
25
+
26
+ 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; }
27
+
28
+ 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; }
29
+ function LabeledDropdownSinglePill(_ref) {
30
+ let {
31
+ label,
32
+ labelIsValue = false,
33
+ options,
34
+ value,
35
+ onSelect = () => null,
36
+ onChange,
37
+ maxWidth,
38
+ minWidth,
39
+ fixed = false
40
+ } = _ref,
41
+ menuProps = _objectWithoutProperties(_ref, _excluded);
42
+
22
43
  const [optionValue, setOptionValue] = useState(value);
23
44
  const prevOptions = usePrevious(options);
24
45
  const areOptionsEqual = useShouldRecalculate(hasOptionChanged(prevOptions, options));
25
46
  useEffect(() => setOptionValue(value), [value]);
26
47
  useEffect(() => {
27
- const selectedValue = options.find((option) => option.selected);
48
+ const selectedValue = options.find(option => option.selected);
49
+
28
50
  if (selectedValue) {
29
51
  setOptionValue(selectedValue);
30
52
  } else if (!selectedValue) {
@@ -33,93 +55,100 @@ function LabeledDropdownSinglePill({
33
55
  }, [areOptionsEqual]);
34
56
  useLayoutEffect(() => {
35
57
  if (optionValue) {
36
- const selectedValue = options.find((option) => option.id === optionValue.id);
58
+ const selectedValue = options.find(option => option.id === optionValue.id);
37
59
  setOptionValue(selectedValue);
38
60
  }
39
61
  }, [options]);
40
- const selectOption = useCallback((option) => {
62
+ const selectOption = useCallback(option => {
41
63
  if (isFunction(onChange)) {
42
64
  onChange(option);
43
65
  }
66
+
44
67
  setOptionValue(option);
45
68
  onSelect(option);
46
69
  }, [onChange, onSelect]);
47
- const onChangeInputValue = useCallback(({ target: { value: inputValue } }) => {
48
- const { onChangeInput } = optionValue;
70
+ const onChangeInputValue = useCallback(_ref2 => {
71
+ let {
72
+ target: {
73
+ value: inputValue
74
+ }
75
+ } = _ref2;
76
+ const {
77
+ onChangeInput
78
+ } = optionValue;
49
79
  onChangeInput && onChangeInput(inputValue);
50
80
  }, [optionValue]);
51
- const removeOption = (removedOption) => {
52
- const { onRemove } = menuProps;
53
- const { onChangeInput } = optionValue;
81
+
82
+ const removeOption = removedOption => {
83
+ const {
84
+ onRemove
85
+ } = menuProps;
86
+ const {
87
+ onChangeInput
88
+ } = optionValue;
54
89
  setOptionValue(null);
55
- onChangeInput && onChangeInput("");
56
- const newOption = { ...removedOption, input: "" };
90
+ onChangeInput && onChangeInput('');
91
+
92
+ const newOption = _objectSpread(_objectSpread({}, removedOption), {}, {
93
+ input: ''
94
+ });
95
+
57
96
  onRemove && onRemove(newOption, removedOption);
58
97
  };
59
- const renderPill = (option, fixed2) => {
60
- const { input, onChangeInput, ...otherProps } = option;
98
+
99
+ const renderPill = (option, fixed) => {
100
+ const {
101
+ input,
102
+ onChangeInput
103
+ } = option,
104
+ otherProps = _objectWithoutProperties(option, _excluded2);
105
+
61
106
  let SelectedPill;
107
+
62
108
  if (isString(input)) {
63
109
  SelectedPill = InputPill;
64
- } else if (fixed2) {
110
+ } else if (fixed) {
65
111
  SelectedPill = Pill;
66
112
  } else {
67
113
  SelectedPill = RemovablePill;
68
114
  }
69
- return /* @__PURE__ */ React2.createElement(SelectedPill, {
70
- key: option.id,
115
+
116
+ return /*#__PURE__*/jsx(SelectedPill, _objectSpread({
71
117
  label: option.label,
72
118
  onChange: onChangeInputValue,
73
- onRemove: (e) => removeOption(option, e),
74
- value: input,
75
- ...otherProps
76
- });
119
+ onRemove: e => removeOption(option),
120
+ value: input
121
+ }, otherProps), option.id);
77
122
  };
123
+
78
124
  const renderSelection = () => {
79
125
  if (!labelIsValue) {
80
- if (optionValue)
81
- return renderPill(optionValue, fixed);
82
- return /* @__PURE__ */ React2.createElement(Pill, {
126
+ if (optionValue) return renderPill(optionValue, fixed);
127
+ return _Pill || (_Pill = /*#__PURE__*/_jsx(Pill, {
83
128
  label: "-"
84
- });
129
+ }));
85
130
  }
86
131
  };
87
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(DropdownPill, {
88
- ...menuProps,
89
- label: !labelIsValue ? label : optionValue?.label,
90
- maxWidth,
91
- minWidth,
92
- onSelectMenuItem: selectOption,
93
- options: [
94
- {
95
- ...menuProps,
96
- type: "SelectionGroup",
97
- id: "multi-selection-views",
132
+
133
+ return /*#__PURE__*/jsxs(Fragment, {
134
+ children: [/*#__PURE__*/jsx(DropdownPill, _objectSpread(_objectSpread({}, menuProps), {}, {
135
+ label: !labelIsValue ? label : optionValue === null || optionValue === void 0 ? void 0 : optionValue.label,
136
+ maxWidth: maxWidth,
137
+ minWidth: minWidth,
138
+ onSelectMenuItem: selectOption,
139
+ options: [_objectSpread(_objectSpread({}, menuProps), {}, {
140
+ type: 'SelectionGroup',
141
+ id: 'multi-selection-views',
98
142
  multi: false,
99
143
  items: options,
100
144
  closeOnClick: true
101
- }
102
- ],
103
- selection: {
104
- "multi-selection-views": optionValue ? [optionValue?.id] : ""
105
- },
106
- variant: "title"
107
- }), renderSelection());
145
+ })],
146
+ selection: {
147
+ 'multi-selection-views': optionValue ? [optionValue === null || optionValue === void 0 ? void 0 : optionValue.id] : ''
148
+ },
149
+ variant: "title"
150
+ })), renderSelection()]
151
+ });
108
152
  }
109
- LabeledDropdownSinglePill.propTypes = {
110
- label: PropTypes.string,
111
- labelIsValue: PropTypes.bool,
112
- options: PropTypes.array,
113
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
114
- onSelect: PropTypes.func,
115
- onChange: PropTypes.func,
116
- maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
117
- minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
118
- fixed: PropTypes.bool
119
- };
120
- var LabeledDropdownSinglePill_default = LabeledDropdownSinglePill;
121
- export {
122
- LabeledDropdownSinglePill,
123
- LabeledDropdownSinglePill_default as default
124
- };
125
- //# sourceMappingURL=LabeledDropdownSinglePill.js.map
153
+
154
+ export { LabeledDropdownSinglePill as default };
@@ -1,15 +1,16 @@
1
- import * as React from "react";
2
- import { isEqual } from "@elliemae/ds-utilities";
3
- import { omit } from "lodash";
1
+ import 'core-js/modules/esnext.async-iterator.map.js';
2
+ import 'core-js/modules/esnext.iterator.map.js';
3
+ import { isEqual } from '@elliemae/ds-utilities';
4
+ import { omit } from 'lodash';
5
+
4
6
  const hasOptionChanged = (prevOptions, options) => {
5
7
  if (prevOptions && options) {
6
- const prevOptionsOmited = prevOptions.map((option) => omit(option, ["input", "onChangeInput", "mask"]));
7
- const optionsOmited = options.map((option) => omit(option, ["input", "onChangeInput", "mask"]));
8
+ const prevOptionsOmited = prevOptions.map(option => omit(option, ['input', 'onChangeInput', 'mask']));
9
+ const optionsOmited = options.map(option => omit(option, ['input', 'onChangeInput', 'mask']));
8
10
  return isEqual(prevOptionsOmited, optionsOmited);
9
11
  }
12
+
10
13
  return false;
11
14
  };
12
- export {
13
- hasOptionChanged
14
- };
15
- //# sourceMappingURL=utils.js.map
15
+
16
+ export { hasOptionChanged };