@elliemae/ds-pills 2.3.0-alpha.8 → 2.3.0-next.2

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 (216) hide show
  1. package/cjs/components/Pill.js +53 -0
  2. package/cjs/components/PillButton.js +56 -0
  3. package/cjs/components/PillGroup.js +64 -0
  4. package/cjs/components/index.js +17 -0
  5. package/cjs/components/styled.js +85 -0
  6. package/cjs/components/types/DropdownPill.js +86 -0
  7. package/cjs/components/types/InputPill.js +74 -0
  8. package/cjs/components/types/LabelPill.js +46 -0
  9. package/cjs/components/types/ReadOnlyPill.js +50 -0
  10. package/cjs/components/types/RemovablePill.js +72 -0
  11. package/cjs/components/types/ValuePill.js +54 -0
  12. package/cjs/components/types/index.js +19 -0
  13. package/cjs/deprecated/DropdownPill.js +113 -0
  14. package/cjs/deprecated/InputPill.js +84 -0
  15. package/cjs/deprecated/LabeledDropdownPills.js +106 -0
  16. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +134 -0
  17. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +153 -0
  18. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +162 -0
  19. package/cjs/deprecated/LabeledDropdownPillsTypes/utils.js +20 -0
  20. package/cjs/deprecated/LabeledPills.js +62 -0
  21. package/cjs/deprecated/OverflowPill.js +73 -0
  22. package/cjs/deprecated/Pill.js +88 -0
  23. package/cjs/deprecated/PillGroup.js +72 -0
  24. package/cjs/deprecated/ReadOnlyPill.js +101 -0
  25. package/cjs/deprecated/RemovablePill.js +74 -0
  26. package/cjs/deprecated/index.js +33 -0
  27. package/cjs/index.d.js +2 -0
  28. package/cjs/index.js +43 -0
  29. package/cjs/props.js +69 -0
  30. package/cjs/utils.js +28 -0
  31. package/esm/components/Pill.js +44 -0
  32. package/esm/components/PillButton.js +46 -0
  33. package/esm/components/PillGroup.js +53 -0
  34. package/esm/components/index.js +3 -0
  35. package/esm/components/styled.js +67 -0
  36. package/esm/components/types/DropdownPill.js +76 -0
  37. package/esm/components/types/InputPill.js +65 -0
  38. package/esm/components/types/LabelPill.js +37 -0
  39. package/esm/components/types/ReadOnlyPill.js +41 -0
  40. package/esm/components/types/RemovablePill.js +63 -0
  41. package/esm/components/types/ValuePill.js +45 -0
  42. package/esm/components/types/index.js +6 -0
  43. package/esm/deprecated/DropdownPill.js +100 -0
  44. package/esm/deprecated/InputPill.js +74 -0
  45. package/esm/deprecated/LabeledDropdownPills.js +95 -0
  46. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +126 -0
  47. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +145 -0
  48. package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +154 -0
  49. package/esm/deprecated/LabeledDropdownPillsTypes/utils.js +16 -0
  50. package/esm/deprecated/LabeledPills.js +53 -0
  51. package/esm/deprecated/OverflowPill.js +62 -0
  52. package/esm/deprecated/Pill.js +76 -0
  53. package/esm/deprecated/PillGroup.js +60 -0
  54. package/esm/deprecated/ReadOnlyPill.js +90 -0
  55. package/esm/deprecated/RemovablePill.js +64 -0
  56. package/esm/deprecated/index.js +8 -0
  57. package/esm/index.d.js +1 -0
  58. package/esm/index.js +11 -0
  59. package/esm/props.js +60 -0
  60. package/esm/utils.js +24 -0
  61. package/package.json +86 -88
  62. package/types/components/Pill.d.ts +5 -0
  63. package/types/components/PillButton.d.ts +5 -0
  64. package/types/components/PillGroup.d.ts +13 -0
  65. package/types/components/index.d.ts +3 -0
  66. package/types/components/styled.d.ts +24 -0
  67. package/types/components/types/DropdownPill.d.ts +3 -0
  68. package/types/components/types/InputPill.d.ts +3 -0
  69. package/types/components/types/LabelPill.d.ts +3 -0
  70. package/types/components/types/ReadOnlyPill.d.ts +3 -0
  71. package/types/components/types/RemovablePill.d.ts +3 -0
  72. package/types/components/types/ValuePill.d.ts +3 -0
  73. package/types/components/types/index.d.ts +6 -0
  74. package/types/deprecated/DropdownPill.d.ts +66 -0
  75. package/types/deprecated/InputPill.d.ts +10 -0
  76. package/types/deprecated/LabeledDropdownPills.d.ts +82 -0
  77. package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.d.ts +15 -0
  78. package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.d.ts +13 -0
  79. package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.d.ts +28 -0
  80. package/types/deprecated/LabeledDropdownPillsTypes/utils.d.ts +1 -0
  81. package/types/deprecated/LabeledPills.d.ts +52 -0
  82. package/types/deprecated/OverflowPill.d.ts +33 -0
  83. package/types/deprecated/Pill.d.ts +59 -0
  84. package/types/deprecated/PillGroup.d.ts +50 -0
  85. package/types/deprecated/ReadOnlyPill.d.ts +56 -0
  86. package/types/deprecated/RemovablePill.d.ts +49 -0
  87. package/types/deprecated/index.d.ts +9 -0
  88. package/types/index.d.ts +3 -0
  89. package/types/props.d.ts +92 -0
  90. package/types/tests/DSPill.test.d.ts +1 -0
  91. package/types/tests/DSPillGroup.test.d.ts +1 -0
  92. package/types/tests/events/DSPill.events.keyboard.test.d.ts +1 -0
  93. package/types/tests/events/DSPill.events.test.d.ts +1 -0
  94. package/types/tests/events/DSPillGroup.events.keyboard.test.d.ts +1 -0
  95. package/types/tests/events/DSPillGroup.events.test.d.ts +1 -0
  96. package/types/utils.d.ts +4 -0
  97. package/dist/cjs/components/Pill.js +0 -60
  98. package/dist/cjs/components/Pill.js.map +0 -7
  99. package/dist/cjs/components/PillButton.js +0 -58
  100. package/dist/cjs/components/PillButton.js.map +0 -7
  101. package/dist/cjs/components/PillGroup.js +0 -72
  102. package/dist/cjs/components/PillGroup.js.map +0 -7
  103. package/dist/cjs/components/index.js +0 -30
  104. package/dist/cjs/components/index.js.map +0 -7
  105. package/dist/cjs/components/styled.js +0 -235
  106. package/dist/cjs/components/styled.js.map +0 -7
  107. package/dist/cjs/components/types/DropdownPill.js +0 -88
  108. package/dist/cjs/components/types/DropdownPill.js.map +0 -7
  109. package/dist/cjs/components/types/InputPill.js +0 -84
  110. package/dist/cjs/components/types/InputPill.js.map +0 -7
  111. package/dist/cjs/components/types/LabelPill.js +0 -52
  112. package/dist/cjs/components/types/LabelPill.js.map +0 -7
  113. package/dist/cjs/components/types/ReadOnlyPill.js +0 -55
  114. package/dist/cjs/components/types/ReadOnlyPill.js.map +0 -7
  115. package/dist/cjs/components/types/RemovablePill.js +0 -79
  116. package/dist/cjs/components/types/RemovablePill.js.map +0 -7
  117. package/dist/cjs/components/types/ValuePill.js +0 -59
  118. package/dist/cjs/components/types/ValuePill.js.map +0 -7
  119. package/dist/cjs/components/types/index.js +0 -33
  120. package/dist/cjs/components/types/index.js.map +0 -7
  121. package/dist/cjs/deprecated/DropdownPill.js +0 -92
  122. package/dist/cjs/deprecated/DropdownPill.js.map +0 -7
  123. package/dist/cjs/deprecated/InputPill.js +0 -82
  124. package/dist/cjs/deprecated/InputPill.js.map +0 -7
  125. package/dist/cjs/deprecated/LabeledDropdownPills.js +0 -102
  126. package/dist/cjs/deprecated/LabeledDropdownPills.js.map +0 -7
  127. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +0 -131
  128. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +0 -7
  129. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +0 -145
  130. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +0 -7
  131. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +0 -154
  132. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +0 -7
  133. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/utils.js +0 -44
  134. package/dist/cjs/deprecated/LabeledDropdownPillsTypes/utils.js.map +0 -7
  135. package/dist/cjs/deprecated/LabeledPills.js +0 -75
  136. package/dist/cjs/deprecated/LabeledPills.js.map +0 -7
  137. package/dist/cjs/deprecated/OverflowPill.js +0 -79
  138. package/dist/cjs/deprecated/OverflowPill.js.map +0 -7
  139. package/dist/cjs/deprecated/Pill.js +0 -73
  140. package/dist/cjs/deprecated/Pill.js.map +0 -7
  141. package/dist/cjs/deprecated/PillGroup.js +0 -72
  142. package/dist/cjs/deprecated/PillGroup.js.map +0 -7
  143. package/dist/cjs/deprecated/ReadOnlyPill.js +0 -100
  144. package/dist/cjs/deprecated/ReadOnlyPill.js.map +0 -7
  145. package/dist/cjs/deprecated/RemovablePill.js +0 -78
  146. package/dist/cjs/deprecated/RemovablePill.js.map +0 -7
  147. package/dist/cjs/deprecated/index.js +0 -43
  148. package/dist/cjs/deprecated/index.js.map +0 -7
  149. package/dist/cjs/index.d.js +0 -27
  150. package/dist/cjs/index.d.js.map +0 -7
  151. package/dist/cjs/index.js +0 -37
  152. package/dist/cjs/index.js.map +0 -7
  153. package/dist/cjs/props.js +0 -95
  154. package/dist/cjs/props.js.map +0 -7
  155. package/dist/cjs/utils.js +0 -46
  156. package/dist/cjs/utils.js.map +0 -7
  157. package/dist/esm/components/Pill.js +0 -31
  158. package/dist/esm/components/Pill.js.map +0 -7
  159. package/dist/esm/components/PillButton.js +0 -29
  160. package/dist/esm/components/PillButton.js.map +0 -7
  161. package/dist/esm/components/PillGroup.js +0 -43
  162. package/dist/esm/components/PillGroup.js.map +0 -7
  163. package/dist/esm/components/index.js +0 -5
  164. package/dist/esm/components/index.js.map +0 -7
  165. package/dist/esm/components/styled.js +0 -206
  166. package/dist/esm/components/styled.js.map +0 -7
  167. package/dist/esm/components/types/DropdownPill.js +0 -59
  168. package/dist/esm/components/types/DropdownPill.js.map +0 -7
  169. package/dist/esm/components/types/InputPill.js +0 -55
  170. package/dist/esm/components/types/InputPill.js.map +0 -7
  171. package/dist/esm/components/types/LabelPill.js +0 -23
  172. package/dist/esm/components/types/LabelPill.js.map +0 -7
  173. package/dist/esm/components/types/ReadOnlyPill.js +0 -26
  174. package/dist/esm/components/types/ReadOnlyPill.js.map +0 -7
  175. package/dist/esm/components/types/RemovablePill.js +0 -50
  176. package/dist/esm/components/types/RemovablePill.js.map +0 -7
  177. package/dist/esm/components/types/ValuePill.js +0 -30
  178. package/dist/esm/components/types/ValuePill.js.map +0 -7
  179. package/dist/esm/components/types/index.js +0 -8
  180. package/dist/esm/components/types/index.js.map +0 -7
  181. package/dist/esm/deprecated/DropdownPill.js +0 -63
  182. package/dist/esm/deprecated/DropdownPill.js.map +0 -7
  183. package/dist/esm/deprecated/InputPill.js +0 -53
  184. package/dist/esm/deprecated/InputPill.js.map +0 -7
  185. package/dist/esm/deprecated/LabeledDropdownPills.js +0 -73
  186. package/dist/esm/deprecated/LabeledDropdownPills.js.map +0 -7
  187. package/dist/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +0 -102
  188. package/dist/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +0 -7
  189. package/dist/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +0 -116
  190. package/dist/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +0 -7
  191. package/dist/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +0 -125
  192. package/dist/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +0 -7
  193. package/dist/esm/deprecated/LabeledDropdownPillsTypes/utils.js +0 -15
  194. package/dist/esm/deprecated/LabeledDropdownPillsTypes/utils.js.map +0 -7
  195. package/dist/esm/deprecated/LabeledPills.js +0 -46
  196. package/dist/esm/deprecated/LabeledPills.js.map +0 -7
  197. package/dist/esm/deprecated/OverflowPill.js +0 -50
  198. package/dist/esm/deprecated/OverflowPill.js.map +0 -7
  199. package/dist/esm/deprecated/Pill.js +0 -44
  200. package/dist/esm/deprecated/Pill.js.map +0 -7
  201. package/dist/esm/deprecated/PillGroup.js +0 -43
  202. package/dist/esm/deprecated/PillGroup.js.map +0 -7
  203. package/dist/esm/deprecated/ReadOnlyPill.js +0 -71
  204. package/dist/esm/deprecated/ReadOnlyPill.js.map +0 -7
  205. package/dist/esm/deprecated/RemovablePill.js +0 -49
  206. package/dist/esm/deprecated/RemovablePill.js.map +0 -7
  207. package/dist/esm/deprecated/index.js +0 -14
  208. package/dist/esm/deprecated/index.js.map +0 -7
  209. package/dist/esm/index.d.js +0 -2
  210. package/dist/esm/index.d.js.map +0 -7
  211. package/dist/esm/index.js +0 -8
  212. package/dist/esm/index.js.map +0 -7
  213. package/dist/esm/props.js +0 -66
  214. package/dist/esm/props.js.map +0 -7
  215. package/dist/esm/utils.js +0 -17
  216. package/dist/esm/utils.js.map +0 -7
