@elliemae/ds-pills 2.0.0-alpha.5 → 2.0.0-alpha.9

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 (44) hide show
  1. package/cjs/components/Pill.js +4 -4
  2. package/cjs/components/PillButton.js +51 -0
  3. package/cjs/components/PillGroup.js +3 -3
  4. package/cjs/components/index.js +3 -0
  5. package/cjs/components/styled.js +33 -52
  6. package/cjs/components/types/DropdownPill.js +34 -32
  7. package/cjs/components/types/InputPill.js +32 -25
  8. package/cjs/components/types/LabelPill.js +14 -6
  9. package/cjs/components/types/ReadOnlyPill.js +20 -10
  10. package/cjs/components/types/RemovablePill.js +30 -19
  11. package/cjs/components/types/ValuePill.js +20 -9
  12. package/cjs/deprecated/DropdownPill.js +6 -6
  13. package/cjs/deprecated/InputPill.js +9 -9
  14. package/cjs/deprecated/LabeledDropdownPills.js +3 -3
  15. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +4 -4
  16. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +4 -4
  17. package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +6 -6
  18. package/cjs/deprecated/LabeledPills.js +2 -2
  19. package/cjs/deprecated/OverflowPill.js +3 -3
  20. package/cjs/deprecated/Pill.js +4 -4
  21. package/cjs/deprecated/PillGroup.js +2 -2
  22. package/cjs/deprecated/ReadOnlyPill.js +4 -4
  23. package/cjs/deprecated/RemovablePill.js +5 -5
  24. package/cjs/index.js +4 -1
  25. package/cjs/props.js +18 -3
  26. package/esm/components/Pill.js +3 -3
  27. package/esm/components/PillButton.js +41 -0
  28. package/esm/components/index.js +1 -0
  29. package/esm/components/styled.js +28 -44
  30. package/esm/components/types/DropdownPill.js +34 -33
  31. package/esm/components/types/InputPill.js +30 -24
  32. package/esm/components/types/LabelPill.js +12 -4
  33. package/esm/components/types/ReadOnlyPill.js +20 -10
  34. package/esm/components/types/RemovablePill.js +29 -19
  35. package/esm/components/types/ValuePill.js +20 -9
  36. package/esm/deprecated/InputPill.js +2 -2
  37. package/esm/deprecated/RemovablePill.js +2 -2
  38. package/esm/index.js +1 -0
  39. package/esm/props.js +16 -3
  40. package/package.json +13 -9
  41. package/types/components/PillButton.d.ts +5 -0
  42. package/types/components/index.d.ts +1 -0
  43. package/types/components/styled.d.ts +30 -7
  44. package/types/props.d.ts +13 -0
@@ -1,68 +1,52 @@
1
1
  import styled, { css } from 'styled-components';
2
2
  import Grid from '@elliemae/ds-grid';
3
- import CloseXsmall from '@elliemae/ds-icons/CloseXsmall';
4
- import ChevronDown from '@elliemae/ds-icons/ChevronSmallDown';
3
+ import { DSButtonV2 } from '@elliemae/ds-button';
5
4
 
6
5
  /* eslint-disable max-lines */
7
6
  // Common CSS
8
7
  // =============================================================================
9
8
 
10
- const borderOutside = color => css([":after{content:' ';position:absolute;top:0px;left:0px;right:0px;bottom:0px;border:1px solid ", ";border-radius:12px;pointer-events:none;}"], color);
9
+ const borderOutside = (color, size = 1, zIndex = 2, borderRadius = '12px') => css([":after{content:' ';position:absolute;top:0px;left:0px;right:0px;bottom:0px;border:", "px solid ", ";border-top-left-radius:", ";border-top-right-radius:", ";border-bottom-left-radius:", ";border-bottom-right-radius:", ";pointer-events:none;z-index:", ";}"], size, color, borderRadius, borderRadius, borderRadius, borderRadius, zIndex);
11
10
 
