@elliemae/ds-pills 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (96) hide show
  1. package/cjs/components/Pill.js +48 -0
  2. package/cjs/components/PillButton.js +51 -0
  3. package/cjs/components/PillGroup.js +50 -0
  4. package/cjs/components/index.js +17 -0
  5. package/cjs/components/styled.js +69 -0
  6. package/cjs/components/types/DropdownPill.js +66 -0
  7. package/cjs/components/types/InputPill.js +71 -0
  8. package/cjs/components/types/LabelPill.js +31 -0
  9. package/cjs/components/types/ReadOnlyPill.js +37 -0
  10. package/cjs/components/types/RemovablePill.js +62 -0
  11. package/cjs/components/types/ValuePill.js +39 -0
  12. package/cjs/components/types/index.js +19 -0
  13. package/cjs/{DropdownPill.js → deprecated/DropdownPill.js} +9 -9
  14. package/cjs/{InputPill.js → deprecated/InputPill.js} +9 -9
  15. package/cjs/{LabeledDropdownPills.js → deprecated/LabeledDropdownPills.js} +3 -3
  16. package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownCascadeMenuPill.js +7 -7
  17. package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownMultiPill.js +15 -15
  18. package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownSinglePill.js +13 -13
  19. package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/utils.js +0 -0
  20. package/cjs/{LabeledPills.js → deprecated/LabeledPills.js} +2 -2
  21. package/cjs/{OverflowPill.js → deprecated/OverflowPill.js} +8 -8
  22. package/cjs/{Pill.js → deprecated/Pill.js} +4 -4
  23. package/cjs/{PillGroup.js → deprecated/PillGroup.js} +2 -2
  24. package/cjs/{ReadOnlyPill.js → deprecated/ReadOnlyPill.js} +8 -8
  25. package/cjs/{RemovablePill.js → deprecated/RemovablePill.js} +7 -7
  26. package/cjs/deprecated/index.js +32 -0
  27. package/cjs/index.d.js +2 -0
  28. package/cjs/index.js +19 -9
  29. package/cjs/props.js +57 -0
  30. package/cjs/utils.js +18 -0
  31. package/esm/components/Pill.js +39 -0
  32. package/esm/components/PillButton.js +41 -0
  33. package/esm/components/PillGroup.js +39 -0
  34. package/esm/components/index.js +3 -0
  35. package/esm/components/styled.js +52 -0
  36. package/esm/components/types/DropdownPill.js +54 -0
  37. package/esm/components/types/InputPill.js +61 -0
  38. package/esm/components/types/LabelPill.js +22 -0
  39. package/esm/components/types/ReadOnlyPill.js +28 -0
  40. package/esm/components/types/RemovablePill.js +52 -0
  41. package/esm/components/types/ValuePill.js +30 -0
  42. package/esm/components/types/index.js +6 -0
  43. package/esm/{DropdownPill.js → deprecated/DropdownPill.js} +0 -0
  44. package/esm/{InputPill.js → deprecated/InputPill.js} +2 -2
  45. package/esm/{LabeledDropdownPills.js → deprecated/LabeledDropdownPills.js} +0 -0
  46. package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownCascadeMenuPill.js +0 -0
  47. package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownMultiPill.js +0 -0
  48. package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownSinglePill.js +0 -0
  49. package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/utils.js +0 -0
  50. package/esm/{LabeledPills.js → deprecated/LabeledPills.js} +0 -0
  51. package/esm/{OverflowPill.js → deprecated/OverflowPill.js} +0 -0
  52. package/esm/{Pill.js → deprecated/Pill.js} +0 -0
  53. package/esm/{PillGroup.js → deprecated/PillGroup.js} +0 -0
  54. package/esm/{ReadOnlyPill.js → deprecated/ReadOnlyPill.js} +0 -0
  55. package/esm/{RemovablePill.js → deprecated/RemovablePill.js} +2 -2
  56. package/esm/deprecated/index.js +8 -0
  57. package/esm/index.d.js +1 -0
  58. package/esm/index.js +11 -8
  59. package/esm/props.js +46 -0
  60. package/esm/utils.js +14 -0
  61. package/package.json +108 -48
  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 +7 -0
  65. package/types/components/index.d.ts +3 -0
  66. package/types/components/styled.d.ts +40 -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/{DropdownPill.d.ts → deprecated/DropdownPill.d.ts} +0 -0
  75. package/types/{InputPill.d.ts → deprecated/InputPill.d.ts} +0 -0
  76. package/types/{LabeledDropdownPills.d.ts → deprecated/LabeledDropdownPills.d.ts} +0 -0
  77. package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownCascadeMenuPill.d.ts +0 -0
  78. package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownMultiPill.d.ts +0 -0
  79. package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownSinglePill.d.ts +0 -0
  80. package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/utils.d.ts +0 -0
  81. package/types/{LabeledPills.d.ts → deprecated/LabeledPills.d.ts} +0 -0
  82. package/types/{OverflowPill.d.ts → deprecated/OverflowPill.d.ts} +0 -0
  83. package/types/{Pill.d.ts → deprecated/Pill.d.ts} +0 -0
  84. package/types/{PillGroup.d.ts → deprecated/PillGroup.d.ts} +0 -0
  85. package/types/{ReadOnlyPill.d.ts → deprecated/ReadOnlyPill.d.ts} +0 -0
  86. package/types/{RemovablePill.d.ts → deprecated/RemovablePill.d.ts} +0 -0
  87. package/types/deprecated/index.d.ts +8 -0
  88. package/types/index.d.ts +3 -9
  89. package/types/props.d.ts +39 -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