@@ -0,0 +1,154 @@
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
+
43
+ const [optionValue, setOptionValue] = useState(value);
44
+ const prevOptions = usePrevious(options);
45
+ const areOptionsEqual = useShouldRecalculate(hasOptionChanged(prevOptions, options));
46
+ useEffect(() => setOptionValue(value), [value]);
47
+ useEffect(() => {
48
+ const selectedValue = options.find(option => option.selected);
49
+
50
+ if (selectedValue) {
51
+ setOptionValue(selectedValue);
52
+ } else if (!selectedValue) {
53
+ setOptionValue(options[0]);
54
+ }
55
+ }, [areOptionsEqual]);
56
+ useLayoutEffect(() => {
57
+ if (optionValue) {
58
+ const selectedValue = options.find(option => option.id === optionValue.id);
59
+ setOptionValue(selectedValue);
60
+ }
61
+ }, [options]);
62
+ const selectOption = useCallback(option => {
63
+ if (isFunction(onChange)) {
64
+ onChange(option);
65
+ }
66
+
67
+ setOptionValue(option);
68
+ onSelect(option);
69
+ }, [onChange, onSelect]);
70
+ const onChangeInputValue = useCallback(_ref2 => {
71
+ let {
72
+ target: {
73
+ value: inputValue
74
+ }
75
+ } = _ref2;
76
+ const {
77
+ onChangeInput
78
+ } = optionValue;
79
+ onChangeInput && onChangeInput(inputValue);
80
+ }, [optionValue]);
81
+
82
+ const removeOption = removedOption => {
83
+ const {
84
+ onRemove
85
+ } = menuProps;
86
+ const {
87
+ onChangeInput
88
+ } = optionValue;
89
+ setOptionValue(null);
90
+ onChangeInput && onChangeInput('');
91
+
92
+ const newOption = _objectSpread(_objectSpread({}, removedOption), {}, {
93
+ input: ''
94
+ });
95
+
96
+ onRemove && onRemove(newOption, removedOption);
97
+ };
98
+
99
+ const renderPill = (option, fixed) => {
100
+ const {
101
+ input,
102
+ onChangeInput
103
+ } = option,
104
+ otherProps = _objectWithoutProperties(option, _excluded2);
105
+
106
+ let SelectedPill;
107
+
108
+ if (isString(input)) {
109
+ SelectedPill = InputPill;
110
+ } else if (fixed) {
111
+ SelectedPill = Pill;
112
+ } else {
113
+ SelectedPill = RemovablePill;
114
+ }
115
+
116
+ return /*#__PURE__*/jsx(SelectedPill, _objectSpread({
117
+ label: option.label,
118
+ onChange: onChangeInputValue,
119
+ onRemove: e => removeOption(option),
120
+ value: input
121
+ }, otherProps), option.id);
122
+ };
123
+
124
+ const renderSelection = () => {
125
+ if (!labelIsValue) {
126
+ if (optionValue) return renderPill(optionValue, fixed);
127
+ return _Pill || (_Pill = /*#__PURE__*/_jsx(Pill, {
128
+ label: "-"
129
+ }));
130
+ }
131
+ };
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',
142
+ multi: false,
143
+ items: options,
144
+ closeOnClick: true
145
+ })],
146
+ selection: {
147
+ 'multi-selection-views': optionValue ? [optionValue === null || optionValue === void 0 ? void 0 : optionValue.id] : ''
148
+ },
149
+ variant: "title"
150
+ })), renderSelection()]
151
+ });
152
+ }
153
+
154
+ export { LabeledDropdownSinglePill as default };
@@ -0,0 +1,16 @@
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
+
6
+ const hasOptionChanged = (prevOptions, options) => {
7
+ if (prevOptions && options) {
8
+ const prevOptionsOmited = prevOptions.map(option => omit(option, ['input', 'onChangeInput', 'mask']));
9
+ const optionsOmited = options.map(option => omit(option, ['input', 'onChangeInput', 'mask']));
10
+ return isEqual(prevOptionsOmited, optionsOmited);
11
+ }
12
+
13
+ return false;
14
+ };
15
+
16
+ export { hasOptionChanged };
@@ -0,0 +1,53 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'react';
3
+ import { PropTypes, describe } from 'react-desc';
4
+ import { PillGroup } from './PillGroup.js';
5
+ import { RemovablePill } from './RemovablePill.js';
6
+ import { Pill } from './Pill.js';
7
+
8
+ function LabeledPills(_ref) {
9
+ let {
10
+ children,
11
+ label = '',
12
+ leftAddon,
13
+ onFocusGroupSet,
14
+ onFocusNextGroup,
15
+ onFocusPreviousGroup
16
+ } = _ref;
17
+ return /*#__PURE__*/_jsx(PillGroup, {
18
+ onFocusGroupSet: onFocusGroupSet,
19
+ onFocusNextGroup: onFocusNextGroup,
20
+ onFocusPreviousGroup: onFocusPreviousGroup
21
+ }, void 0, /*#__PURE__*/_jsx(Pill, {
22
+ label: label,
23
+ leftAddon: leftAddon,
24
+ variant: "title",
25
+ "data-testid": "pill-title"
26
+ }), children);
27
+ }
28
+
29
+ const props = {
30
+ /** labeled pill text label */
31
+ label: PropTypes.string.isRequired.description('pill text label'),
32
+
33
+ /** pill to add the label to */
34
+ children: PropTypes.arrayOf(PropTypes.shape({
35
+ type: PropTypes.oneOf([PropTypes.instanceOf(Pill), PropTypes.instanceOf(RemovablePill)])
36
+ })).isRequired.description('pill to add the label to'),
37
+
38
+ /** addon component to left */
39
+ leftAddon: PropTypes.node.description('addon component to left'),
40
+
41
+ /** focus next group callback */
42
+ onFocusNextGroup: PropTypes.func.description('focus next group callback'),
43
+
44
+ /** focus prev group callback */
45
+ onFocusPreviousGroup: PropTypes.func.description('focus prev group callback'),
46
+
47
+ /** focus group set callback */
48
+ onFocusGroupSet: PropTypes.func.description('focus group set callback')
49
+ };
50
+ const DSLabeledPillsWithSchema = describe(LabeledPills);
51
+ DSLabeledPillsWithSchema.propTypes = props;
52
+
53
+ export { DSLabeledPillsWithSchema, LabeledPills };
@@ -0,0 +1,62 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'core-js/modules/web.dom-collections.iterator.js';
3
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
4
+ import 'core-js/modules/esnext.iterator.constructor.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import { useRef, useState, useEffect } from 'react';
7
+ import { PropTypes, describe } from 'react-desc';
8
+ import useFocusGroupItem from '@elliemae/ds-shared/FocusGroup/useFocusGroupItem';
9
+ import DSTooltip from '@elliemae/ds-tooltip';
10
+ import { Pill } from './Pill.js';
11
+
12
+ function OverflowPill(_ref) {
13
+ let {
14
+ containerProps = {},
15
+ label = '',
16
+ options = []
17
+ } = _ref;
18
+ const ref = useRef(null);
19
+ const [tooltipIsOpen, setTooltipIsOpen] = useState(false);
20
+ const [tooltipText, setTooltipText] = useState('');
21
+ useEffect(() => {
22
+ let text = '';
23
+ options.forEach(option => {
24
+ if (!tooltipText || option === options[0]) {
25
+ text = "".concat(option.label);
26
+ } else {
27
+ text = text.concat(", ".concat(option.label));
28
+ }
29
+ });
30
+ setTooltipText(text);
31
+ }, [options]);
32
+ useFocusGroupItem(ref);
33
+ return /*#__PURE__*/_jsx(DSTooltip, {
34
+ isOpen: tooltipIsOpen,
35
+ title: tooltipText,
36
+ zIndex: 11,
37
+ triggerComponent: /*#__PURE__*/_jsx(Pill, {
38
+ className: "overflow-pill",
39
+ containerProps: containerProps,
40
+ innerRef: ref,
41
+ label: label,
42
+ tabIndex: -1,
43
+ onMouseEnter: () => setTooltipIsOpen(true),
44
+ onMouseLeave: () => setTooltipIsOpen(false)
45
+ })
46
+ });
47
+ }
48
+
49
+ const props = {
50
+ /** props to inject to pill wrapper */
51
+ containerProps: PropTypes.object.description('props to inject to pill wrapper'),
52
+
53
+ /** pill text label */
54
+ label: PropTypes.string.isRequired.description('pill text label'),
55
+
56
+ /** overflow pills options */
57
+ options: PropTypes.array.description('overflow pills options')
58
+ };
59
+ const DSOverflowPillWithSchema = describe(OverflowPill);
60
+ DSOverflowPillWithSchema.propTypes = props;
61
+
62
+ export { DSOverflowPillWithSchema, OverflowPill };
@@ -0,0 +1,76 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
8
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
+ import 'react';
10
+ import { PropTypes, describe } from 'react-desc';
11
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
12
+ import { jsxs } from 'react/jsx-runtime';
13
+
14
+ const _excluded = ["containerProps", "label", "leftAddon", "rightAddon", "variant", "size"];
15
+
16
+ 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; }
17
+
18
+ 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; }
19
+ const pillBlockName = 'pill';
20
+ const PillWrapper = aggregatedClasses('div')(pillBlockName, null, _ref => {
21
+ let {
22
+ size,
23
+ variant
24
+ } = _ref;
25
+ return {
26
+ [variant]: !!variant,
27
+ [size]: !!size
28
+ };
29
+ });
30
+ const PillLabel = aggregatedClasses('span')(pillBlockName, 'label');
31
+ const PillAddon = aggregatedClasses('div')(pillBlockName, 'addon');
32
+
33
+ function Pill(_ref2) {
34
+ let {
35
+ containerProps = {},
36
+ label = '',
37
+ leftAddon,
38
+ rightAddon,
39
+ variant = 'value',
40
+ size = 'm'
41
+ } = _ref2,
42
+ otherProps = _objectWithoutProperties(_ref2, _excluded);
43
+
44
+ return /*#__PURE__*/jsxs(PillWrapper, _objectSpread(_objectSpread(_objectSpread({}, containerProps), {}, {
45
+ classProps: {
46
+ variant,
47
+ size
48
+ }
49
+ }, otherProps), {}, {
50
+ children: [leftAddon && /*#__PURE__*/_jsx(PillAddon, {}, void 0, leftAddon), /*#__PURE__*/_jsx(PillLabel, {}, void 0, label), rightAddon && /*#__PURE__*/_jsx(PillAddon, {}, void 0, rightAddon)]
51
+ }));
52
+ }
53
+
54
+ const props = {
55
+ /** props to inject to pill wrapper */
56
+ containerProps: PropTypes.object.description('props to inject to pill wrapper'),
57
+
58
+ /** pill text label */
59
+ label: PropTypes.string.isRequired.description('pill text label'),
60
+
61
+ /** pill size */
62
+ size: PropTypes.oneOf(['m', 'l']).description('pill size'),
63
+
64
+ /** pill variant */
65
+ variant: PropTypes.oneOf(['value', 'title']).description('pill variant'),
66
+
67
+ /** addon component to left */
68
+ leftAddon: PropTypes.node.description('addon component to left'),
69
+
70
+ /** addon component to right */
71
+ rightAddon: PropTypes.node.description('addon component to right')
72
+ };
73
+ const DSPillWithSchema = describe(Pill);
74
+ DSPillWithSchema.propTypes = props;
75
+
76
+ export { DSPillWithSchema, Pill, Pill as default };
@@ -0,0 +1,60 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
7
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
8
+ import 'react';
9
+ import { PropTypes, describe } from 'react-desc';
10
+ import { aggregatedClasses } from '@elliemae/ds-classnames';
11
+ import FocusGroupProvider from '@elliemae/ds-shared/FocusGroup/FocusGroupManager';
12
+ import { jsx } from 'react/jsx-runtime';
13
+
14
+ 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; }
15
+
16
+ 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; }
17
+ const pillGroupBlockName = 'pill-group';
18
+ const Container = aggregatedClasses('div')(pillGroupBlockName);
19
+
20
+ const PillGroup = _ref => {
21
+ let {
22
+ containerProps = {},
23
+ onFocusNextGroup,
24
+ onFocusPreviousGroup,
25
+ onFocusGroupSet,
26
+ children
27
+ } = _ref;
28
+ return /*#__PURE__*/_jsx(FocusGroupProvider, {
29
+ keyBindings: {
30
+ Tab: 'next'
31
+ },
32
+ onFocusGroupSet: onFocusGroupSet,
33
+ onFocusNextGroup: onFocusNextGroup,
34
+ onFocusPreviousGroup: onFocusPreviousGroup,
35
+ orientation: "horizontal"
36
+ }, void 0, /*#__PURE__*/jsx(Container, _objectSpread(_objectSpread({}, containerProps), {}, {
37
+ children: children
38
+ })));
39
+ };
40
+
41
+ const props = {
42
+ /** props injected to component wrapper */
43
+ containerProps: PropTypes.object.description('props injected to component wrapper'),
44
+
45
+ /** focus next group callback */
46
+ onFocusNextGroup: PropTypes.func.description('focus next group callback'),
47
+
48
+ /** focus prev group callback */
49
+ onFocusPreviousGroup: PropTypes.func.description('focus prev group callback'),
50
+
51
+ /** focus group set callback */
52
+ onFocusGroupSet: PropTypes.func.description('focus group set callback'),
53
+
54
+ /** pill components */
55
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired.description('pill components')
56
+ };
57
+ const DSPillGroupWithSchema = describe(PillGroup);
58
+ DSPillGroupWithSchema.propTypes = props;
59
+
60
+ export { Container, DSPillGroupWithSchema, PillGroup };
@@ -0,0 +1,90 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'core-js/modules/web.dom-collections.iterator.js';
3
+ import { useRef, useState } from 'react';
4
+ import { PropTypes, describe } from 'react-desc';
5
+ import { InfoCircleSmall } from '@elliemae/ds-icons';
6
+ import DSModal, { MODAL_TYPE_V2 } from '@elliemae/ds-modal';
7
+ import Popover from '@elliemae/ds-popover';
8
+ import { Pill } from './Pill.js';
9
+ import { jsxs, Fragment } from 'react/jsx-runtime';
10
+
11
+ const ReadOnlyPill = _ref => {
12
+ let {
13
+ containerProps = {},
14
+ modalContent = '',
15
+ label = '',
16
+ leftAddon,
17
+ modalTitle = '',
18
+ tooltipText = ''
19
+ } = _ref;
20
+ const ref = useRef(null);
21
+ const [isModalOpen, setIsModalOpen] = useState(false);
22
+ const [isTooltipOpen, setIsTooltipOpen] = useState(false);
23
+
24
+ const toggle = () => {
25
+ setIsModalOpen(!isModalOpen);
26
+ };
27
+
28
+ return /*#__PURE__*/jsxs(Fragment, {
29
+ children: [/*#__PURE__*/_jsx(Pill, {
30
+ "data-testid": "read-only-pill",
31
+ className: "removable-pill",
32
+ containerProps: containerProps,
33
+ innerRef: ref,
34
+ label: label,
35
+ leftAddon: leftAddon,
36
+ rightAddon: /*#__PURE__*/_jsx(Popover, {
37
+ isOpen: tooltipText && isTooltipOpen,
38
+ content: tooltipText,
39
+ placement: "top",
40
+ showArrow: true,
41
+ renderTrigger: _ref2 => {
42
+ let {
43
+ ref
44
+ } = _ref2;
45
+ return /*#__PURE__*/_jsx(InfoCircleSmall, {
46
+ role: "button",
47
+ "data-testid": "read-only-info-btn",
48
+ className: "remove-pill-button",
49
+ onClick: toggle,
50
+ onMouseEnter: () => setIsTooltipOpen(true),
51
+ onMouseLeave: () => setIsTooltipOpen(false),
52
+ color: ['brand-primary', '600'],
53
+ innerRef: ref
54
+ });
55
+ }
56
+ }),
57
+ tabIndex: -1
58
+ }), /*#__PURE__*/_jsx(DSModal, {
59
+ isOpen: isModalOpen,
60
+ showClose: true,
61
+ shouldCloseOnOverlayClick: true,
62
+ modalTitle: modalTitle,
63
+ modalType: MODAL_TYPE_V2.INFORMATION,
64
+ onClose: toggle,
65
+ version: 2
66
+ }, void 0, modalContent)]
67
+ });
68
+ };
69
+
70
+ const props = {
71
+ /** props injected to component wrapper */
72
+ containerProps: PropTypes.object.description('props injected to component wrapper'),
73
+
74
+ /** labeled pill text label */
75
+ label: PropTypes.string.isRequired.description('pill text label'),
76
+
77
+ /** addon component to left */
78
+ leftAddon: PropTypes.node.description('addon component to left'),
79
+
80
+ /** read only pill modal content */
81
+ modalContent: PropTypes.string.description('read only pill modal content'),
82
+
83
+ /** read only pill modal title */
84
+ modalTitle: PropTypes.string.description('read only pill modal title'),
85
+ tooltipText: PropTypes.string.description('text to display in tooltip')
86
+ };
87
+ const DSReadOnlyPillWithSchema = describe(ReadOnlyPill);
88
+ DSReadOnlyPillWithSchema.propTypes = props;
89
+
90
+ export { DSReadOnlyPillWithSchema, ReadOnlyPill };
@@ -0,0 +1,64 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useRef } from 'react';
3
+ import { PropTypes, describe } from 'react-desc';
4
+ import { isFunction } from '@elliemae/ds-utilities';
5
+ import { CloseXsmall } from '@elliemae/ds-icons';
6
+ import useFocusGroupItem from '@elliemae/ds-shared/FocusGroup/useFocusGroupItem';
7
+ import { Pill } from './Pill.js';
8
+
9
+ function RemovablePill(_ref) {
10
+ let {
11
+ containerProps = {},
12
+ label = '',
13
+ onRemove,
14
+ size = 'm',
15
+ leftAddon
16
+ } = _ref;
17
+ const ref = useRef(null);
18
+ const {
19
+ focusPrevious
20
+ } = useFocusGroupItem(ref);
21
+ return /*#__PURE__*/_jsx(Pill, {
22
+ className: "removable-pill",
23
+ "data-testid": "removable-pill",
24
+ containerProps: containerProps,
25
+ innerRef: ref,
26
+ size: size,
27
+ label: label,
28
+ leftAddon: leftAddon,
29
+ onKeyDown: e => {
30
+ if (e.key === 'Backspace' && isFunction(onRemove)) {
31
+ onRemove();
32
+ if (isFunction(focusPrevious)) focusPrevious();
33
+ }
34
+ },
35
+ rightAddon: /*#__PURE__*/_jsx(CloseXsmall, {
36
+ role: "button",
37
+ "data-testid": "remove-pill-button",
38
+ className: "remove-pill-button",
39
+ onClick: onRemove
40
+ }),
41
+ tabIndex: -1
42
+ });
43
+ }
44
+
45
+ const props = {
46
+ /** props injected to component wrapper */
47
+ containerProps: PropTypes.object.description('props injected to component wrapper'),
48
+
49
+ /** labeled pill text label */
50
+ label: PropTypes.string.isRequired.description('pill text label'),
51
+
52
+ /** remove click callback */
53
+ onRemove: PropTypes.func.description('remove click callback'),
54
+
55
+ /** pill size */
56
+ size: PropTypes.oneOf(['m', 'l']).description('pill size'),
57
+
58
+ /** addon component to left */
59
+ leftAddon: PropTypes.node.description('addon component to left')
60
+ };
61
+ const DSRemovablePillWithSchema = describe(RemovablePill);
62
+ DSRemovablePillWithSchema.propTypes = props;
63
+
64
+ export { DSRemovablePillWithSchema, RemovablePill };
@@ -0,0 +1,8 @@
1
+ export { DSPillWithSchema, Pill, Pill as default } from './Pill.js';
2
+ export { Container, DSPillGroupWithSchema, PillGroup } from './PillGroup.js';
3
+ export { DSLabeledDropdownPillsWithSchema, LabeledDropdownPills } from './LabeledDropdownPills.js';
4
+ export { DSLabeledPillsWithSchema, LabeledPills } from './LabeledPills.js';
5
+ export { DSDropdownPillWithSchema, DropdownPill } from './DropdownPill.js';
6
+ export { DSRemovablePillWithSchema, RemovablePill } from './RemovablePill.js';
7
+ export { DSReadOnlyPillWithSchema, ReadOnlyPill } from './ReadOnlyPill.js';
8
+ export { DSOverflowPillWithSchema, OverflowPill } from './OverflowPill.js';
package/esm/index.d.js ADDED
@@ -0,0 +1 @@
1
+
package/esm/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export { DSPillWithSchema, Pill, Pill as default } from './deprecated/Pill.js';
2
+ export { Container, DSPillGroupWithSchema, PillGroup } from './deprecated/PillGroup.js';
3
+ export { DSLabeledDropdownPillsWithSchema, LabeledDropdownPills } from './deprecated/LabeledDropdownPills.js';
4
+ export { DSLabeledPillsWithSchema, LabeledPills } from './deprecated/LabeledPills.js';
5
+ export { DSDropdownPillWithSchema, DropdownPill } from './deprecated/DropdownPill.js';
6
+ export { DSRemovablePillWithSchema, RemovablePill } from './deprecated/RemovablePill.js';
7
+ export { DSReadOnlyPillWithSchema, ReadOnlyPill } from './deprecated/ReadOnlyPill.js';
8
+ export { DSOverflowPillWithSchema, OverflowPill } from './deprecated/OverflowPill.js';
9
+ export { DSPillV2, DSPillV2WithSchema } from './components/Pill.js';
10
+ export { DSPillGroupV2, DSPillGroupV2Context, DSPillGroupV2WithSchema } from './components/PillGroup.js';
11
+ export { DSPillButton, DSPillButtonWithSchema } from './components/PillButton.js';
package/esm/props.js ADDED
@@ -0,0 +1,60 @@
1
+ import { PropTypes } from 'react-desc';
2
+ import { DSInput } from '@elliemae/ds-form';
3
+
4
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
5
+ const pillTypes = PropTypes.oneOf(['label', 'value', 'input', 'dropdown', 'removable', 'readonly']);
6
+ const DSPillV2PropTypes = {
7
+ label: PropTypes.string.description('Label to show in the pill').isRequired,
8
+ type: pillTypes.description('The type of pill that you want to render').isRequired,
9
+ innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).description('Reference to the focuseable internal element of each pill (remove icons, inputs, dropdown, etc.)').defaultValue(() => null),
10
+ size: PropTypes.oneOf(['s', 'm']).description('Vertical pill size').defaultValue('m'),
11
+ ariaLabel: PropTypes.string.description('Aria label for the pill. If not provided we will use the label').defaultValue(''),
12
+ labelTruncated: PropTypes.bool.description('Whether to truncate the pills label').defaultValue(true),
13
+ tooltipValue: PropTypes.string.description('String to show as a tooltip in the value pill').defaultValue(''),
14
+ iconLeft: PropTypes.node.description('A component to show int the left of a readonly pill').defaultValue(null),
15
+ iconRight: PropTypes.node.description('A component to show in the right of a readonly pill').defaultValue(null),
16
+ onRemove: PropTypes.func.description('Callback triggered when removing a pill with the close icon').defaultValue(() => null),
17
+ inputPlaceholder: PropTypes.string.description('Placeholder for the input pill').defaultValue(''),
18
+ onInputChange: PropTypes.func.description('Callback triggered when user provides input to the input pill').defaultValue(() => null),
19
+ onInputClear: PropTypes.func.description('Callback triggered when the user clears an input pill').defaultValue(() => null),
20
+ inputWidth: PropTypes.number.description('Width in pixels for the input tag in the input pill').defaultValue(150),
21
+ dropdownProps: PropTypes.object.description('Properties that will be used for the dropdown-menu').defaultValue({}),
22
+ onDropdownClick: PropTypes.func.description('Callback when dropdown button is clicked or pressed').defaultValue(() => null)
23
+ };
24
+ const DSPillButtonPropTypes = {
25
+ type: PropTypes.oneOf(['only', 'left', 'right']).description('The position in which this button will be placed. Only used for css styling internally').defaultValue('right'),
26
+ width: PropTypes.string.description('Width of the button').defaultValue('100%'),
27
+ height: PropTypes.string.description('Height of the button').defaultValue('100%')
28
+ };
29
+ const DSPillGroupPropTypes = {
30
+ width: PropTypes.string.description('Width of the group').defaultValue('fit-content'),
31
+ innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).description('Reference to the pill group wrapper').defaultValue(() => null)
32
+ };
33
+ const DSPillV2DefaultProps = {
34
+ innerRef: () => null,
35
+ ariaLabel: '',
36
+ size: 'm',
37
+ labelTruncated: true,
38
+ tooltipValue: '',
39
+ iconLeft: null,
40
+ iconRight: null,
41
+ onRemove: () => null,
42
+ inputPlaceholder: '',
43
+ onInputChange: () => null,
44
+ onInputClear: () => null,
45
+ inputWidth: 72,
46
+ inputRender: DSInput,
47
+ dropdownProps: {},
48
+ onDropdownClick: () => null
49
+ };
50
+ const DSPillButtonDefaultProps = {
51
+ type: 'right',
52
+ width: '100%',
53
+ height: '100%'
54
+ };
55
+ const DSPillGroupDefaultProps = {
56
+ width: 'fit-content',
57
+ innerRef: () => null
58
+ };
59
+
60
+ export { DSPillButtonDefaultProps, DSPillButtonPropTypes, DSPillGroupDefaultProps, DSPillGroupPropTypes, DSPillV2DefaultProps, DSPillV2PropTypes };