12
- const borderInside = color => css([":before{content:' ';position:absolute;top:1px;left:1px;right:1px;bottom:1px;border:1px solid ", ";border-radius:12px;pointer-events:none;}"], color);
13
-
14
- const commonPillWrapperCss = /*#__PURE__*/css(["height:24px;position:relative;width:fit-content;background-color:", ";outline:none;padding:0px 12px 0 12px;border-radius:12px;font-size:", ";color:", ";"], props => props.theme.colors.brand[200], props => props.theme.fontSizes.value[400], props => props.theme.colors.neutral[800]);
15
- const commonFocuseablePillWrapperCss = /*#__PURE__*/css([":focus,:hover,:active{color:", ";", " ", "}"], props => props.theme.colors.brand[800], props => borderOutside(props.theme.colors.brand[600]), props => borderInside(props.theme.colors.brand[300])); // =============================================================================
16
- // Pill content
17
- // =============================================================================
18
-
19
- const StyledInput = /*#__PURE__*/styled.input.withConfig({
20
- componentId: "sc-j0tlch-0"
21
- })(["font-style:", ";color:", ";background:inherit;border:none;font-size:13px;margin:1px 0 1px 12px;padding:0;width:", ";outline:none;:focus{font-style:normal;color:", ";}"], props => props.value === '' ? 'italic' : 'normal', ({
22
- value,
23
- theme
24
- }) => value === '' ? theme.colors.neutral[500] : theme.colors.brand[800], props => props.inputWidth, props => props.theme.colors.brand[800]); // =============================================================================
25
- // Icons
26
- // =============================================================================
27
-
28
- const StyledCloseIcon = /*#__PURE__*/styled(CloseXsmall).withConfig({
29
- componentId: "sc-j0tlch-1"
30
- })(["cursor:pointer;z-index:2;margin-top:-1px;:focus{outline:1px solid ", ";}"], props => props.theme.colors.brand[800]);
31
- const StyledChevronDown = /*#__PURE__*/styled(ChevronDown).withConfig({
32
- componentId: "sc-j0tlch-2"
33
- })(["fill:", ";svg{fill:inherit !important;}"], props => props.theme.colors.neutral[600]); // =============================================================================
11
+ const commonPillWrapperCss = /*#__PURE__*/css(["height:24px;position:relative;width:fit-content;background-color:", ";outline:none;padding:0px 12px 0 12px;border-radius:12px;font-size:13px;line-height:1;color:", ";", ";"], props => props.theme.colors.brand[200], props => props.theme.colors.brand[800], props => borderOutside(props.theme.colors.brand[300])); // =============================================================================
34
12
  // Pills wrappers
35
13
  // =============================================================================
36
14
 
37
15
  const StyledLabelPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
38
- componentId: "sc-j0tlch-3"
39
- })(["", " ", " font-weight:", ";"], commonPillWrapperCss, commonFocuseablePillWrapperCss, props => props.theme.fontWeights.semibold);
16
+ componentId: "sc-j0tlch-0"
17
+ })(["", " font-weight:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.semibold, props => props.hasIcon ? '0px !important' : '12px');
40
18
  const StyledValuePillWrapper = /*#__PURE__*/styled(Grid).withConfig({
41
- componentId: "sc-j0tlch-4"
42
- })(["", " ", " font-weight:", ";"], commonPillWrapperCss, commonFocuseablePillWrapperCss, props => props.theme.fontWeights.regular);
19
+ componentId: "sc-j0tlch-1"
20
+ })(["", " font-weight:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.regular, props => props.hasIcon ? '0px !important' : '12px');
43
21
  const StyledInputPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
44
- componentId: "sc-j0tlch-5"
45
- })(["", " background:", ";border:", ";padding:0;:focus-within{border:1px solid ", ";box-shadow:inset 0 0 0 1px ", ";background:", ";}:active,:hover{border:1px solid ", ";}& .em-ds-input{outline:none !important;border:none !important;box-shadow:none !important;border-radius:none !important;height:100%;background:transparent;width:", ";padding:0;margin:1px 0 1px 12px;}& .em-ds-input__tooltip-ref{height:100%;}"], commonPillWrapperCss, ({
46
- value,
47
- theme
48
- }) => value === '' ? theme.colors.neutral['000'] : theme.colors.brand[200], ({
22
+ componentId: "sc-j0tlch-2"
23
+ })(["", " background:", ";padding:0;", ":focus-within{", "}:active{", "}& .em-ds-input{outline:none !important;border:none !important;box-shadow:none !important;border-radius:0 !important;height:100%;background:transparent;width:", ";padding:0;margin:0 0 0 8px;}& .em-ds-input__tooltip-ref{height:100%;}"], commonPillWrapperCss, props => props.theme.colors.neutral['000'], ({
49
24
  value,
50
25
  theme
51
- }) => value === '' ? `1px solid ${theme.colors.neutral[300]}` : '1px solid transparent', props => props.theme.colors.brand[600], props => props.theme.colors.brand[300], props => props.theme.colors.brand[200], props => props.theme.colors.brand[700], props => `${props.inputWidth}px`);
26
+ }) => borderOutside(value === '' ? theme.colors.neutral[400] : theme.colors.brand[500]), props => props.inputHasFocus ? borderOutside(props.theme.colors.brand[700], 2) : '', props => props.inputHasFocus ? borderOutside(props.theme.colors.brand[500]) : '', props => `${props.inputWidth + (props.value === '' ? 24 : 0)}px`);
52
27
  const StyledDropdownPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