package/cjs/props.js ADDED
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var reactDesc = require('react-desc');
6
+ var DSInput = require('@elliemae/ds-form/Input');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var DSInput__default = /*#__PURE__*/_interopDefaultLegacy(DSInput);
11
+
12
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
13
+ const pillTypes = reactDesc.PropTypes.oneOf(['label', 'value', 'input', 'dropdown', 'removable', 'readonly']);
14
+ const DSPillV2PropTypes = {
15
+ label: reactDesc.PropTypes.string.description('Label to show in the pill').isRequired,
16
+ type: pillTypes.description('The type of pill that you want to render').isRequired,
17
+ innerRef: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.object, reactDesc.PropTypes.func]).description('Reference to the focuseable internal element of each pill (remove icons, inputs, dropdown, etc.)').defaultValue(() => null),
18
+ ariaLabel: reactDesc.PropTypes.string.description('Aria label for the pill. If not provided we will use the label').defaultValue(''),
19
+ tooltipValue: reactDesc.PropTypes.string.description('String to show as a tooltip in the value pill').defaultValue(''),
20
+ iconLeft: reactDesc.PropTypes.node.description('A component to show int the left of a readonly pill').defaultValue(null),
21
+ iconRight: reactDesc.PropTypes.node.description('A component to show in the right of a readonly pill').defaultValue(null),
22
+ onRemove: reactDesc.PropTypes.func.description('Callback triggered when removing a pill with the close icon').defaultValue(() => null),
23
+ inputPlaceholder: reactDesc.PropTypes.string.description('Placeholder for the input pill').defaultValue(''),
24
+ onInputChange: reactDesc.PropTypes.func.description('Callback triggered when user provides input to the input pill').defaultValue(() => null),
25
+ onInputClear: reactDesc.PropTypes.func.description('Callback triggered when the user clears an input pill').defaultValue(() => null),
26
+ inputWidth: reactDesc.PropTypes.number.description('Width in pixels for the input tag in the input pill').defaultValue(150),
27
+ dropdownProps: reactDesc.PropTypes.object.description('Properties that will be used for the dropdown-menu').defaultValue({})
28
+ };
29
+ const DSPillButtonPropTypes = {
30
+ type: reactDesc.PropTypes.oneOf(['only', 'left', 'right']).description('The position in which this button will be placed. Only used for css styling internally').defaultValue('right'),
31
+ width: reactDesc.PropTypes.string.description('Width of the button').defaultValue('100%'),
32
+ height: reactDesc.PropTypes.string.description('Height of the button').defaultValue('100%')
33
+ };
34
+ const DSPillV2DefaultProps = {
35
+ innerRef: () => null,
36
+ ariaLabel: '',
37
+ tooltipValue: '',
38
+ iconLeft: null,
39
+ iconRight: null,
40
+ onRemove: () => null,
41
+ inputPlaceholder: '',
42
+ onInputChange: () => null,
43
+ onInputClear: () => null,
44
+ inputWidth: 72,
45
+ inputRender: DSInput__default["default"],
46
+ dropdownProps: {}
47
+ };
48
+ const DSPillButtonDefaultProps = {
49
+ type: 'right',
50
+ width: '100%',
51
+ height: '100%'
52
+ };
53
+
54
+ exports.DSPillButtonDefaultProps = DSPillButtonDefaultProps;
55
+ exports.DSPillButtonPropTypes = DSPillButtonPropTypes;
56
+ exports.DSPillV2DefaultProps = DSPillV2DefaultProps;
57
+ exports.DSPillV2PropTypes = DSPillV2PropTypes;
package/cjs/utils.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const setMultipleRefs = (...refs) => _ref => {
6
+ refs.forEach(ref => {
7
+ if (!ref || !_ref) return;
8
+
9
+ if (typeof ref === 'function') {
10
+ ref(_ref);
11
+ return;
12
+ }
13
+
14
+ if (ref) ref.current = _ref;
15
+ });
16
+ };
17
+
18
+ exports.setMultipleRefs = setMultipleRefs;
@@ -0,0 +1,39 @@
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import 'react';
3
+ import { describe } from 'react-desc';
4
+ import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
5
+ import { DSPillV2PropTypes, DSPillV2DefaultProps } from '../props.js';
6
+ import { DropdownPill } from './types/DropdownPill.js';
7
+ import { InputPill } from './types/InputPill.js';
8
+ import { LabelPill } from './types/LabelPill.js';
9
+ import { ReadOnlyPill } from './types/ReadOnlyPill.js';
10
+ import { RemovablePill } from './types/RemovablePill.js';
11
+ import { ValuePill } from './types/ValuePill.js';
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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
+ const pillComponentGetter = {
18
+ dropdown: DropdownPill,
19
+ input: InputPill,
20
+ label: LabelPill,
21
+ readonly: ReadOnlyPill,
22
+ removable: RemovablePill,
23
+ value: ValuePill
24
+ };
25
+
26
+ const DSPillV2 = props => {
27
+ const propsWithDefaults = useMemoMergePropsWithDefault(props, DSPillV2DefaultProps);
28
+ useValidateTypescriptPropTypes(propsWithDefaults, DSPillV2WithSchema.toTypescript());
29
+ const {
30
+ type
31
+ } = propsWithDefaults;
32
+ const PillComponent = pillComponentGetter[type];
33
+ return /*#__PURE__*/jsx(PillComponent, _objectSpread({}, propsWithDefaults));
34
+ };
35
+
36
+ const DSPillV2WithSchema = describe(DSPillV2).description('Pill');
37
+ DSPillV2WithSchema.propTypes = DSPillV2PropTypes;
38
+
39
+ export { DSPillV2, DSPillV2WithSchema };
@@ -0,0 +1,41 @@
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
3
+ import 'react';
4
+ import { describe } from 'react-desc';
5
+ import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
6
+ import { StyledPillButton } from './styled.js';
7
+ import { DSPillButtonPropTypes, DSPillButtonDefaultProps } from '../props.js';
8
+ import { jsx } from 'react/jsx-runtime';
9
+
10
+ const _excluded = ["type", "children"];
11
+
12
+ 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
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
+ const typeToClassName = {
16
+ only: 'ds-pill-button-only',
17
+ left: 'ds-pill-button-left',
18
+ right: 'ds-pill-button-right'
19
+ };
20
+
21
+ const DSPillButton = props => {
22
+ const propsWithDefaults = useMemoMergePropsWithDefault(props, DSPillButtonDefaultProps);
23
+ useValidateTypescriptPropTypes(propsWithDefaults, DSPillButtonWithSchema.toTypescript());
24
+
25
+ const {
26
+ type,
27
+ children
28
+ } = propsWithDefaults,
29
+ rest = _objectWithoutProperties(propsWithDefaults, _excluded);
30
+
31
+ return /*#__PURE__*/jsx(StyledPillButton, _objectSpread(_objectSpread({}, rest), {}, {
32
+ buttonType: "raw",
33
+ className: `${typeToClassName[type]} ${rest.className}`,
34
+ children: children
35
+ }));
36
+ };
37
+
38
+ const DSPillButtonWithSchema = describe(DSPillButton).description('Pill button');
39
+ DSPillButtonWithSchema.propTypes = DSPillButtonPropTypes;
40
+
41
+ export { DSPillButton, DSPillButtonWithSchema };
@@ -0,0 +1,39 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import React, { createContext, useMemo, useCallback } from 'react';
3
+ import { describe } from 'react-desc';
4
+ import { uid } from 'uid';
5
+ import { StyledPillGroup } from './styled.js';
6
+
7
+ const DSPillGroupV2Context = /*#__PURE__*/createContext({
8
+ onKeyboardRemove: () => null
9
+ });
10
+
11
+ const DSPillGroupV2 = ({
12
+ children
13
+ }) => {
14
+ const pillGroupUid = useMemo(() => `ds-pill-group-${uid()}`, []);
15
+ const onKeyboardRemove = useCallback(pillUid => {
16
+ const elems = [...document.querySelectorAll(`#${pillGroupUid} .ds-pill-focus-point`)];
17
+ const pillIndex = elems.findIndex(elem => elem.id === pillUid);
18
+
19
+ if (pillIndex > 0) {
20
+ elems[pillIndex - 1].focus();
21
+ } else if (pillIndex + 1 < elems.length) {
22
+ elems[pillIndex + 1].focus();
23
+ }
24
+ }, [pillGroupUid]);
25
+ return /*#__PURE__*/_jsx(DSPillGroupV2Context.Provider, {
26
+ value: {
27
+ onKeyboardRemove
28
+ }
29
+ }, void 0, /*#__PURE__*/_jsx(StyledPillGroup, {
30
+ id: pillGroupUid,
31
+ cols: React.Children.map(children, () => 'auto'),
32
+ gutter: "2px"
33
+ }, void 0, children));
34
+ };
35
+
36
+ const DSPillGroupV2WithSchema = describe(DSPillGroupV2);
37
+ DSPillGroupV2WithSchema.propTypes = {};
38
+
39
+ export { DSPillGroupV2, DSPillGroupV2Context, DSPillGroupV2WithSchema };
@@ -0,0 +1,3 @@
1
+ export { DSPillV2, DSPillV2WithSchema } from './Pill.js';
2
+ export { DSPillGroupV2, DSPillGroupV2Context, DSPillGroupV2WithSchema } from './PillGroup.js';
3
+ export { DSPillButton, DSPillButtonWithSchema } from './PillButton.js';
@@ -0,0 +1,52 @@
1
+ import styled, { css } from 'styled-components';
2
+ import Grid from '@elliemae/ds-grid';
3
+ import { DSButtonV2 } from '@elliemae/ds-button';
4
+
5
+ /* eslint-disable max-lines */
6
+ // Common CSS
7
+ // =============================================================================
8
+
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);
10
+
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])); // =============================================================================
12
+ // Pills wrappers
13
+ // =============================================================================
14
+
15
+ const StyledLabelPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
16
+ componentId: "sc-j0tlch-0"
17
+ })(["", " font-weight:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.semibold, props => props.hasIcon ? '0px !important' : '12px');
18
+ const StyledValuePillWrapper = /*#__PURE__*/styled(Grid).withConfig({
19
+ componentId: "sc-j0tlch-1"
20
+ })(["", " font-weight:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.regular, props => props.hasIcon ? '0px !important' : '12px');
21
+ const StyledInputPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
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'], ({
24
+ value,
25
+ theme
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`);
27
+ const StyledDropdownPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
28
+ componentId: "sc-j0tlch-3"
29
+ })(["", " font-weight:", ";padding:0 0 0 12px;"], commonPillWrapperCss, props => props.theme.fontWeights.semibold);
30
+ const StyledReadonlyPillWrapper = /*#__PURE__*/styled(Grid).withConfig({
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');
33
+ const StyledRemovablePillWrapper = /*#__PURE__*/styled(Grid).withConfig({
34
+ componentId: "sc-j0tlch-5"
35
+ })(["", " font-weight:", ";padding:0 0 0 12px;"], commonPillWrapperCss, props => props.theme.fontWeights.regular); // =============================================================================
36
+ // Pill group
37
+ // =============================================================================
38
+
39
+ const StyledPillGroup = /*#__PURE__*/styled(Grid).withConfig({
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'));
51
+
52
+ export { StyledDropdownPillWrapper, StyledInputPillWrapper, StyledLabelPillWrapper, StyledPillButton, StyledPillGroup, StyledReadonlyPillWrapper, StyledRemovablePillWrapper, StyledSpanWithTooltip, StyledValuePillWrapper };
@@ -0,0 +1,54 @@
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
3
+ import React, { useRef, useMemo } from 'react';
4
+ import DSDropdownMenu from '@elliemae/ds-dropdownmenu';
5
+ import { uid } from 'uid';
6
+ import ChevronDown from '@elliemae/ds-icons/ChevronSmallDown';
7
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
8
+ import { StyledDropdownPillWrapper } from '../styled.js';
9
+ import { setMultipleRefs } from '../../utils.js';
10
+ import { DSPillButton } from '../PillButton.js';
11
+ import { jsx } from 'react/jsx-runtime';
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; }
14
+
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
+ const DropdownPill = /*#__PURE__*/React.memo(({
17
+ label,
18
+ dropdownProps,
19
+ innerRef,
20
+ ariaLabel
21
+ }) => {
22
+ const chevronRef = useRef(null);
23
+ const pillUid = useMemo(() => `ds-pill-${uid()}`, []);
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({
35
+ hideIfNotVisible: true,
36
+ onClose: () => chevronRef.current.focus(),
37
+ menuProps: {
38
+ zIndex: 100
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
+ })));
52
+ });
53
+
54
+ export { DropdownPill };
@@ -0,0 +1,61 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import React, { useRef, useMemo, useCallback, useState } from 'react';
3
+ import { uid } from 'uid';
4
+ import CloseIcon from '@elliemae/ds-icons/CloseXsmall';
5
+ import { StyledInputPillWrapper } from '../styled.js';
6
+ import { setMultipleRefs } from '../../utils.js';
7
+ import { DSPillButton } from '../PillButton.js';
8
+
9
+ const InputPill = /*#__PURE__*/React.memo(({
10
+ label,
11
+ inputPlaceholder,
12
+ inputWidth,
13
+ inputRender,
14
+ onInputChange,
15
+ onInputClear,
16
+ innerRef
17
+ }) => {
18
+ const ref = useRef(null);
19
+ const InputComponent = useMemo(() => inputRender, [inputRender]);
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);
29
+ return /*#__PURE__*/_jsx(StyledInputPillWrapper, {
30
+ className: "ds-pill-wrapper",
31
+ "data-testid": "ds-pill-wrapper",
32
+ cols: label === '' ? ['auto'] : ['auto', '24px'],
33
+ inputWidth: inputWidth,
34
+ value: label,
35
+ inputHasFocus: inputHasFocus
36
+ }, void 0, /*#__PURE__*/_jsx(InputComponent, {
37
+ id: pillUid,
38
+ className: "ds-pill-focus-point",
39
+ "data-testid": "ds-pill-input",
40
+ innerRef: setMultipleRefs(ref, innerRef),
41
+ value: label,
42
+ onChange: onInputChange,
43
+ placeholder: inputPlaceholder,
44
+ onFocus: () => setInputHasFocus(true),
45
+ onBlur: () => setInputHasFocus(false),
46
+ disableTooltip: false
47
+ }), label !== '' && /*#__PURE__*/_jsx(DSPillButton, {
48
+ id: pillUid,
49
+ "data-testid": "ds-pill-clear-icon",
50
+ innerRef: innerRef,
51
+ onClick: onCloseIconClick,
52
+ onKeyDown: onCloseIconClick,
53
+ "aria-label": "Clear input",
54
+ type: "right"
55
+ }, void 0, /*#__PURE__*/_jsx(CloseIcon, {
56
+ size: "s",
57
+ color: ['brand-primary', '700']
58
+ })));
59
+ });
60
+
61
+ export { InputPill };
@@ -0,0 +1,22 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import React from 'react';
3
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
4
+ import { StyledLabelPillWrapper } from '../styled.js';
5
+
6
+ const LabelPill = /*#__PURE__*/React.memo(({
7
+ label,
8
+ iconLeft,
9
+ ariaLabel
10
+ }) => /*#__PURE__*/_jsx(StyledLabelPillWrapper, {
11
+ alignItems: "center",
12
+ className: "ds-pill-wrapper ds-pill-wrapper-label",
13
+ "data-testid": "ds-pill-wrapper",
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
+ })));
21
+
22
+ export { LabelPill };
@@ -0,0 +1,28 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import React from 'react';
3
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
4
+ import { StyledReadonlyPillWrapper } from '../styled.js';
5
+
6
+ const ReadOnlyPill = /*#__PURE__*/React.memo(({
7
+ label,
8
+ iconLeft,
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
+ });
27
+
28
+ export { ReadOnlyPill };
@@ -0,0 +1,52 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import React, { useContext, useMemo, useCallback } from 'react';
3
+ import { uid } from 'uid';
4
+ import CloseIcon from '@elliemae/ds-icons/CloseXsmall';
5
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
6
+ import { StyledRemovablePillWrapper } from '../styled.js';
7
+ import { DSPillGroupV2Context } from '../PillGroup.js';
8
+ import { DSPillButton } from '../PillButton.js';
9
+
10
+ const RemovablePill = /*#__PURE__*/React.memo(({
11
+ label,
12
+ onRemove,
13
+ innerRef,
14
+ ariaLabel
15
+ }) => {
16
+ const {
17
+ onKeyboardRemove
18
+ } = useContext(DSPillGroupV2Context);
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]);
27
+ return /*#__PURE__*/_jsx(StyledRemovablePillWrapper, {
28
+ cols: ['auto', '24px'],
29
+ gutter: "2px",
30
+ alignItems: "center",
31
+ justifyItems: "center",
32
+ className: "ds-pill-wrapper ds-pill-wrapper-removable",
33
+ "data-testid": "ds-pill-wrapper",
34
+ "aria-label": ariaLabel || label
35
+ }, void 0, /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
36
+ value: label
37
+ }), /*#__PURE__*/_jsx(DSPillButton, {
38
+ className: "ds-pill-focus-point",
39
+ id: pillUid,
40
+ "data-testid": "ds-pill-close-icon",
41
+ innerRef: innerRef,
42
+ onClick: onRemove,
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
+ })));
50
+ });
51
+
52
+ export { RemovablePill };
@@ -0,0 +1,30 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import React from 'react';
3
+ import { DSTooltipV3 } from '@elliemae/ds-tooltip';
4
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
5
+ import { StyledValuePillWrapper, StyledSpanWithTooltip } from '../styled.js';
6
+
7
+ const ValuePill = /*#__PURE__*/React.memo(({
8
+ label,
9
+ tooltipValue,
10
+ iconLeft,
11
+ ariaLabel
12
+ }) => /*#__PURE__*/_jsx(StyledValuePillWrapper, {
13
+ alignItems: "center",
14
+ className: "ds-pill-wrapper ds-pill-wrapper-value",
15
+ "data-testid": "ds-pill-wrapper",
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
+ })));
29
+
30
+ export { ValuePill };
@@ -0,0 +1,6 @@
1
+ export { DropdownPill } from './DropdownPill.js';
2
+ export { InputPill } from './InputPill.js';
3
+ export { LabelPill } from './LabelPill.js';
4
+ export { ReadOnlyPill } from './ReadOnlyPill.js';
5
+ export { RemovablePill } from './RemovablePill.js';
6
+ export { ValuePill } from './ValuePill.js';
@@ -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
File without changes
File without changes
@@ -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",
@@ -0,0 +1,8 @@
1
+ export { DSPillWithSchema, Pill } 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 CHANGED
@@ -1,8 +1,11 @@
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';
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';