@elliemae/ds-pills 2.0.0-alpha.1 → 2.0.0-alpha.13
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.
- package/cjs/components/Pill.js +53 -0
- package/cjs/components/PillButton.js +56 -0
- package/cjs/components/PillGroup.js +64 -0
- package/cjs/components/index.js +17 -0
- package/cjs/components/styled.js +85 -0
- package/cjs/components/types/DropdownPill.js +86 -0
- package/cjs/components/types/InputPill.js +74 -0
- package/cjs/components/types/LabelPill.js +46 -0
- package/cjs/components/types/ReadOnlyPill.js +50 -0
- package/cjs/components/types/RemovablePill.js +72 -0
- package/cjs/components/types/ValuePill.js +54 -0
- package/cjs/components/types/index.js +19 -0
- package/cjs/{DropdownPill.js → deprecated/DropdownPill.js} +16 -11
- package/cjs/{InputPill.js → deprecated/InputPill.js} +24 -20
- package/cjs/{LabeledDropdownPills.js → deprecated/LabeledDropdownPills.js} +8 -3
- package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownCascadeMenuPill.js +25 -15
- package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownMultiPill.js +28 -20
- package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownSinglePill.js +29 -24
- package/cjs/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/utils.js +4 -2
- package/cjs/{LabeledPills.js → deprecated/LabeledPills.js} +11 -10
- package/cjs/{OverflowPill.js → deprecated/OverflowPill.js} +20 -15
- package/cjs/{Pill.js → deprecated/Pill.js} +21 -13
- package/cjs/{PillGroup.js → deprecated/PillGroup.js} +26 -18
- package/cjs/{ReadOnlyPill.js → deprecated/ReadOnlyPill.js} +33 -29
- package/cjs/{RemovablePill.js → deprecated/RemovablePill.js} +17 -17
- package/cjs/deprecated/index.js +33 -0
- package/cjs/index.d.js +2 -0
- package/cjs/index.js +19 -9
- package/cjs/props.js +69 -0
- package/cjs/utils.js +28 -0
- package/esm/components/Pill.js +44 -0
- package/esm/components/PillButton.js +46 -0
- package/esm/components/PillGroup.js +53 -0
- package/esm/components/index.js +3 -0
- package/esm/components/styled.js +67 -0
- package/esm/components/types/DropdownPill.js +76 -0
- package/esm/components/types/InputPill.js +65 -0
- package/esm/components/types/LabelPill.js +37 -0
- package/esm/components/types/ReadOnlyPill.js +41 -0
- package/esm/components/types/RemovablePill.js +63 -0
- package/esm/components/types/ValuePill.js +45 -0
- package/esm/components/types/index.js +6 -0
- package/esm/{DropdownPill.js → deprecated/DropdownPill.js} +7 -1
- package/esm/{InputPill.js → deprecated/InputPill.js} +18 -11
- package/esm/{LabeledDropdownPills.js → deprecated/LabeledDropdownPills.js} +5 -0
- package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownCascadeMenuPill.js +15 -5
- package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownMultiPill.js +10 -2
- package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownSinglePill.js +15 -8
- package/esm/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/utils.js +3 -1
- package/esm/{LabeledPills.js → deprecated/LabeledPills.js} +9 -8
- package/esm/{OverflowPill.js → deprecated/OverflowPill.js} +12 -7
- package/esm/{Pill.js → deprecated/Pill.js} +18 -10
- package/esm/{PillGroup.js → deprecated/PillGroup.js} +25 -17
- package/esm/{ReadOnlyPill.js → deprecated/ReadOnlyPill.js} +26 -21
- package/esm/{RemovablePill.js → deprecated/RemovablePill.js} +10 -9
- package/esm/deprecated/index.js +8 -0
- package/esm/index.d.js +1 -0
- package/esm/index.js +11 -8
- package/esm/props.js +60 -0
- package/esm/utils.js +24 -0
- package/package.json +120 -51
- package/types/components/Pill.d.ts +5 -0
- package/types/components/PillButton.d.ts +5 -0
- package/types/components/PillGroup.d.ts +13 -0
- package/types/components/index.d.ts +3 -0
- package/types/components/styled.d.ts +24 -0
- package/types/components/types/DropdownPill.d.ts +3 -0
- package/types/components/types/InputPill.d.ts +3 -0
- package/types/components/types/LabelPill.d.ts +3 -0
- package/types/components/types/ReadOnlyPill.d.ts +3 -0
- package/types/components/types/RemovablePill.d.ts +3 -0
- package/types/components/types/ValuePill.d.ts +3 -0
- package/types/components/types/index.d.ts +6 -0
- package/types/deprecated/DropdownPill.d.ts +75 -0
- package/types/{InputPill.d.ts → deprecated/InputPill.d.ts} +0 -0
- package/types/deprecated/LabeledDropdownPills.d.ts +93 -0
- package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownCascadeMenuPill.d.ts +0 -0
- package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownMultiPill.d.ts +0 -0
- package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/LabeledDropdownSinglePill.d.ts +0 -0
- package/types/{LabeledDropdownPillsTypes → deprecated/LabeledDropdownPillsTypes}/utils.d.ts +1 -1
- package/types/deprecated/LabeledPills.d.ts +59 -0
- package/types/deprecated/OverflowPill.d.ts +37 -0
- package/types/deprecated/Pill.d.ts +67 -0
- package/types/deprecated/PillGroup.d.ts +56 -0
- package/types/deprecated/ReadOnlyPill.d.ts +63 -0
- package/types/deprecated/RemovablePill.d.ts +55 -0
- package/types/deprecated/index.d.ts +9 -0
- package/types/index.d.ts +3 -9
- package/types/props.d.ts +92 -0
- package/types/tests/DSPill.test.d.ts +1 -0
- package/types/tests/DSPillGroup.test.d.ts +1 -0
- package/types/tests/events/DSPill.events.keyboard.test.d.ts +1 -0
- package/types/tests/events/DSPill.events.test.d.ts +1 -0
- package/types/tests/events/DSPillGroup.events.keyboard.test.d.ts +1 -0
- package/types/tests/events/DSPillGroup.events.test.d.ts +1 -0
- package/types/utils.d.ts +4 -0
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
- package/types/DropdownPill.d.ts +0 -31
- package/types/LabeledDropdownPills.d.ts +0 -37
- package/types/LabeledPills.d.ts +0 -27
- package/types/OverflowPill.d.ts +0 -18
- package/types/Pill.d.ts +0 -29
- package/types/PillGroup.d.ts +0 -25
- package/types/ReadOnlyPill.d.ts +0 -26
- package/types/RemovablePill.d.ts +0 -24
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
require('react');
|
|
12
|
+
var reactDesc = require('react-desc');
|
|
13
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
14
|
+
var props = require('../props.js');
|
|
15
|
+
var DropdownPill = require('./types/DropdownPill.js');
|
|
16
|
+
var InputPill = require('./types/InputPill.js');
|
|
17
|
+
var LabelPill = require('./types/LabelPill.js');
|
|
18
|
+
var ReadOnlyPill = require('./types/ReadOnlyPill.js');
|
|
19
|
+
var RemovablePill = require('./types/RemovablePill.js');
|
|
20
|
+
var ValuePill = require('./types/ValuePill.js');
|
|
21
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
22
|
+
|
|
23
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
26
|
+
|
|
27
|
+
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; }
|
|
28
|
+
|
|
29
|
+
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__default["default"](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; }
|
|
30
|
+
const pillComponentGetter = {
|
|
31
|
+
dropdown: DropdownPill.DropdownPill,
|
|
32
|
+
input: InputPill.InputPill,
|
|
33
|
+
label: LabelPill.LabelPill,
|
|
34
|
+
readonly: ReadOnlyPill.ReadOnlyPill,
|
|
35
|
+
removable: RemovablePill.RemovablePill,
|
|
36
|
+
value: ValuePill.ValuePill
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const DSPillV2 = props$1 => {
|
|
40
|
+
const propsWithDefaults = dsPropsHelpers.useMemoMergePropsWithDefault(props$1, props.DSPillV2DefaultProps);
|
|
41
|
+
dsPropsHelpers.useValidateTypescriptPropTypes(propsWithDefaults, props.DSPillV2PropTypes);
|
|
42
|
+
const {
|
|
43
|
+
type
|
|
44
|
+
} = propsWithDefaults;
|
|
45
|
+
const PillComponent = pillComponentGetter[type];
|
|
46
|
+
return /*#__PURE__*/jsxRuntime.jsx(PillComponent, _objectSpread({}, propsWithDefaults));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const DSPillV2WithSchema = reactDesc.describe(DSPillV2).description('Pill');
|
|
50
|
+
DSPillV2WithSchema.propTypes = props.DSPillV2PropTypes;
|
|
51
|
+
|
|
52
|
+
exports.DSPillV2 = DSPillV2;
|
|
53
|
+
exports.DSPillV2WithSchema = DSPillV2WithSchema;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
12
|
+
require('react');
|
|
13
|
+
var reactDesc = require('react-desc');
|
|
14
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
15
|
+
var styled = require('./styled.js');
|
|
16
|
+
var props = require('../props.js');
|
|
17
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
18
|
+
|
|
19
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
+
|
|
21
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
|
+
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
23
|
+
|
|
24
|
+
const _excluded = ["type", "children"];
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
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__default["default"](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; }
|
|
29
|
+
const typeToClassName = {
|
|
30
|
+
only: 'ds-pill-button-only',
|
|
31
|
+
left: 'ds-pill-button-left',
|
|
32
|
+
right: 'ds-pill-button-right'
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const DSPillButton = props$1 => {
|
|
36
|
+
const propsWithDefaults = dsPropsHelpers.useMemoMergePropsWithDefault(props$1, props.DSPillButtonDefaultProps);
|
|
37
|
+
dsPropsHelpers.useValidateTypescriptPropTypes(propsWithDefaults, props.DSPillButtonPropTypes);
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
type,
|
|
41
|
+
children
|
|
42
|
+
} = propsWithDefaults,
|
|
43
|
+
rest = _objectWithoutProperties__default["default"](propsWithDefaults, _excluded);
|
|
44
|
+
|
|
45
|
+
return /*#__PURE__*/jsxRuntime.jsx(styled.StyledPillButton, _objectSpread(_objectSpread({}, rest), {}, {
|
|
46
|
+
buttonType: "raw",
|
|
47
|
+
className: "".concat(typeToClassName[type], " ").concat(rest.className),
|
|
48
|
+
children: children
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const DSPillButtonWithSchema = reactDesc.describe(DSPillButton).description('Pill button');
|
|
53
|
+
DSPillButtonWithSchema.propTypes = props.DSPillButtonPropTypes;
|
|
54
|
+
|
|
55
|
+
exports.DSPillButton = DSPillButton;
|
|
56
|
+
exports.DSPillButtonWithSchema = DSPillButtonWithSchema;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var reactDesc = require('react-desc');
|
|
11
|
+
var uid = require('uid');
|
|
12
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
13
|
+
var props = require('../props.js');
|
|
14
|
+
var styled = require('./styled.js');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
+
|
|
22
|
+
const DSPillGroupV2Context = /*#__PURE__*/React.createContext({
|
|
23
|
+
onKeyboardRemove: () => null
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const DSPillGroupV2 = props$1 => {
|
|
27
|
+
const propsWithDefaults = dsPropsHelpers.useMemoMergePropsWithDefault(props$1, props.DSPillGroupDefaultProps);
|
|
28
|
+
dsPropsHelpers.useValidateTypescriptPropTypes(propsWithDefaults, props.DSPillGroupPropTypes);
|
|
29
|
+
const pillGroupUid = React.useMemo(() => "ds-pill-group-".concat(uid.uid()), []);
|
|
30
|
+
const {
|
|
31
|
+
children,
|
|
32
|
+
width,
|
|
33
|
+
innerRef
|
|
34
|
+
} = propsWithDefaults;
|
|
35
|
+
const onKeyboardRemove = React.useCallback(pillUid => {
|
|
36
|
+
const elems = [...document.querySelectorAll("#".concat(pillGroupUid, " .ds-pill-focus-point"))];
|
|
37
|
+
const pillIndex = elems.findIndex(elem => elem.id === pillUid);
|
|
38
|
+
|
|
39
|
+
if (pillIndex > 0) {
|
|
40
|
+
elems[pillIndex - 1].focus();
|
|
41
|
+
} else if (pillIndex + 1 < elems.length) {
|
|
42
|
+
elems[pillIndex + 1].focus();
|
|
43
|
+
}
|
|
44
|
+
}, [pillGroupUid]);
|
|
45
|
+
return /*#__PURE__*/_jsx__default["default"](DSPillGroupV2Context.Provider, {
|
|
46
|
+
value: {
|
|
47
|
+
onKeyboardRemove
|
|
48
|
+
}
|
|
49
|
+
}, void 0, /*#__PURE__*/jsxRuntime.jsx(styled.StyledPillGroup, {
|
|
50
|
+
width: width,
|
|
51
|
+
id: pillGroupUid,
|
|
52
|
+
cols: React__default["default"].Children.map(children, () => 'auto'),
|
|
53
|
+
gutter: "2px",
|
|
54
|
+
ref: innerRef,
|
|
55
|
+
children: children
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const DSPillGroupV2WithSchema = reactDesc.describe(DSPillGroupV2);
|
|
60
|
+
DSPillGroupV2WithSchema.propTypes = props.DSPillGroupPropTypes;
|
|
61
|
+
|
|
62
|
+
exports.DSPillGroupV2 = DSPillGroupV2;
|
|
63
|
+
exports.DSPillGroupV2Context = DSPillGroupV2Context;
|
|
64
|
+
exports.DSPillGroupV2WithSchema = DSPillGroupV2WithSchema;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Pill = require('./Pill.js');
|
|
6
|
+
var PillGroup = require('./PillGroup.js');
|
|
7
|
+
var PillButton = require('./PillButton.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.DSPillV2 = Pill.DSPillV2;
|
|
12
|
+
exports.DSPillV2WithSchema = Pill.DSPillV2WithSchema;
|
|
13
|
+
exports.DSPillGroupV2 = PillGroup.DSPillGroupV2;
|
|
14
|
+
exports.DSPillGroupV2Context = PillGroup.DSPillGroupV2Context;
|
|
15
|
+
exports.DSPillGroupV2WithSchema = PillGroup.DSPillGroupV2WithSchema;
|
|
16
|
+
exports.DSPillButton = PillButton.DSPillButton;
|
|
17
|
+
exports.DSPillButtonWithSchema = PillButton.DSPillButtonWithSchema;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
var dsSystem = require('@elliemae/ds-system');
|
|
8
|
+
var Grid = require('@elliemae/ds-grid');
|
|
9
|
+
var dsButton = require('@elliemae/ds-button');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
14
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
|
+
var Grid__default = /*#__PURE__*/_interopDefaultLegacy(Grid);
|
|
16
|
+
|
|
17
|
+
var _templateObject, _templateObject2;
|
|
18
|
+
// Common CSS
|
|
19
|
+
// =============================================================================
|
|
20
|
+
|
|
21
|
+
const borderOutside = function (color) {
|
|
22
|
+
let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
23
|
+
let zIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
24
|
+
let borderRadius = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '12px';
|
|
25
|
+
return dsSystem.css(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n :after {\n content: ' ';\n position: absolute;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n border: ", "px solid ", ";\n border-top-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n pointer-events: none;\n z-index: ", ";\n }\n"])), size, color, borderRadius, borderRadius, borderRadius, borderRadius, zIndex);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const commonPillWrapperCss = dsSystem.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n height: ", ";\n\n position: relative;\n\n width: fit-content;\n\n background-color: ", ";\n\n outline: none;\n\n white-space: nowrap;\n\n padding: 0px 12px 0 12px;\n border-radius: 12px;\n\n font-size: 13px;\n line-height: 1;\n color: ", ";\n ", ";\n"])), props => (props === null || props === void 0 ? void 0 : props.size) === 'm' ? '24px' : '18px', props => props.theme.colors.brand[200], props => props.theme.colors.brand[800], props => borderOutside(props.theme.colors.brand[300])); // =============================================================================
|
|
29
|
+
// Pills wrappers
|
|
30
|
+
// =============================================================================
|
|
31
|
+
|
|
32
|
+
const StyledLabelPillWrapper = /*#__PURE__*/styled__default["default"](Grid__default["default"]).withConfig({
|
|
33
|
+
componentId: "sc-j0tlch-0"
|
|
34
|
+
})(["", " font-weight:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.semibold, props => props.hasIcon ? '0px !important' : '12px');
|
|
35
|
+
const StyledValuePillWrapper = /*#__PURE__*/styled__default["default"](Grid__default["default"]).withConfig({
|
|
36
|
+
componentId: "sc-j0tlch-1"
|
|
37
|
+
})(["", " font-weight:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.regular, props => props.hasIcon ? '0px !important' : '12px');
|
|
38
|
+
const StyledInputPillWrapper = /*#__PURE__*/styled__default["default"](Grid__default["default"]).withConfig({
|
|
39
|
+
componentId: "sc-j0tlch-2"
|
|
40
|
+
})(["", " 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'], _ref => {
|
|
41
|
+
let {
|
|
42
|
+
value,
|
|
43
|
+
theme
|
|
44
|
+
} = _ref;
|
|
45
|
+
return borderOutside(value === '' ? theme.colors.neutral[400] : theme.colors.brand[500]);
|
|
46
|
+
}, props => props.inputHasFocus ? borderOutside(props.theme.colors.brand[700], 2) : '', props => props.inputHasFocus ? borderOutside(props.theme.colors.brand[500]) : '', props => "".concat(props.inputWidth + (props.value === '' ? 24 : 0), "px"));
|
|
47
|
+
const StyledDropdownPillWrapper = /*#__PURE__*/styled__default["default"](Grid__default["default"]).withConfig({
|
|
48
|
+
componentId: "sc-j0tlch-3"
|
|
49
|
+
})(["", " font-weight:", ";padding:0 0 0 12px;"], commonPillWrapperCss, props => props.theme.fontWeights.semibold);
|
|
50
|
+
const StyledReadonlyPillWrapper = /*#__PURE__*/styled__default["default"](Grid__default["default"]).withConfig({
|
|
51
|
+
componentId: "sc-j0tlch-4"
|
|
52
|
+
})(["", " font-weight:", ";padding-right:", ";padding-left:", ";"], commonPillWrapperCss, props => props.theme.fontWeights.semibold, props => props.hasIconRight ? '0 !important' : '12px', props => props.hasIconLeft ? '0 !important' : '12px');
|
|
53
|
+
const StyledRemovablePillWrapper = /*#__PURE__*/styled__default["default"](Grid__default["default"]).withConfig({
|
|
54
|
+
componentId: "sc-j0tlch-5"
|
|
55
|
+
})(["", " font-weight:", ";padding:0 0 0 12px;"], commonPillWrapperCss, props => props.theme.fontWeights.regular); // =============================================================================
|
|
56
|
+
// Pill group
|
|
57
|
+
// =============================================================================
|
|
58
|
+
|
|
59
|
+
const StyledPillGroup = /*#__PURE__*/styled__default["default"](Grid__default["default"]).withConfig({
|
|
60
|
+
componentId: "sc-j0tlch-6"
|
|
61
|
+
})(["width:", ";& .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;}}}"], _ref2 => {
|
|
62
|
+
let {
|
|
63
|
+
width
|
|
64
|
+
} = _ref2;
|
|
65
|
+
return width;
|
|
66
|
+
}); // =============================================================================
|
|
67
|
+
// Extra stuff
|
|
68
|
+
// =============================================================================
|
|
69
|
+
|
|
70
|
+
const StyledSpanWithTooltip = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
71
|
+
componentId: "sc-j0tlch-7"
|
|
72
|
+
})(["outline:none;:focus{", "}"], props => borderOutside(props.theme.colors.brand[700], 2, 3));
|
|
73
|
+
const StyledPillButton = /*#__PURE__*/styled__default["default"](dsButton.DSButtonV2).withConfig({
|
|
74
|
+
componentId: "sc-j0tlch-8"
|
|
75
|
+
})(["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'));
|
|
76
|
+
|
|
77
|
+
exports.StyledDropdownPillWrapper = StyledDropdownPillWrapper;
|
|
78
|
+
exports.StyledInputPillWrapper = StyledInputPillWrapper;
|
|
79
|
+
exports.StyledLabelPillWrapper = StyledLabelPillWrapper;
|
|
80
|
+
exports.StyledPillButton = StyledPillButton;
|
|
81
|
+
exports.StyledPillGroup = StyledPillGroup;
|
|
82
|
+
exports.StyledReadonlyPillWrapper = StyledReadonlyPillWrapper;
|
|
83
|
+
exports.StyledRemovablePillWrapper = StyledRemovablePillWrapper;
|
|
84
|
+
exports.StyledSpanWithTooltip = StyledSpanWithTooltip;
|
|
85
|
+
exports.StyledValuePillWrapper = StyledValuePillWrapper;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var DSDropdownMenu = require('@elliemae/ds-dropdownmenu');
|
|
14
|
+
var uid = require('uid');
|
|
15
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
16
|
+
var dsTruncatedTooltipText = require('@elliemae/ds-truncated-tooltip-text');
|
|
17
|
+
var styled = require('../styled.js');
|
|
18
|
+
var utils = require('../../utils.js');
|
|
19
|
+
var PillButton = require('../PillButton.js');
|
|
20
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
21
|
+
|
|
22
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
+
|
|
24
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
25
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
26
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
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__default["default"](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; }
|
|
31
|
+
const DropdownPill = /*#__PURE__*/React__default["default"].memo(_ref => {
|
|
32
|
+
let {
|
|
33
|
+
label,
|
|
34
|
+
size,
|
|
35
|
+
labelTruncated,
|
|
36
|
+
dropdownProps,
|
|
37
|
+
innerRef,
|
|
38
|
+
ariaLabel,
|
|
39
|
+
onDropdownClick
|
|
40
|
+
} = _ref;
|
|
41
|
+
const chevronRef = React.useRef(null);
|
|
42
|
+
const pillUid = React.useMemo(() => "ds-pill-".concat(uid.uid()), []);
|
|
43
|
+
const TextComponent = labelTruncated ? _ref2 => {
|
|
44
|
+
let {
|
|
45
|
+
children
|
|
46
|
+
} = _ref2;
|
|
47
|
+
return /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
|
|
48
|
+
value: children
|
|
49
|
+
});
|
|
50
|
+
} : React__default["default"].Fragment;
|
|
51
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledDropdownPillWrapper, {
|
|
52
|
+
size: size,
|
|
53
|
+
id: pillUid,
|
|
54
|
+
className: "ds-pill-wrapper ds-pill-wrapper-dropdown",
|
|
55
|
+
"data-testid": "ds-pill-wrapper",
|
|
56
|
+
cols: ['auto', '24px'],
|
|
57
|
+
gutter: "2px",
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
justifyItems: "center"
|
|
60
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](TextComponent, {}, void 0, label), /*#__PURE__*/jsxRuntime.jsx(DSDropdownMenu.DSDropdownMenuV2, _objectSpread(_objectSpread({
|
|
61
|
+
placementOrderPreference: ['bottom-start', 'bottom', 'bottom-end', 'right-end', 'top-start', 'top', 'top-end']
|
|
62
|
+
}, dropdownProps), {}, {
|
|
63
|
+
onClickOutside: e => {
|
|
64
|
+
if (e.code === 'Escape') chevronRef.current.focus();
|
|
65
|
+
if (dropdownProps.onClickOutside) dropdownProps.onClickOutside(e);
|
|
66
|
+
},
|
|
67
|
+
wrapperStyles: {
|
|
68
|
+
width: '100%',
|
|
69
|
+
height: '100%'
|
|
70
|
+
},
|
|
71
|
+
children: /*#__PURE__*/_jsx__default["default"](PillButton.DSPillButton, {
|
|
72
|
+
className: "ds-pill-focus-point",
|
|
73
|
+
"data-testid": "ds-pill-dropdown-chevron",
|
|
74
|
+
innerRef: utils.setMultipleRefs(chevronRef, innerRef),
|
|
75
|
+
"aria-label": ariaLabel || label,
|
|
76
|
+
type: "right",
|
|
77
|
+
onClick: onDropdownClick
|
|
78
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallDown, {
|
|
79
|
+
color: ['brand-primary', '800'],
|
|
80
|
+
width: 20,
|
|
81
|
+
height: 20
|
|
82
|
+
}))
|
|
83
|
+
})));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
exports.DropdownPill = DropdownPill;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var uid = require('uid');
|
|
9
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
10
|
+
var styled = require('../styled.js');
|
|
11
|
+
var utils = require('../../utils.js');
|
|
12
|
+
var PillButton = require('../PillButton.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
18
|
+
|
|
19
|
+
const InputPill = /*#__PURE__*/React__default["default"].memo(_ref => {
|
|
20
|
+
let {
|
|
21
|
+
label,
|
|
22
|
+
size,
|
|
23
|
+
inputPlaceholder,
|
|
24
|
+
inputWidth,
|
|
25
|
+
inputRender,
|
|
26
|
+
onInputChange,
|
|
27
|
+
onInputClear,
|
|
28
|
+
innerRef
|
|
29
|
+
} = _ref;
|
|
30
|
+
const ref = React.useRef(null);
|
|
31
|
+
const InputComponent = React.useMemo(() => inputRender, [inputRender]);
|
|
32
|
+
const pillUid = React.useMemo(() => "ds-pill-".concat(uid.uid()), []);
|
|
33
|
+
const onCloseIconClick = React.useCallback(e => {
|
|
34
|
+
if ([undefined, 'Enter', 'Space'].includes(e.code)) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
onInputClear(e);
|
|
37
|
+
ref.current.focus();
|
|
38
|
+
}
|
|
39
|
+
}, [onInputClear]);
|
|
40
|
+
const [inputHasFocus, setInputHasFocus] = React.useState(false);
|
|
41
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledInputPillWrapper, {
|
|
42
|
+
size: size,
|
|
43
|
+
className: "ds-pill-wrapper",
|
|
44
|
+
"data-testid": "ds-pill-wrapper",
|
|
45
|
+
cols: label === '' ? ['auto'] : ['auto', '24px'],
|
|
46
|
+
inputWidth: inputWidth,
|
|
47
|
+
value: label,
|
|
48
|
+
inputHasFocus: inputHasFocus
|
|
49
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](InputComponent, {
|
|
50
|
+
id: pillUid,
|
|
51
|
+
className: "ds-pill-focus-point",
|
|
52
|
+
"data-testid": "ds-pill-input",
|
|
53
|
+
innerRef: utils.setMultipleRefs(ref, innerRef),
|
|
54
|
+
value: label,
|
|
55
|
+
onChange: onInputChange,
|
|
56
|
+
placeholder: inputPlaceholder,
|
|
57
|
+
onFocus: () => setInputHasFocus(true),
|
|
58
|
+
onBlur: () => setInputHasFocus(false),
|
|
59
|
+
disableTooltip: false
|
|
60
|
+
}), label !== '' && /*#__PURE__*/_jsx__default["default"](PillButton.DSPillButton, {
|
|
61
|
+
id: pillUid,
|
|
62
|
+
"data-testid": "ds-pill-clear-icon",
|
|
63
|
+
innerRef: innerRef,
|
|
64
|
+
onClick: onCloseIconClick,
|
|
65
|
+
onKeyDown: onCloseIconClick,
|
|
66
|
+
"aria-label": "Clear input",
|
|
67
|
+
type: "right"
|
|
68
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](dsIcons.CloseXsmall, {
|
|
69
|
+
size: "s",
|
|
70
|
+
color: ['brand-primary', '700']
|
|
71
|
+
})));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
exports.InputPill = InputPill;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var dsTruncatedTooltipText = require('@elliemae/ds-truncated-tooltip-text');
|
|
11
|
+
var styled = require('../styled.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
16
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
+
|
|
18
|
+
const LabelPill = /*#__PURE__*/React__default["default"].memo(_ref => {
|
|
19
|
+
let {
|
|
20
|
+
label,
|
|
21
|
+
size,
|
|
22
|
+
labelTruncated,
|
|
23
|
+
iconLeft,
|
|
24
|
+
ariaLabel
|
|
25
|
+
} = _ref;
|
|
26
|
+
const TextComponent = labelTruncated ? _ref2 => {
|
|
27
|
+
let {
|
|
28
|
+
children
|
|
29
|
+
} = _ref2;
|
|
30
|
+
return /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
|
|
31
|
+
value: children
|
|
32
|
+
});
|
|
33
|
+
} : React__default["default"].Fragment;
|
|
34
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledLabelPillWrapper, {
|
|
35
|
+
size: size,
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
className: "ds-pill-wrapper ds-pill-wrapper-label",
|
|
38
|
+
"data-testid": "ds-pill-wrapper",
|
|
39
|
+
"aria-label": ariaLabel || label,
|
|
40
|
+
cols: [iconLeft && 'min-content', 'auto'].filter(notFalse => notFalse),
|
|
41
|
+
gutter: "xxxs",
|
|
42
|
+
hasIcon: iconLeft !== null
|
|
43
|
+
}, void 0, iconLeft, /*#__PURE__*/_jsx__default["default"](TextComponent, {}, void 0, label));
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
exports.LabelPill = LabelPill;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var dsTruncatedTooltipText = require('@elliemae/ds-truncated-tooltip-text');
|
|
11
|
+
var styled = require('../styled.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
16
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
+
|
|
18
|
+
const ReadOnlyPill = /*#__PURE__*/React__default["default"].memo(_ref => {
|
|
19
|
+
let {
|
|
20
|
+
label,
|
|
21
|
+
size,
|
|
22
|
+
labelTruncated,
|
|
23
|
+
iconLeft,
|
|
24
|
+
iconRight,
|
|
25
|
+
ariaLabel
|
|
26
|
+
} = _ref;
|
|
27
|
+
const hasIconLeft = iconLeft !== null || iconRight !== null && label === '';
|
|
28
|
+
const hasIconRight = iconRight !== null || iconLeft !== null && label === '';
|
|
29
|
+
const TextComponent = labelTruncated ? _ref2 => {
|
|
30
|
+
let {
|
|
31
|
+
children
|
|
32
|
+
} = _ref2;
|
|
33
|
+
return /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
|
|
34
|
+
value: children
|
|
35
|
+
});
|
|
36
|
+
} : React__default["default"].Fragment;
|
|
37
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledReadonlyPillWrapper, {
|
|
38
|
+
size: size,
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
className: "ds-pill-wrapper ds-pill-wrapper-readonly",
|
|
41
|
+
"data-testid": "ds-pill-wrapper",
|
|
42
|
+
"aria-label": ariaLabel || label,
|
|
43
|
+
cols: [iconLeft && 'min-content', label && 'auto', iconRight && 'min-content'].filter(notFalse => notFalse),
|
|
44
|
+
gutter: "xxxs",
|
|
45
|
+
hasIconRight: hasIconRight,
|
|
46
|
+
hasIconLeft: hasIconLeft
|
|
47
|
+
}, void 0, iconLeft, label ? /*#__PURE__*/_jsx__default["default"](TextComponent, {}, void 0, label) : null, iconRight);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
exports.ReadOnlyPill = ReadOnlyPill;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var uid = require('uid');
|
|
8
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
9
|
+
var dsTruncatedTooltipText = require('@elliemae/ds-truncated-tooltip-text');
|
|
10
|
+
var styled = require('../styled.js');
|
|
11
|
+
var PillGroup = require('../PillGroup.js');
|
|
12
|
+
var PillButton = require('../PillButton.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
18
|
+
|
|
19
|
+
const RemovablePill = /*#__PURE__*/React__default["default"].memo(_ref => {
|
|
20
|
+
let {
|
|
21
|
+
label,
|
|
22
|
+
size,
|
|
23
|
+
labelTruncated,
|
|
24
|
+
onRemove,
|
|
25
|
+
innerRef,
|
|
26
|
+
ariaLabel
|
|
27
|
+
} = _ref;
|
|
28
|
+
const {
|
|
29
|
+
onKeyboardRemove
|
|
30
|
+
} = React.useContext(PillGroup.DSPillGroupV2Context);
|
|
31
|
+
const pillUid = React.useMemo(() => "ds-pill-".concat(uid.uid()), []);
|
|
32
|
+
const TextComponent = labelTruncated ? _ref2 => {
|
|
33
|
+
let {
|
|
34
|
+
children
|
|
35
|
+
} = _ref2;
|
|
36
|
+
return /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
|
|
37
|
+
value: children
|
|
38
|
+
});
|
|
39
|
+
} : React__default["default"].Fragment;
|
|
40
|
+
const onKeyDown = React.useCallback(e => {
|
|
41
|
+
if (['Enter', 'Space'].includes(e.code)) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
if (onKeyboardRemove) onKeyboardRemove(pillUid);
|
|
44
|
+
onRemove(e);
|
|
45
|
+
}
|
|
46
|
+
}, [onKeyboardRemove, onRemove, pillUid]);
|
|
47
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledRemovablePillWrapper, {
|
|
48
|
+
size: size,
|
|
49
|
+
cols: ['auto', '24px'],
|
|
50
|
+
gutter: "2px",
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
justifyItems: "center",
|
|
53
|
+
className: "ds-pill-wrapper ds-pill-wrapper-removable",
|
|
54
|
+
"data-testid": "ds-pill-wrapper",
|
|
55
|
+
"aria-label": ariaLabel || label
|
|
56
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](TextComponent, {}, void 0, label), /*#__PURE__*/_jsx__default["default"](PillButton.DSPillButton, {
|
|
57
|
+
className: "ds-pill-focus-point",
|
|
58
|
+
id: pillUid,
|
|
59
|
+
"data-testid": "ds-pill-close-icon",
|
|
60
|
+
innerRef: innerRef,
|
|
61
|
+
onClick: onRemove,
|
|
62
|
+
onKeyDown: onKeyDown,
|
|
63
|
+
"aria-label": "Remove ".concat(label),
|
|
64
|
+
type: "right"
|
|
65
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](dsIcons.CloseXsmall, {
|
|
66
|
+
width: 22.65,
|
|
67
|
+
height: 22.65,
|
|
68
|
+
color: ['brand-primary', '700']
|
|
69
|
+
})));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
exports.RemovablePill = RemovablePill;
|