53
- componentId: "sc-j0tlch-6"
54
- })(["", " ", " font-weight:", ";cursor:pointer;padding:1px 3px 0 12px;:focus,:hover,:active{& ", "{fill:", ";}}"], commonPillWrapperCss, commonFocuseablePillWrapperCss, props => props.theme.fontWeights.semibold, StyledChevronDown, props => props.theme.colors.brand[800]);
28
+ componentId: "sc-j0tlch-3"
29
+ })(["", " font-weight:", ";padding:0 0 0 12px;"], commonPillWrapperCss, props => props.theme.fontWeights.semibold);
55
30
  const StyledReadonlyPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
56
- componentId: "sc-j0tlch-7"
57
- })(["", " font-weight:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.semibold);
31
+ componentId: "sc-j0tlch-4"
32
+ })(["", " font-weight:", ";padding-right:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.semibold, props => props.hasIconRight ? '0 !important' : '12px', props => props.hasIconLeft ? '0 !important' : '12px');
58
33
  const StyledRemovablePillWrapper = /*#__PURE__*/styled(Grid).withConfig({
59
- componentId: "sc-j0tlch-8"
60
- })(["", " ", " font-weight:", ";padding:1px 3px 0 12px;"], commonPillWrapperCss, commonFocuseablePillWrapperCss, props => props.theme.fontWeights.regular); // =============================================================================
34
+ componentId: "sc-j0tlch-5"
35
+ })(["", " font-weight:", ";padding:0 0 0 12px;"], commonPillWrapperCss, props => props.theme.fontWeights.regular); // =============================================================================
61
36
  // Pill group
62
37
  // =============================================================================
63
38
 
64
39
  const StyledPillGroup = /*#__PURE__*/styled(Grid).withConfig({
65
- componentId: "sc-j0tlch-9"
66
- })(["width:fit-content;& .ds-pill-wrapper{&:not(:first-of-type){&,:after,:before,> input{border-top-left-radius:0px;border-bottom-left-radius:0px;}}}& .ds-pill-wrapper{&:not(:last-of-type){&,:after,:before,> input{border-top-right-radius:0px;border-bottom-right-radius:0px;}}}"]);
40
+ componentId: "sc-j0tlch-6"
41
+ })(["width:fit-content;& .ds-pill-wrapper{&:not(:first-of-type){&,:after,:before,.ds-pill-tooltip-value:after{border-top-left-radius:0px;border-bottom-left-radius:0px;}}&:not(:last-of-type){&,:after,:before,.ds-pill-tooltip-value:after{border-top-right-radius:0px;border-bottom-right-radius:0px;}}}& .ds-pill-wrapper-label,& .ds-pill-wrapper-value,& .ds-pill-wrapper-readonly{&:not(:first-of-type){padding-left:8px;}&:not(:last-of-type){padding-right:8px;}}& .ds-pill-wrapper-removable:not(:first-of-type){padding-left:8px;}& .ds-pill-wrapper-dropdown:not(:first-of-type){padding-left:8px;}& .ds-pill-wrapper{:not(:first-of-type){.ds-pill-button-left{border-radius:0px;}.ds-pill-button-only{border-top-left-radius:0px;border-bottom-left-radius:0px;}}:not(:last-of-type){.ds-pill-button-right{border-radius:0px;}.ds-pill-button-only{border-top-right-radius:0px;border-bottom-right-radius:0px;}}}"]); // =============================================================================
42
+ // Extra stuff
43
+ // =============================================================================
44
+
45
+ const StyledSpanWithTooltip = /*#__PURE__*/styled.span.withConfig({
46
+ componentId: "sc-j0tlch-7"
47
+ })(["outline:none;:focus{", "}"], props => borderOutside(props.theme.colors.brand[700], 2, 3));
48
+ const StyledPillButton = /*#__PURE__*/styled(DSButtonV2).withConfig({
49
+ componentId: "sc-j0tlch-8"
50
+ })(["display:grid;place-items:center;position:relative;padding:0;width:", ";height:", ";border-radius:12px;:focus{", "}cursor:pointer;"], props => props.width, props => props.height, props => borderOutside(props.theme.colors.brand[700], 2, 3, 'inherit'));
67
51
 
68
- export { StyledChevronDown, StyledCloseIcon, StyledDropdownPillWrapper, StyledInput, StyledInputPillWrapper, StyledLabelPillWrapper, StyledPillGroup, StyledReadonlyPillWrapper, StyledRemovablePillWrapper, StyledValuePillWrapper };
52
+ export { StyledDropdownPillWrapper, StyledInputPillWrapper, StyledLabelPillWrapper, StyledPillButton, StyledPillGroup, StyledReadonlyPillWrapper, StyledRemovablePillWrapper, StyledSpanWithTooltip, StyledValuePillWrapper };
@@ -1,13 +1,14 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
2
  import _jsx from '@babel/runtime/helpers/esm/jsx';
3
- import React, { useState, useRef, useMemo } from 'react';
3
+ import React, { useRef, useMemo } from 'react';
4
4
  import DSDropdownMenu from '@elliemae/ds-dropdownmenu';
5
5
  import { uid } from 'uid';
6
- import { StyledDropdownPillWrapper, StyledChevronDown } from '../styled.js';
6
+ import ChevronDown from '@elliemae/ds-icons/ChevronSmallDown';
7
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
8
+ import { StyledDropdownPillWrapper } from '../styled.js';
7
9
  import { setMultipleRefs } from '../../utils.js';
8
- import { jsx, jsxs } from 'react/jsx-runtime';
9
-
10
- var _StyledChevronDown;
10
+ import { DSPillButton } from '../PillButton.js';
11
+ import { jsx } from 'react/jsx-runtime';
11
12
 
12
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13
14
 
@@ -15,39 +16,39 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
16
  const DropdownPill = /*#__PURE__*/React.memo(({
16
17
  label,
17
18
  dropdownProps,
18
- innerRef
19
+ innerRef,
20
+ ariaLabel
19
21
  }) => {
20
- const [chevronEl, chevronRef] = useState();
21
- const pillRef = useRef(null);
22
+ const chevronRef = useRef(null);
22
23
  const pillUid = useMemo(() => `ds-pill-${uid()}`, []);
23
- return /*#__PURE__*/jsx(DSDropdownMenu, _objectSpread(_objectSpread({}, dropdownProps), {}, {
24
+ return /*#__PURE__*/_jsx(StyledDropdownPillWrapper, {
25
+ id: pillUid,
26
+ className: "ds-pill-wrapper ds-pill-wrapper-dropdown",
27
+ "data-testid": "ds-pill-wrapper",
28
+ cols: ['auto', '24px'],
29
+ gutter: "2px",
30
+ alignItems: "center",
31
+ justifyItems: "center"
32
+ }, void 0, /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
33
+ value: label
34
+ }), /*#__PURE__*/jsx(DSDropdownMenu, _objectSpread(_objectSpread({
24
35
  hideIfNotVisible: true,
25
- referenceNode: chevronEl,
26
- onClose: () => pillRef.current.focus(),
36
+ onClose: () => chevronRef.current.focus(),
27
37
  menuProps: {
28
38
  zIndex: 100
29
- },
30
- triggerComponent: /*#__PURE__*/jsxs(StyledDropdownPillWrapper, {
31
- id: pillUid,
32
- className: "ds-pill-wrapper ds-pill-focus-point",
33
- "data-testid": "ds-pill-wrapper",
34
- ref: setMultipleRefs(pillRef, innerRef),
35
- cols: ['auto', '24px'],
36
- alignItems: "center",
37
- tabIndex: 0,
38
- justifyItems: "center",
39
- role: "button",
40
- onKeyDown: e => ['Enter', 'Space'].includes(e.code),
41
- "aria-label": label,
42
- children: [label, /*#__PURE__*/jsx("div", {
43
- ref: chevronRef,
44
- children: _StyledChevronDown || (_StyledChevronDown = /*#__PURE__*/_jsx(StyledChevronDown, {
45
- size: "s",
46
- "data-testid": "ds-pill-dropdown-chevron"
47
- }))
48
- })]
49
- })
50
- }));
39
+ }
40
+ }, dropdownProps), {}, {
41
+ triggerComponent: /*#__PURE__*/_jsx(DSPillButton, {
42
+ className: "ds-pill-focus-point",
43
+ "data-testid": "ds-pill-dropdown-chevron",
44
+ innerRef: setMultipleRefs(chevronRef, innerRef),
45
+ "aria-label": ariaLabel || label,
46
+ type: "right"
47
+ }, void 0, /*#__PURE__*/_jsx(ChevronDown, {
48
+ color: ['brand-primary', '700'],
49
+ size: "s"
50
+ }))
51
+ })));
51
52
  });
52
53
 
53
54
  export { DropdownPill };
@@ -1,8 +1,10 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import React, { useRef, useMemo } from 'react';
2
+ import React, { useRef, useMemo, useCallback, useState } from 'react';
3
3
  import { uid } from 'uid';
4
- import { StyledInputPillWrapper, StyledCloseIcon } from '../styled.js';
4
+ import CloseIcon from '@elliemae/ds-icons/CloseXsmall';
5
+ import { StyledInputPillWrapper } from '../styled.js';
5
6
  import { setMultipleRefs } from '../../utils.js';
7
+ import { DSPillButton } from '../PillButton.js';
6
8
 
7
9
  const InputPill = /*#__PURE__*/React.memo(({
8
10
  label,
@@ -16,11 +18,21 @@ const InputPill = /*#__PURE__*/React.memo(({
16
18
  const ref = useRef(null);
17
19
  const InputComponent = useMemo(() => inputRender, [inputRender]);
18
20
  const pillUid = useMemo(() => `ds-pill-${uid()}`, []);
21
+ const onCloseIconClick = useCallback(e => {
22
+ if ([undefined, 'Enter', 'Space'].includes(e.code)) {
23
+ e.preventDefault();
24
+ onInputClear(e);
25
+ ref.current.focus();
26
+ }
27
+ }, [onInputClear]);
28
+ const [inputHasFocus, setInputHasFocus] = useState(false);
19
29
  return /*#__PURE__*/_jsx(StyledInputPillWrapper, {
20
30
  className: "ds-pill-wrapper",
21
31
  "data-testid": "ds-pill-wrapper",
22
- cols: ['auto', '24px'],
23
- inputWidth: inputWidth
32
+ cols: label === '' ? ['auto'] : ['auto', '24px'],
33
+ inputWidth: inputWidth,
34
+ value: label,
35
+ inputHasFocus: inputHasFocus
24
36
  }, void 0, /*#__PURE__*/_jsx(InputComponent, {
25
37
  id: pillUid,
26
38
  className: "ds-pill-focus-point",
@@ -28,28 +40,22 @@ const InputPill = /*#__PURE__*/React.memo(({
28
40
  innerRef: setMultipleRefs(ref, innerRef),
29
41
  value: label,
30
42
  onChange: onInputChange,
31
- placeholder: inputPlaceholder
32
- }), label !== '' && /*#__PURE__*/_jsx(StyledCloseIcon, {
43
+ placeholder: inputPlaceholder,
44
+ onFocus: () => setInputHasFocus(true),
45
+ onBlur: () => setInputHasFocus(false),
46
+ disableTooltip: false
47
+ }), label !== '' && /*#__PURE__*/_jsx(DSPillButton, {
48
+ id: pillUid,
33
49
  "data-testid": "ds-pill-clear-icon",
34
- tabIndex: 0,
50
+ innerRef: innerRef,
51
+ onClick: onCloseIconClick,
52
+ onKeyDown: onCloseIconClick,
53
+ "aria-label": "Clear input",
54
+ type: "right"
55
+ }, void 0, /*#__PURE__*/_jsx(CloseIcon, {
35
56
  size: "s",
36
- onClick: e => {
37
- onInputClear(e);
38
- ref.current.focus();
39
- },
40
- onKeyDown: e => {
41
- if (['Enter', 'Space'].includes(e.code)) {
42
- e.preventDefault();
43
- onInputClear(e);
44
- ref.current.focus();
45
- }
46
- },
47
- style: {
48
- position: 'absolute',
49
- right: 6,
50
- top: 4
51
- }
52
- }));
57
+ color: ['brand-primary', '700']
58
+ })));
53
59
  });
54
60
 
55
61
  export { InputPill };
@@ -1,14 +1,22 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import React from 'react';
3
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
3
4
  import { StyledLabelPillWrapper } from '../styled.js';
4
5
 
5
6
  const LabelPill = /*#__PURE__*/React.memo(({
6
- label
7
+ label,
8
+ iconLeft,
9
+ ariaLabel
7
10
  }) => /*#__PURE__*/_jsx(StyledLabelPillWrapper, {
8
11
  alignItems: "center",
9
- className: "ds-pill-wrapper",
12
+ className: "ds-pill-wrapper ds-pill-wrapper-label",
10
13
  "data-testid": "ds-pill-wrapper",
11
- "aria-label": label
12
- }, void 0, label));
14
+ "aria-label": ariaLabel || label,
15
+ cols: [iconLeft && 'min-content', 'auto'].filter(notFalse => notFalse),
16
+ gutter: "xxxs",
17
+ hasIcon: iconLeft !== null
18
+ }, void 0, iconLeft, /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
19
+ value: label
20
+ })));
13
21
 
14
22
  export { LabelPill };
@@ -1,18 +1,28 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import React from 'react';
3
- import { StyledLabelPillWrapper } from '../styled.js';
3
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
4
+ import { StyledReadonlyPillWrapper } from '../styled.js';
4
5
 
5
6
  const ReadOnlyPill = /*#__PURE__*/React.memo(({
6
7
  label,
7
8
  iconLeft,
8
- iconRight
9
- }) => /*#__PURE__*/_jsx(StyledLabelPillWrapper, {
10
- alignItems: "center",
11
- className: "ds-pill-wrapper",
12
- "data-testid": "ds-pill-wrapper",
13
- "aria-label": label,
14
- cols: [iconLeft && 'min-content', label && 'auto', iconRight && 'min-content'].filter(notFalse => notFalse),
15
- gutter: "xxs"
16
- }, void 0, iconLeft, label ? /*#__PURE__*/_jsx("span", {}, void 0, label) : null, iconRight));
9
+ iconRight,
10
+ ariaLabel
11
+ }) => {
12
+ const hasIconLeft = iconLeft !== null || iconRight !== null && label === '';
13
+ const hasIconRight = iconRight !== null || iconLeft !== null && label === '';
14
+ return /*#__PURE__*/_jsx(StyledReadonlyPillWrapper, {
15
+ alignItems: "center",
16
+ className: "ds-pill-wrapper ds-pill-wrapper-readonly",
17
+ "data-testid": "ds-pill-wrapper",
18
+ "aria-label": ariaLabel || label,
19
+ cols: [iconLeft && 'min-content', label && 'auto', iconRight && 'min-content'].filter(notFalse => notFalse),
20
+ gutter: "xxxs",
21
+ hasIconRight: hasIconRight,
22
+ hasIconLeft: hasIconLeft
23
+ }, void 0, iconLeft, label ? /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
24
+ value: label
25
+ }) : null, iconRight);
26
+ });
17
27
 
18
28
  export { ReadOnlyPill };
@@ -1,42 +1,52 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import React, { useContext, useMemo } from 'react';
2
+ import React, { useContext, useMemo, useCallback } from 'react';
3
3
  import { uid } from 'uid';
4
- import { StyledRemovablePillWrapper, StyledCloseIcon } from '../styled.js';
5
- import { setMultipleRefs } from '../../utils.js';
4
+ import CloseIcon from '@elliemae/ds-icons/CloseXsmall';
5
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
6
+ import { StyledRemovablePillWrapper } from '../styled.js';
6
7
  import { DSPillGroupV2Context } from '../PillGroup.js';
8
+ import { DSPillButton } from '../PillButton.js';
7
9
 
8
10
  const RemovablePill = /*#__PURE__*/React.memo(({
9
11
  label,
10
12
  onRemove,
11
- innerRef
13
+ innerRef,
14
+ ariaLabel
12
15
  }) => {
13
16
  const {
14
17
  onKeyboardRemove
15
18
  } = useContext(DSPillGroupV2Context);
16
19
  const pillUid = useMemo(() => `ds-pill-${uid()}`, []);
20
+ const onKeyDown = useCallback(e => {
21
+ if (['Enter', 'Space'].includes(e.code)) {
22
+ e.preventDefault();
23
+ if (onKeyboardRemove) onKeyboardRemove(pillUid);
24
+ onRemove(e);
25
+ }
26
+ }, [onKeyboardRemove, onRemove, pillUid]);
17
27
  return /*#__PURE__*/_jsx(StyledRemovablePillWrapper, {
18
28
  cols: ['auto', '24px'],
29
+ gutter: "2px",
19
30
  alignItems: "center",
20
31
  justifyItems: "center",
21
- className: "ds-pill-wrapper",
32
+ className: "ds-pill-wrapper ds-pill-wrapper-removable",
22
33
  "data-testid": "ds-pill-wrapper",
23
- "aria-label": label
24
- }, void 0, label, /*#__PURE__*/_jsx(StyledCloseIcon, {
25
- id: pillUid,
34
+ "aria-label": ariaLabel || label
35
+ }, void 0, /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
36
+ value: label
37
+ }), /*#__PURE__*/_jsx(DSPillButton, {
26
38
  className: "ds-pill-focus-point",
39
+ id: pillUid,
27
40
  "data-testid": "ds-pill-close-icon",
28
- tabIndex: 0,
29
- size: "s",
30
- innerRef: setMultipleRefs(innerRef),
41
+ innerRef: innerRef,
31
42
  onClick: onRemove,
32
- onKeyDown: e => {
33
- if (['Enter', 'Space'].includes(e.code)) {
34
- e.preventDefault();
35
- if (onKeyboardRemove) onKeyboardRemove(pillUid);
36
- onRemove(e);
37
- }
38
- }
39
- }));
43
+ onKeyDown: onKeyDown,
44
+ "aria-label": `Remove ${label}`,
45
+ type: "right"
46
+ }, void 0, /*#__PURE__*/_jsx(CloseIcon, {
47
+ size: "s",
48
+ color: ['brand-primary', '700']
49
+ })));
40
50
  });
41
51
 
42
52
  export { RemovablePill };
@@ -1,19 +1,30 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import React from 'react';
3
- import { DSTooltipV2 } from '@elliemae/ds-tooltip';
4
- import { StyledValuePillWrapper } from '../styled.js';
3
+ import { DSTooltipV3 } from '@elliemae/ds-tooltip';
4
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
5
+ import { StyledValuePillWrapper, StyledSpanWithTooltip } from '../styled.js';
5
6
 
6
7
  const ValuePill = /*#__PURE__*/React.memo(({
7
8
  label,
8
- tooltipValue
9
+ tooltipValue,
10
+ iconLeft,
11
+ ariaLabel
9
12
  }) => /*#__PURE__*/_jsx(StyledValuePillWrapper, {
10
13
  alignItems: "center",
11
- className: "ds-pill-wrapper",
14
+ className: "ds-pill-wrapper ds-pill-wrapper-value",
12
15
  "data-testid": "ds-pill-wrapper",
13
- "aria-label": label
14
- }, void 0, tooltipValue !== '' ? /*#__PURE__*/_jsx(DSTooltipV2, {
15
- title: tooltipValue,
16
- triggerComponent: label
17
- }) : label));
16
+ "aria-label": ariaLabel || label,
17
+ cols: [iconLeft && 'min-content', 'auto'].filter(notFalse => notFalse),
18
+ gutter: "xxxs",
19
+ hasIcon: iconLeft !== null
20
+ }, void 0, iconLeft, tooltipValue !== '' ? /*#__PURE__*/_jsx(DSTooltipV3, {
21
+ text: tooltipValue,
22
+ startPlacementPreference: "bottom"
23
+ }, void 0, /*#__PURE__*/_jsx(StyledSpanWithTooltip, {
24
+ className: "ds-pill-tooltip-value",
25
+ tabIndex: 0
26
+ }, void 0, label)) : /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
27
+ value: label
28
+ })));
18
29
 
19
30
  export { ValuePill };
@@ -2,7 +2,7 @@ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
4
  import 'react';
5
- import CloseXsmall from '@elliemae/ds-icons/CloseXsmall';
5
+ import CloseIcon from '@elliemae/ds-icons/CloseXsmall';
6
6
  import { aggregatedClasses } from '@elliemae/ds-classnames';
7
7
  import DSInputMask from '@elliemae/ds-form/InputMask';
8
8
  import DSInput from '@elliemae/ds-form/Input';
@@ -55,7 +55,7 @@ function InputPill(_ref) {
55
55
  placeholder: placeholder,
56
56
  value: value
57
57
  }, otherProps)),
58
- rightAddon: value && /*#__PURE__*/_jsx(CloseXsmall, {
58
+ rightAddon: value && /*#__PURE__*/_jsx(CloseIcon, {
59
59
  className: "remove-pill-button",
60
60
  "data-testid": "remove-pill-button",
61
61
  onClick: onRemove
@@ -2,7 +2,7 @@ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import { useRef } from 'react';
3
3
  import { PropTypes, describe } from 'react-desc';
4
4
  import { isFunction } from '@elliemae/ds-utilities/utils';
5
- import CloseXsmall from '@elliemae/ds-icons/CloseXsmall';
5
+ import CloseIcon from '@elliemae/ds-icons/CloseXsmall';
6
6
  import useFocusGroupItem from '@elliemae/ds-shared/FocusGroup/useFocusGroupItem';
7
7
  import { Pill } from './Pill.js';
8
8
 
@@ -31,7 +31,7 @@ function RemovablePill({
31
31
  if (isFunction(focusPrevious)) focusPrevious();
32
32
  }
33
33
  },
34
- rightAddon: /*#__PURE__*/_jsx(CloseXsmall, {
34
+ rightAddon: /*#__PURE__*/_jsx(CloseIcon, {
35
35
  role: "button",
36
36
  "data-testid": "remove-pill-button",
37
37
  className: "remove-pill-button",
package/esm/index.js CHANGED
@@ -8,3 +8,4 @@ export { DSReadOnlyPillWithSchema, ReadOnlyPill } from './deprecated/ReadOnlyPil
8
8
  export { DSOverflowPillWithSchema, OverflowPill } from './deprecated/OverflowPill.js';
9
9
  export { DSPillV2, DSPillV2WithSchema } from './components/Pill.js';
10
10
  export { DSPillGroupV2, DSPillGroupV2Context, DSPillGroupV2WithSchema } from './components/PillGroup.js';
11
+ export { DSPillButton, DSPillButtonWithSchema } from './components/PillButton.js';
package/esm/props.js CHANGED
@@ -2,11 +2,13 @@ import { PropTypes } from 'react-desc';
2
2
  import DSInput from '@elliemae/ds-form/Input';
3
3
 
4
4
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
5
- const pillTypes = PropTypes.oneOf(['label', 'value', 'input', 'dropdown', 'removable']);
5
+ const pillTypes = PropTypes.oneOf(['label', 'value', 'input', 'dropdown', 'removable', 'readonly']);
6
6
  const DSPillV2PropTypes = {
7
7
  label: PropTypes.string.description('Label to show in the pill').isRequired,
8
8
  type: pillTypes.description('The type of pill that you want to render').isRequired,
9
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
+ ariaLabel: PropTypes.string.description('Aria label for the pill. If not provided we will use the label').defaultValue(''),
11
+ tooltipValue: PropTypes.string.description('String to show as a tooltip in the value pill').defaultValue(''),
10
12
  iconLeft: PropTypes.node.description('A component to show int the left of a readonly pill').defaultValue(null),
11
13
  iconRight: PropTypes.node.description('A component to show in the right of a readonly pill').defaultValue(null),
12
14
  onRemove: PropTypes.func.description('Callback triggered when removing a pill with the close icon').defaultValue(() => null),
@@ -16,8 +18,14 @@ const DSPillV2PropTypes = {
16
18
  inputWidth: PropTypes.number.description('Width in pixels for the input tag in the input pill').defaultValue(150),
17
19
  dropdownProps: PropTypes.object.description('Properties that will be used for the dropdown-menu').defaultValue({})
18
20
  };
21
+ const DSPillButtonPropTypes = {
22
+ type: PropTypes.oneOf(['only', 'left', 'right']).description('The position in which this button will be placed. Only used for css styling internally').defaultValue('right'),
23
+ width: PropTypes.string.description('Width of the button').defaultValue('100%'),
24
+ height: PropTypes.string.description('Height of the button').defaultValue('100%')
25
+ };
19
26
  const DSPillV2DefaultProps = {
20
27
  innerRef: () => null,
28
+ ariaLabel: '',
21
29
  tooltipValue: '',
22
30
  iconLeft: null,
23
31
  iconRight: null,
@@ -25,9 +33,14 @@ const DSPillV2DefaultProps = {
25
33
  inputPlaceholder: '',
26
34
  onInputChange: () => null,
27
35
  onInputClear: () => null,
28
- inputWidth: 150,
36
+ inputWidth: 72,
29
37
  inputRender: DSInput,
30
38
  dropdownProps: {}
31
39
  };
40
+ const DSPillButtonDefaultProps = {
41
+ type: 'right',
42
+ width: '100%',
43
+ height: '100%'
44
+ };
32
45
 
33
- export { DSPillV2DefaultProps, DSPillV2PropTypes };
46
+ export { DSPillButtonDefaultProps, DSPillButtonPropTypes, DSPillV2DefaultProps, DSPillV2PropTypes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-pills",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.9",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Pills",
6
6
  "module": "./esm/index.js",
@@ -111,6 +111,10 @@
111
111
  "import": "./esm/components/PillGroup.js",
112
112
  "require": "./cjs/components/PillGroup.js"
113
113
  },
114
+ "./components/PillButton": {
115
+ "import": "./esm/components/PillButton.js",
116
+ "require": "./cjs/components/PillButton.js"
117
+ },
114
118
  "./components/Pill": {
115
119
  "import": "./esm/components/Pill.js",
116
120
  "require": "./cjs/components/Pill.js"
@@ -140,14 +144,14 @@
140
144
  "build": "node ../../scripts/build/build.js"
141
145
  },
142
146
  "dependencies": {
143
- "@elliemae/ds-classnames": "2.0.0-alpha.5",
144
- "@elliemae/ds-dropdownmenu": "2.0.0-alpha.5",
145
- "@elliemae/ds-form": "2.0.0-alpha.5",
146
- "@elliemae/ds-icons": "2.0.0-alpha.5",
147
- "@elliemae/ds-modal": "2.0.0-alpha.5",
148
- "@elliemae/ds-shared": "2.0.0-alpha.5",
149
- "@elliemae/ds-tooltip": "2.0.0-alpha.5",
150
- "@elliemae/ds-utilities": "2.0.0-alpha.5",
147
+ "@elliemae/ds-classnames": "2.0.0-alpha.9",
148
+ "@elliemae/ds-dropdownmenu": "2.0.0-alpha.9",
149
+ "@elliemae/ds-form": "2.0.0-alpha.9",
150
+ "@elliemae/ds-icons": "2.0.0-alpha.9",
151
+ "@elliemae/ds-modal": "2.0.0-alpha.9",
152
+ "@elliemae/ds-shared": "2.0.0-alpha.9",
153
+ "@elliemae/ds-tooltip": "2.0.0-alpha.9",
154
+ "@elliemae/ds-utilities": "2.0.0-alpha.9",
151
155
  "prop-types": "~15.7.2",
152
156
  "react-desc": "~4.1.3"
153
157
  },
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { DSButtonPropsT } from '@elliemae/ds-button';
3
+ declare const DSPillButton: React.ComponentType<DSButtonPropsT>;
4
+ declare const DSPillButtonWithSchema: any;
5
+ export { DSPillButton, DSPillButtonWithSchema };
@@ -1,2 +1,3 @@
1
1
  export * from './Pill';
2
2
  export * from './PillGroup';
3
+ export * from './PillButton';