@dhis2-ui/chip 9.11.0 → 9.11.1-beta.1

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.
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithOnRemove = exports.WithOnClick = exports.WithIcon = exports.WithChildren = exports.Default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _chip = require("./chip.js");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ window.onClick = window.Cypress && window.Cypress.cy.stub();
11
+ window.onRemove = window.Cypress && window.Cypress.cy.stub();
12
+ var _default = exports.default = {
13
+ title: 'Chip'
14
+ };
15
+ const Default = () => /*#__PURE__*/_react.default.createElement(_chip.Chip, null, "Message");
16
+ exports.Default = Default;
17
+ const WithOnClick = () => /*#__PURE__*/_react.default.createElement(_chip.Chip, {
18
+ onClick: window.onClick
19
+ }, "Chippy");
20
+ exports.WithOnClick = WithOnClick;
21
+ const WithOnRemove = () => /*#__PURE__*/_react.default.createElement(_chip.Chip, {
22
+ onRemove: window.onRemove
23
+ }, "Chipmunk");
24
+ exports.WithOnRemove = WithOnRemove;
25
+ const WithChildren = () => /*#__PURE__*/_react.default.createElement(_chip.Chip, null, "I am a child");
26
+ exports.WithChildren = WithChildren;
27
+ const WithIcon = () => /*#__PURE__*/_react.default.createElement(_chip.Chip, {
28
+ icon: /*#__PURE__*/_react.default.createElement("div", null, "Icon")
29
+ }, "Message");
30
+ exports.WithIcon = WithIcon;
package/build/cjs/chip.js CHANGED
@@ -4,30 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Chip = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
8
  var _uiConstants = require("@dhis2/ui-constants");
11
-
12
9
  var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
11
  var _react = _interopRequireDefault(require("react"));
17
-
18
12
  var _content = require("./content.js");
19
-
20
13
  var _icon = require("./icon.js");
21
-
22
14
  var _remove = require("./remove.js");
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
16
  const DEFAULT_INLINE_MARGIN = '4';
27
-
28
17
  const Chip = _ref => {
29
18
  var _ref2, _ref3, _ref4, _ref5;
30
-
31
19
  let {
32
20
  selected,
33
21
  dense,
@@ -54,7 +42,7 @@ const Chip = _ref => {
54
42
  }
55
43
  },
56
44
  "data-test": dataTest,
57
- className: _style.default.dynamic([["3780556490", [_uiConstants.colors.grey200, _uiConstants.colors.grey900, _uiConstants.colors.grey300, _uiConstants.theme.secondary600, _uiConstants.colors.white]], ["1687525377", [marginBottom && "margin-bottom: ".concat(marginBottom, "px;"), (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && "margin-top: ".concat(marginTop, "px")]]]) + " " + ((0, _classnames.default)(className, {
45
+ className: _style.default.dynamic([["3780556490", [_uiConstants.colors.grey200, _uiConstants.colors.grey900, _uiConstants.colors.grey300, _uiConstants.theme.secondary600, _uiConstants.colors.white]], ["1687525377", [marginBottom && `margin-bottom: ${marginBottom}px;`, (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && `margin-top: ${marginTop}px`]]]) + " " + ((0, _classnames.default)(className, {
58
46
  selected,
59
47
  dense,
60
48
  disabled,
@@ -62,21 +50,20 @@ const Chip = _ref => {
62
50
  }) || "")
63
51
  }, /*#__PURE__*/_react.default.createElement(_icon.Icon, {
64
52
  icon: icon,
65
- dataTest: "".concat(dataTest, "-icon")
53
+ dataTest: `${dataTest}-icon`
66
54
  }), /*#__PURE__*/_react.default.createElement(_content.Content, {
67
55
  overflow: overflow
68
56
  }, children), /*#__PURE__*/_react.default.createElement(_remove.Remove, {
69
57
  onRemove: onRemove,
70
- dataTest: "".concat(dataTest, "-remove")
58
+ dataTest: `${dataTest}-remove`
71
59
  }), /*#__PURE__*/_react.default.createElement(_style.default, {
72
60
  id: "3780556490",
73
61
  dynamic: [_uiConstants.colors.grey200, _uiConstants.colors.grey900, _uiConstants.colors.grey300, _uiConstants.theme.secondary600, _uiConstants.colors.white]
74
- }, ["span.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:32px;border-radius:16px;background-color:".concat(_uiConstants.colors.grey200, ";font-size:14px;line-height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:").concat(_uiConstants.colors.grey900, ";}"), ".dense.__jsx-style-dynamic-selector{height:24px;font-size:13px;line-height:15px;}", "span.__jsx-style-dynamic-selector:hover{background-color:".concat(_uiConstants.colors.grey300, ";}"), ".selected.__jsx-style-dynamic-selector{background-color:".concat(_uiConstants.theme.secondary600, ";font-weight:500;}"), ".selected.__jsx-style-dynamic-selector:hover{background-color:#00695c;}", ".selected.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{color:".concat(_uiConstants.colors.white, ";}"), ".disabled.__jsx-style-dynamic-selector{cursor:not-allowed;opacity:0.3;}", ".disabled.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{pointer-events:none;}", ".dragging.__jsx-style-dynamic-selector{box-shadow:0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
62
+ }, [`span.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:32px;border-radius:16px;background-color:${_uiConstants.colors.grey200};font-size:14px;line-height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:${_uiConstants.colors.grey900};}`, ".dense.__jsx-style-dynamic-selector{height:24px;font-size:13px;line-height:15px;}", `span.__jsx-style-dynamic-selector:hover{background-color:${_uiConstants.colors.grey300};}`, `.selected.__jsx-style-dynamic-selector{background-color:${_uiConstants.theme.secondary600};font-weight:500;}`, ".selected.__jsx-style-dynamic-selector:hover{background-color:#00695c;}", `.selected.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{color:${_uiConstants.colors.white};}`, ".disabled.__jsx-style-dynamic-selector{cursor:not-allowed;opacity:0.3;}", ".disabled.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{pointer-events:none;}", ".dragging.__jsx-style-dynamic-selector{box-shadow:0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
75
63
  id: "1687525377",
76
- dynamic: [marginBottom && "margin-bottom: ".concat(marginBottom, "px;"), (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && "margin-top: ".concat(marginTop, "px")]
77
- }, ["span.__jsx-style-dynamic-selector{".concat(marginBottom && "margin-bottom: ".concat(marginBottom, "px;"), " margin-inline-start:").concat((_ref4 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_INLINE_MARGIN, "px;margin-inline-end:").concat((_ref5 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_INLINE_MARGIN, "px;").concat(marginTop && "margin-top: ".concat(marginTop, "px"), ";}")]));
64
+ dynamic: [marginBottom && `margin-bottom: ${marginBottom}px;`, (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && `margin-top: ${marginTop}px`]
65
+ }, [`span.__jsx-style-dynamic-selector{${marginBottom && `margin-bottom: ${marginBottom}px;`} margin-inline-start:${(_ref4 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_INLINE_MARGIN}px;margin-inline-end:${(_ref5 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_INLINE_MARGIN}px;${marginTop && `margin-top: ${marginTop}px`};}`]));
78
66
  };
79
-
80
67
  exports.Chip = Chip;
81
68
  Chip.defaultProps = {
82
69
  dataTest: 'dhis2-uicore-chip',
@@ -91,22 +78,16 @@ Chip.propTypes = {
91
78
  disabled: _propTypes.default.bool,
92
79
  dragging: _propTypes.default.bool,
93
80
  icon: _propTypes.default.element,
94
-
95
81
  /** `margin-bottom` value, applied in `px` */
96
82
  marginBottom: _propTypes.default.number,
97
-
98
83
  /** `margin-inline-end` value, applied in `px` */
99
84
  marginInlineEnd: _propTypes.default.number,
100
-
101
85
  /** `margin-inline-start` value, applied in `px` */
102
86
  marginInlineStart: _propTypes.default.number,
103
-
104
87
  /** `margin-inline-start` value, applied in `px` */
105
88
  marginLeft: _propTypes.default.number,
106
-
107
89
  /** `margin-inline-end` value, applied in `px` */
108
90
  marginRight: _propTypes.default.number,
109
-
110
91
  /** `margin-top` value, applied in `px` */
111
92
  marginTop: _propTypes.default.number,
112
93
  overflow: _propTypes.default.bool,
@@ -4,37 +4,44 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.Selected = exports.Removable = exports.RTLRemovable = exports.Overflow = exports.IconContent = exports.Icon = exports.DenseRemoveable = exports.Dense = exports.Default = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _chip = require("./chip.js");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const subtitle = `Chips are useful for displaying a selection of defined choices and filters to the user.`;
12
+ const description = `
13
+ Chips are used to display a list of defined options, filters or views for a related view. Chips are always a secondary content to a main element, for example a data table or a dashboard.
14
+ See an example application of chips [here](https://github.com/dhis2/design-system/blob/master/atoms/chip.md#usage).
15
+
16
+ #### Chip vs. Button
17
+
18
+ Chips should only be used for filtering or selecting an option. Do not use filters to trigger actions such as 'Save', 'Exit' or 'Open'. Use a [button](../?path=/docs/actions-buttons-button--basic) to trigger actions.
13
19
 
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ #### Displaying chips
15
21
 
16
- const subtitle = "Chips are useful for displaying a selection of defined choices and filters to the user.";
17
- const description = "\nChips are used to display a list of defined options, filters or views for a related view. Chips are always a secondary content to a main element, for example a data table or a dashboard.\nSee an example application of chips [here](https://github.com/dhis2/design-system/blob/master/atoms/chip.md#usage).\n\n#### Chip vs. Button\n\nChips should only be used for filtering or selecting an option. Do not use filters to trigger actions such as 'Save', 'Exit' or 'Open'. Use a [button](../?path=/docs/actions-buttons-button--basic) to trigger actions.\n\n#### Displaying chips\n\n- Chips should be displayed in a horizontal list, where space permits.\n- Do not stack single chips on top of one another if there is space to display them inline.\n- Do not use horizontal scrolling to display a large number of chips. Always wrap chips onto a new line below.\n\n```js\nimport { Chip } from '@dhis2/ui'\n```\n";
22
+ - Chips should be displayed in a horizontal list, where space permits.
23
+ - Do not stack single chips on top of one another if there is space to display them inline.
24
+ - Do not use horizontal scrolling to display a large number of chips. Always wrap chips onto a new line below.
18
25
 
26
+ \`\`\`js
27
+ import { Chip } from '@dhis2/ui'
28
+ \`\`\`
29
+ `;
19
30
  window.onClick = (payload, event) => {
20
31
  console.log('onClick payload', payload);
21
32
  console.log('onClick event', event);
22
33
  };
23
-
24
34
  window.onRemove = (payload, event) => {
25
35
  console.log('onRemove payload', payload);
26
36
  console.log('onRemove event', event);
27
37
  };
28
-
29
38
  const onClick = function () {
30
39
  return window.onClick(...arguments);
31
40
  };
32
-
33
41
  const onRemove = function () {
34
42
  return window.onRemove(...arguments);
35
43
  };
36
-
37
- var _default = {
44
+ var _default = exports.default = {
38
45
  title: 'Chip',
39
46
  component: _chip.Chip,
40
47
  parameters: {
@@ -49,34 +56,27 @@ var _default = {
49
56
  onClick
50
57
  }
51
58
  };
52
- exports.default = _default;
53
-
54
59
  const Template = args => /*#__PURE__*/_react.default.createElement(_chip.Chip, args);
55
-
56
- const Default = Template.bind({});
57
- exports.Default = Default;
60
+ const Default = exports.Default = Template.bind({});
58
61
  Default.args = {
59
62
  children: 'Chippy'
60
63
  };
61
- const Selected = Template.bind({});
62
- exports.Selected = Selected;
64
+ const Selected = exports.Selected = Template.bind({});
63
65
  Selected.args = {
64
66
  selected: true,
65
67
  children: 'Chipmunk'
66
68
  };
67
- const Overflow = Template.bind({});
68
- exports.Overflow = Overflow;
69
+ const Overflow = exports.Overflow = Template.bind({});
69
70
  Overflow.args = {
70
71
  overflow: true,
71
72
  selected: true,
72
73
  children: 'A super long chip which should definitely truncate'
73
74
  };
74
- const Removable = Template.bind({});
75
- exports.Removable = Removable;
76
- Removable.args = { ...Default.args,
75
+ const Removable = exports.Removable = Template.bind({});
76
+ Removable.args = {
77
+ ...Default.args,
77
78
  onRemove
78
79
  };
79
-
80
80
  const Globe = () => /*#__PURE__*/_react.default.createElement("svg", {
81
81
  role: "img",
82
82
  viewBox: "0 0 24 24",
@@ -85,14 +85,11 @@ const Globe = () => /*#__PURE__*/_react.default.createElement("svg", {
85
85
  }, /*#__PURE__*/_react.default.createElement("title", null, "LGTM icon"), /*#__PURE__*/_react.default.createElement("path", {
86
86
  d: "M12.008 4.866c-2.914 0-5.377.679-6.995 2.11-.05-.088-.085-.163-.141-.253-.17-.273-.328-.583-.828-.89a2.699 2.699 0 0 0-1.014-.387 2.14 2.14 0 0 0-.47-.001l.099-.013c-.91 0-1.442.546-1.788 1.016-.344.47-.566.999-.71 1.577-.285 1.155-.289 2.651.81 3.767.575.588 1.251.863 1.863 1.027.118.032.223.04.336.063.399 1.892 1.58 3.492 3.158 4.381v.001h.002c.929.522 1.81.761 2.472 1.014.924.357 1.9.751 3.036.85l.06.006h.15c1.306 0 2.296-.527 3.152-.855.655-.25 1.54-.482 2.477-1.008a6.156 6.156 0 0 0 1.196-.88 6.759 6.759 0 0 0 1.967-3.45 3.913 3.913 0 0 0 2.19-1.15c1.098-1.115 1.094-2.611.809-3.766-.144-.578-.366-1.106-.71-1.577-.345-.47-.879-1.016-1.788-1.016l.1.013a2.14 2.14 0 0 0-.472.002 2.695 2.695 0 0 0-1.01.385c-.499.307-.658.616-.827.888-.055.089-.09.163-.139.249-1.617-1.426-4.076-2.103-6.985-2.103zm.023 1.37c3.557 0 6.013 1.065 7.057 2.97.63-.243 1.093-1.89 1.612-2.209.42-.26.665-.195.665-.195.95 0 1.93 2.797.712 4.032-.644.657-1.83.842-2.422.795-.045 1.906-1.155 3.626-2.624 4.45-.748.42-1.552.64-2.296.924-.921.352-1.786.763-2.662.763h-.092c-.872-.076-1.74-.407-2.662-.763-.744-.285-1.548-.51-2.296-.93-1.46-.824-2.571-2.54-2.616-4.445-.587.05-1.788-.132-2.436-.794-1.217-1.235-.238-4.032.712-4.032 0 0 .246-.064.666.195.521.321.987 1.984 1.62 2.214C6.013 7.3 8.47 6.236 12.032 6.236zm-3.876 2.33a3.053 3.053 0 1 0 0 6.105 3.053 3.053 0 0 0 0-6.105zm7.751 0a3.052 3.052 0 1 0 0 6.105 3.052 3.052 0 0 0 0-6.105zM8.591 10.28a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.313-1.694.57.57 0 0 0 1.098-.216.57.57 0 0 0-.547-.57 1.35 1.35 0 0 1 .762-.233zm6.888 0a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.314-1.694.57.57 0 1 0 .552-.785 1.35 1.35 0 0 1 .762-.234zM11.52 14.93c-.239.02-.377.146-.377.476 0 .21.138.365.378.365a.143.143 0 0 0 .033-.282c-.022-.005-.13-.044-.13-.136 0-.093 0-.125.183-.15.078-.012.116-.105.092-.18-.024-.075-.094-.1-.18-.093zm1.023 0c-.085-.006-.156.018-.18.093-.024.075.015.168.093.18.182.025.182.057.182.15 0 .092-.107.131-.13.136a.143.143 0 0 0 .033.282c.24 0 .379-.155.379-.365 0-.33-.139-.456-.377-.476z"
87
87
  }));
88
-
89
- const Icon = Template.bind({});
90
- exports.Icon = Icon;
88
+ const Icon = exports.Icon = Template.bind({});
91
89
  Icon.args = {
92
90
  icon: /*#__PURE__*/_react.default.createElement(Globe, null),
93
91
  children: 'With an icon'
94
92
  };
95
-
96
93
  const GlobeResizable = () => /*#__PURE__*/_react.default.createElement("svg", {
97
94
  role: "img",
98
95
  viewBox: "0 0 24 24",
@@ -103,9 +100,7 @@ const GlobeResizable = () => /*#__PURE__*/_react.default.createElement("svg", {
103
100
  }, /*#__PURE__*/_react.default.createElement("title", null, "LGTM icon"), /*#__PURE__*/_react.default.createElement("path", {
104
101
  d: "M12.008 4.866c-2.914 0-5.377.679-6.995 2.11-.05-.088-.085-.163-.141-.253-.17-.273-.328-.583-.828-.89a2.699 2.699 0 0 0-1.014-.387 2.14 2.14 0 0 0-.47-.001l.099-.013c-.91 0-1.442.546-1.788 1.016-.344.47-.566.999-.71 1.577-.285 1.155-.289 2.651.81 3.767.575.588 1.251.863 1.863 1.027.118.032.223.04.336.063.399 1.892 1.58 3.492 3.158 4.381v.001h.002c.929.522 1.81.761 2.472 1.014.924.357 1.9.751 3.036.85l.06.006h.15c1.306 0 2.296-.527 3.152-.855.655-.25 1.54-.482 2.477-1.008a6.156 6.156 0 0 0 1.196-.88 6.759 6.759 0 0 0 1.967-3.45 3.913 3.913 0 0 0 2.19-1.15c1.098-1.115 1.094-2.611.809-3.766-.144-.578-.366-1.106-.71-1.577-.345-.47-.879-1.016-1.788-1.016l.1.013a2.14 2.14 0 0 0-.472.002 2.695 2.695 0 0 0-1.01.385c-.499.307-.658.616-.827.888-.055.089-.09.163-.139.249-1.617-1.426-4.076-2.103-6.985-2.103zm.023 1.37c3.557 0 6.013 1.065 7.057 2.97.63-.243 1.093-1.89 1.612-2.209.42-.26.665-.195.665-.195.95 0 1.93 2.797.712 4.032-.644.657-1.83.842-2.422.795-.045 1.906-1.155 3.626-2.624 4.45-.748.42-1.552.64-2.296.924-.921.352-1.786.763-2.662.763h-.092c-.872-.076-1.74-.407-2.662-.763-.744-.285-1.548-.51-2.296-.93-1.46-.824-2.571-2.54-2.616-4.445-.587.05-1.788-.132-2.436-.794-1.217-1.235-.238-4.032.712-4.032 0 0 .246-.064.666.195.521.321.987 1.984 1.62 2.214C6.013 7.3 8.47 6.236 12.032 6.236zm-3.876 2.33a3.053 3.053 0 1 0 0 6.105 3.053 3.053 0 0 0 0-6.105zm7.751 0a3.052 3.052 0 1 0 0 6.105 3.052 3.052 0 0 0 0-6.105zM8.591 10.28a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.313-1.694.57.57 0 0 0 1.098-.216.57.57 0 0 0-.547-.57 1.35 1.35 0 0 1 .762-.233zm6.888 0a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.314-1.694.57.57 0 1 0 .552-.785 1.35 1.35 0 0 1 .762-.234zM11.52 14.93c-.239.02-.377.146-.377.476 0 .21.138.365.378.365a.143.143 0 0 0 .033-.282c-.022-.005-.13-.044-.13-.136 0-.093 0-.125.183-.15.078-.012.116-.105.092-.18-.024-.075-.094-.1-.18-.093zm1.023 0c-.085-.006-.156.018-.18.093-.024.075.015.168.093.18.182.025.182.057.182.15 0 .092-.107.131-.13.136a.143.143 0 0 0 .033.282c.24 0 .379-.155.379-.365 0-.33-.139-.456-.377-.476z"
105
102
  }));
106
-
107
- const IconContent = Template.bind({});
108
- exports.IconContent = IconContent;
103
+ const IconContent = exports.IconContent = Template.bind({});
109
104
  IconContent.args = {
110
105
  children: /*#__PURE__*/_react.default.createElement("span", {
111
106
  className: "jsx-4024600781" + " " + "container"
@@ -119,27 +114,24 @@ IconContent.args = {
119
114
  id: "4024600781"
120
115
  }, [".container.jsx-4024600781{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-content:center;-ms-flex-line-pack:center;align-content:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".text.jsx-4024600781{margin-right:4px;}", ".icon.jsx-4024600781{display:inline-block;height:16px;}"]))
121
116
  };
122
-
123
117
  const Dense = () => /*#__PURE__*/_react.default.createElement(_chip.Chip, {
124
118
  dense: true
125
119
  }, "I am dense");
126
-
127
120
  exports.Dense = Dense;
128
121
  Dense.args = {
129
122
  dense: true,
130
123
  children: 'I am dense'
131
124
  };
132
- const DenseRemoveable = Template.bind({});
133
- exports.DenseRemoveable = DenseRemoveable;
134
- DenseRemoveable.args = { ...Dense.args,
125
+ const DenseRemoveable = exports.DenseRemoveable = Template.bind({});
126
+ DenseRemoveable.args = {
127
+ ...Dense.args,
135
128
  ...Removable.args,
136
129
  children: 'Removable and dense'
137
130
  };
138
-
139
131
  const RTLRemovable = args => /*#__PURE__*/_react.default.createElement("div", {
140
132
  dir: "rtl"
141
133
  }, /*#__PURE__*/_react.default.createElement(_chip.Chip, args, "RTL removable"));
142
-
143
134
  exports.RTLRemovable = RTLRemovable;
144
- RTLRemovable.args = { ...Removable.args
135
+ RTLRemovable.args = {
136
+ ...Removable.args
145
137
  };
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Content = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
8
  var _uiConstants = require("@dhis2/ui-constants");
11
-
12
9
  var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
11
  var _react = _interopRequireDefault(require("react"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
13
  const Content = _ref => {
21
14
  let {
22
15
  children,
@@ -29,9 +22,8 @@ const Content = _ref => {
29
22
  }, children, /*#__PURE__*/_react.default.createElement(_style.default, {
30
23
  id: "765109298",
31
24
  dynamic: [_uiConstants.spacers.dp12]
32
- }, ["span.__jsx-style-dynamic-selector{margin:0 ".concat(_uiConstants.spacers.dp12, ";color:inherit;white-space:nowrap;}"), ".overflow.__jsx-style-dynamic-selector{max-width:150px;overflow:hidden;text-overflow:ellipsis;}"]));
25
+ }, [`span.__jsx-style-dynamic-selector{margin:0 ${_uiConstants.spacers.dp12};color:inherit;white-space:nowrap;}`, ".overflow.__jsx-style-dynamic-selector{max-width:150px;overflow:hidden;text-overflow:ellipsis;}"]));
33
26
  };
34
-
35
27
  exports.Content = Content;
36
28
  Content.propTypes = {
37
29
  children: _propTypes.default.any,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Chip with children is rendered', () => {
6
5
  cy.visitStory('Chip', 'With children');
7
6
  cy.get('[data-test="dhis2-uicore-chip"]').should('be.visible');
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a default Chip is rendered', () => {
6
5
  cy.visitStory('Chip', 'Default');
7
6
  cy.get('[data-test="dhis2-uicore-chip"]').should('be.visible');
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Chip with onClick handler is rendered', () => {
6
- cy.visitStory('Chip', 'With onClick');
5
+ cy.visitStory('Chip', 'With on click');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the Chip is clicked', () => {
9
8
  cy.get('[data-test="dhis2-uicore-chip"]').click();
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
4
-
5
4
  (0, _cypressCucumberPreprocessor.Given)('a Chip with onRemove handler is rendered', () => {
6
- cy.visitStory('Chip', 'With onRemove');
5
+ cy.visitStory('Chip', 'With on remove');
7
6
  });
8
7
  (0, _cypressCucumberPreprocessor.When)('the remove icon is clicked', () => {
9
8
  cy.get('[data-test="dhis2-uicore-chip-remove"]').click();
package/build/cjs/icon.js CHANGED
@@ -4,40 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Icon = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
8
  var _uiConstants = require("@dhis2/ui-constants");
11
-
12
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
10
  var _react = _interopRequireDefault(require("react"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
12
  const Icon = _ref => {
19
13
  let {
20
14
  icon,
21
15
  dataTest
22
16
  } = _ref;
23
-
24
17
  if (!icon) {
25
18
  return null;
26
19
  }
27
-
28
20
  return /*#__PURE__*/_react.default.createElement("span", {
29
21
  "data-test": dataTest,
30
22
  className: _style.default.dynamic([["1889825154", [_uiConstants.spacers.dp4]]])
31
23
  }, icon, /*#__PURE__*/_react.default.createElement(_style.default, {
32
24
  id: "1889825154",
33
25
  dynamic: [_uiConstants.spacers.dp4]
34
- }, ["span.__jsx-style-dynamic-selector{width:24px;height:24px;margin-inline-start:".concat(_uiConstants.spacers.dp4, ";margin-inline-end:-6px;border-radius:50%;overflow:hidden;}"), "span.__jsx-style-dynamic-selector>*{max-height:24px;max-width:24px;}"]));
26
+ }, [`span.__jsx-style-dynamic-selector{width:24px;height:24px;margin-inline-start:${_uiConstants.spacers.dp4};margin-inline-end:-6px;border-radius:50%;overflow:hidden;}`, "span.__jsx-style-dynamic-selector>*{max-height:24px;max-width:24px;}"]));
35
27
  };
36
-
37
28
  exports.Icon = Icon;
38
29
  Icon.propTypes = {
39
30
  dataTest: _propTypes.default.string.isRequired,
40
-
41
31
  /** the slot for an icon is 24x24px, bigger elements will be clipped */
42
32
  icon: _propTypes.default.element
43
33
  };
@@ -9,5 +9,4 @@ Object.defineProperty(exports, "Chip", {
9
9
  return _chip.Chip;
10
10
  }
11
11
  });
12
-
13
12
  var _chip = require("./chip.js");
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Remove = void 0;
7
-
8
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
-
10
8
  var _uiConstants = require("@dhis2/ui-constants");
11
-
12
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
10
  var _react = _interopRequireDefault(require("react"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
12
  function CancelOutline(_ref) {
19
13
  let {
20
14
  className
@@ -30,44 +24,38 @@ function CancelOutline(_ref) {
30
24
  id: "2898942518"
31
25
  }, ["svg.jsx-2898942518{fill:inherit;height:16px;width:16px;vertical-align:middle;pointer-events:none;}"]));
32
26
  }
33
-
34
27
  CancelOutline.propTypes = {
35
28
  className: _propTypes.default.string
36
29
  };
37
- const containerStyle = ["span.jsx-2824632002{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:20px;width:20px;margin-inline-end:4px;border-radius:12px;margin-inline-start:-8px;}", "span.jsx-2824632002:hover{background:".concat(_uiConstants.colors.grey400, ";}")];
30
+ const containerStyle = ["span.jsx-2824632002{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:20px;width:20px;margin-inline-end:4px;border-radius:12px;margin-inline-start:-8px;}", `span.jsx-2824632002:hover{background:${_uiConstants.colors.grey400};}`];
38
31
  containerStyle.__hash = "2824632002";
39
32
  const removeIcon = {
40
33
  styles: /*#__PURE__*/_react.default.createElement(_style.default, {
41
34
  id: "2658726446"
42
- }, ["svg.jsx-2658726446{fill:".concat(_uiConstants.colors.grey600, ";height:16px;width:16px;cursor:pointer;opacity:1;pointer-events:all;}")]),
35
+ }, [`svg.jsx-2658726446{fill:${_uiConstants.colors.grey600};height:16px;width:16px;cursor:pointer;opacity:1;pointer-events:all;}`]),
43
36
  className: "jsx-2658726446"
44
37
  };
45
-
46
38
  const Remove = _ref2 => {
47
39
  let {
48
40
  onRemove,
49
41
  dataTest
50
42
  } = _ref2;
51
-
52
43
  if (!onRemove) {
53
44
  return null;
54
45
  }
55
-
56
46
  return /*#__PURE__*/_react.default.createElement("span", {
57
47
  onClick: e => {
58
48
  e.stopPropagation(); // stop onRemove from triggering onClick on container
59
-
60
49
  onRemove({}, e);
61
50
  },
62
51
  "data-test": dataTest,
63
- className: "jsx-".concat(containerStyle.__hash)
52
+ className: `jsx-${containerStyle.__hash}`
64
53
  }, /*#__PURE__*/_react.default.createElement(CancelOutline, {
65
54
  className: removeIcon.className
66
55
  }), removeIcon.styles, /*#__PURE__*/_react.default.createElement(_style.default, {
67
56
  id: containerStyle.__hash
68
57
  }, containerStyle));
69
58
  };
70
-
71
59
  exports.Remove = Remove;
72
60
  Remove.propTypes = {
73
61
  dataTest: _propTypes.default.string.isRequired,
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { Chip } from './chip.js';
3
+ window.onClick = window.Cypress && window.Cypress.cy.stub();
4
+ window.onRemove = window.Cypress && window.Cypress.cy.stub();
5
+ export default {
6
+ title: 'Chip'
7
+ };
8
+ export const Default = () => /*#__PURE__*/React.createElement(Chip, null, "Message");
9
+ export const WithOnClick = () => /*#__PURE__*/React.createElement(Chip, {
10
+ onClick: window.onClick
11
+ }, "Chippy");
12
+ export const WithOnRemove = () => /*#__PURE__*/React.createElement(Chip, {
13
+ onRemove: window.onRemove
14
+ }, "Chipmunk");
15
+ export const WithChildren = () => /*#__PURE__*/React.createElement(Chip, null, "I am a child");
16
+ export const WithIcon = () => /*#__PURE__*/React.createElement(Chip, {
17
+ icon: /*#__PURE__*/React.createElement("div", null, "Icon")
18
+ }, "Message");
package/build/es/chip.js CHANGED
@@ -7,10 +7,8 @@ import { Content } from './content.js';
7
7
  import { Icon } from './icon.js';
8
8
  import { Remove } from './remove.js';
9
9
  const DEFAULT_INLINE_MARGIN = '4';
10
-
11
10
  const Chip = _ref => {
12
11
  var _ref2, _ref3, _ref4, _ref5;
13
-
14
12
  let {
15
13
  selected,
16
14
  dense,
@@ -37,7 +35,7 @@ const Chip = _ref => {
37
35
  }
38
36
  },
39
37
  "data-test": dataTest,
40
- className: _JSXStyle.dynamic([["3780556490", [colors.grey200, colors.grey900, colors.grey300, theme.secondary600, colors.white]], ["1687525377", [marginBottom && "margin-bottom: ".concat(marginBottom, "px;"), (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && "margin-top: ".concat(marginTop, "px")]]]) + " " + (cx(className, {
38
+ className: _JSXStyle.dynamic([["3780556490", [colors.grey200, colors.grey900, colors.grey300, theme.secondary600, colors.white]], ["1687525377", [marginBottom && `margin-bottom: ${marginBottom}px;`, (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && `margin-top: ${marginTop}px`]]]) + " " + (cx(className, {
41
39
  selected,
42
40
  dense,
43
41
  disabled,
@@ -45,21 +43,20 @@ const Chip = _ref => {
45
43
  }) || "")
46
44
  }, /*#__PURE__*/React.createElement(Icon, {
47
45
  icon: icon,
48
- dataTest: "".concat(dataTest, "-icon")
46
+ dataTest: `${dataTest}-icon`
49
47
  }), /*#__PURE__*/React.createElement(Content, {
50
48
  overflow: overflow
51
49
  }, children), /*#__PURE__*/React.createElement(Remove, {
52
50
  onRemove: onRemove,
53
- dataTest: "".concat(dataTest, "-remove")
51
+ dataTest: `${dataTest}-remove`
54
52
  }), /*#__PURE__*/React.createElement(_JSXStyle, {
55
53
  id: "3780556490",
56
54
  dynamic: [colors.grey200, colors.grey900, colors.grey300, theme.secondary600, colors.white]
57
- }, ["span.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:32px;border-radius:16px;background-color:".concat(colors.grey200, ";font-size:14px;line-height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:").concat(colors.grey900, ";}"), ".dense.__jsx-style-dynamic-selector{height:24px;font-size:13px;line-height:15px;}", "span.__jsx-style-dynamic-selector:hover{background-color:".concat(colors.grey300, ";}"), ".selected.__jsx-style-dynamic-selector{background-color:".concat(theme.secondary600, ";font-weight:500;}"), ".selected.__jsx-style-dynamic-selector:hover{background-color:#00695c;}", ".selected.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{color:".concat(colors.white, ";}"), ".disabled.__jsx-style-dynamic-selector{cursor:not-allowed;opacity:0.3;}", ".disabled.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{pointer-events:none;}", ".dragging.__jsx-style-dynamic-selector{box-shadow:0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);}"]), /*#__PURE__*/React.createElement(_JSXStyle, {
55
+ }, [`span.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:32px;border-radius:16px;background-color:${colors.grey200};font-size:14px;line-height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:${colors.grey900};}`, ".dense.__jsx-style-dynamic-selector{height:24px;font-size:13px;line-height:15px;}", `span.__jsx-style-dynamic-selector:hover{background-color:${colors.grey300};}`, `.selected.__jsx-style-dynamic-selector{background-color:${theme.secondary600};font-weight:500;}`, ".selected.__jsx-style-dynamic-selector:hover{background-color:#00695c;}", `.selected.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector,.selected.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{color:${colors.white};}`, ".disabled.__jsx-style-dynamic-selector{cursor:not-allowed;opacity:0.3;}", ".disabled.__jsx-style-dynamic-selector .remove-icon.__jsx-style-dynamic-selector{pointer-events:none;}", ".dragging.__jsx-style-dynamic-selector{box-shadow:0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);}"]), /*#__PURE__*/React.createElement(_JSXStyle, {
58
56
  id: "1687525377",
59
- dynamic: [marginBottom && "margin-bottom: ".concat(marginBottom, "px;"), (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && "margin-top: ".concat(marginTop, "px")]
60
- }, ["span.__jsx-style-dynamic-selector{".concat(marginBottom && "margin-bottom: ".concat(marginBottom, "px;"), " margin-inline-start:").concat((_ref4 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_INLINE_MARGIN, "px;margin-inline-end:").concat((_ref5 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_INLINE_MARGIN, "px;").concat(marginTop && "margin-top: ".concat(marginTop, "px"), ";}")]));
57
+ dynamic: [marginBottom && `margin-bottom: ${marginBottom}px;`, (_ref2 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_INLINE_MARGIN, (_ref3 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref3 !== void 0 ? _ref3 : DEFAULT_INLINE_MARGIN, marginTop && `margin-top: ${marginTop}px`]
58
+ }, [`span.__jsx-style-dynamic-selector{${marginBottom && `margin-bottom: ${marginBottom}px;`} margin-inline-start:${(_ref4 = marginInlineStart !== null && marginInlineStart !== void 0 ? marginInlineStart : marginLeft) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_INLINE_MARGIN}px;margin-inline-end:${(_ref5 = marginInlineEnd !== null && marginInlineEnd !== void 0 ? marginInlineEnd : marginRight) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_INLINE_MARGIN}px;${marginTop && `margin-top: ${marginTop}px`};}`]));
61
59
  };
62
-
63
60
  Chip.defaultProps = {
64
61
  dataTest: 'dhis2-uicore-chip',
65
62
  marginBottom: 4,
@@ -73,22 +70,16 @@ Chip.propTypes = {
73
70
  disabled: PropTypes.bool,
74
71
  dragging: PropTypes.bool,
75
72
  icon: PropTypes.element,
76
-
77
73
  /** `margin-bottom` value, applied in `px` */
78
74
  marginBottom: PropTypes.number,
79
-
80
75
  /** `margin-inline-end` value, applied in `px` */
81
76
  marginInlineEnd: PropTypes.number,
82
-
83
77
  /** `margin-inline-start` value, applied in `px` */
84
78
  marginInlineStart: PropTypes.number,
85
-
86
79
  /** `margin-inline-start` value, applied in `px` */
87
80
  marginLeft: PropTypes.number,
88
-
89
81
  /** `margin-inline-end` value, applied in `px` */
90
82
  marginRight: PropTypes.number,
91
-
92
83
  /** `margin-top` value, applied in `px` */
93
84
  marginTop: PropTypes.number,
94
85
  overflow: PropTypes.bool,
@@ -1,27 +1,39 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
2
  import React from 'react';
3
3
  import { Chip } from './chip.js';
4
- const subtitle = "Chips are useful for displaying a selection of defined choices and filters to the user.";
5
- const description = "\nChips are used to display a list of defined options, filters or views for a related view. Chips are always a secondary content to a main element, for example a data table or a dashboard.\nSee an example application of chips [here](https://github.com/dhis2/design-system/blob/master/atoms/chip.md#usage).\n\n#### Chip vs. Button\n\nChips should only be used for filtering or selecting an option. Do not use filters to trigger actions such as 'Save', 'Exit' or 'Open'. Use a [button](../?path=/docs/actions-buttons-button--basic) to trigger actions.\n\n#### Displaying chips\n\n- Chips should be displayed in a horizontal list, where space permits.\n- Do not stack single chips on top of one another if there is space to display them inline.\n- Do not use horizontal scrolling to display a large number of chips. Always wrap chips onto a new line below.\n\n```js\nimport { Chip } from '@dhis2/ui'\n```\n";
4
+ const subtitle = `Chips are useful for displaying a selection of defined choices and filters to the user.`;
5
+ const description = `
6
+ Chips are used to display a list of defined options, filters or views for a related view. Chips are always a secondary content to a main element, for example a data table or a dashboard.
7
+ See an example application of chips [here](https://github.com/dhis2/design-system/blob/master/atoms/chip.md#usage).
6
8
 
9
+ #### Chip vs. Button
10
+
11
+ Chips should only be used for filtering or selecting an option. Do not use filters to trigger actions such as 'Save', 'Exit' or 'Open'. Use a [button](../?path=/docs/actions-buttons-button--basic) to trigger actions.
12
+
13
+ #### Displaying chips
14
+
15
+ - Chips should be displayed in a horizontal list, where space permits.
16
+ - Do not stack single chips on top of one another if there is space to display them inline.
17
+ - Do not use horizontal scrolling to display a large number of chips. Always wrap chips onto a new line below.
18
+
19
+ \`\`\`js
20
+ import { Chip } from '@dhis2/ui'
21
+ \`\`\`
22
+ `;
7
23
  window.onClick = (payload, event) => {
8
24
  console.log('onClick payload', payload);
9
25
  console.log('onClick event', event);
10
26
  };
11
-
12
27
  window.onRemove = (payload, event) => {
13
28
  console.log('onRemove payload', payload);
14
29
  console.log('onRemove event', event);
15
30
  };
16
-
17
31
  const onClick = function () {
18
32
  return window.onClick(...arguments);
19
33
  };
20
-
21
34
  const onRemove = function () {
22
35
  return window.onRemove(...arguments);
23
36
  };
24
-
25
37
  export default {
26
38
  title: 'Chip',
27
39
  component: Chip,
@@ -37,9 +49,7 @@ export default {
37
49
  onClick
38
50
  }
39
51
  };
40
-
41
52
  const Template = args => /*#__PURE__*/React.createElement(Chip, args);
42
-
43
53
  export const Default = Template.bind({});
44
54
  Default.args = {
45
55
  children: 'Chippy'
@@ -56,10 +66,10 @@ Overflow.args = {
56
66
  children: 'A super long chip which should definitely truncate'
57
67
  };
58
68
  export const Removable = Template.bind({});
59
- Removable.args = { ...Default.args,
69
+ Removable.args = {
70
+ ...Default.args,
60
71
  onRemove
61
72
  };
62
-
63
73
  const Globe = () => /*#__PURE__*/React.createElement("svg", {
64
74
  role: "img",
65
75
  viewBox: "0 0 24 24",
@@ -68,13 +78,11 @@ const Globe = () => /*#__PURE__*/React.createElement("svg", {
68
78
  }, /*#__PURE__*/React.createElement("title", null, "LGTM icon"), /*#__PURE__*/React.createElement("path", {
69
79
  d: "M12.008 4.866c-2.914 0-5.377.679-6.995 2.11-.05-.088-.085-.163-.141-.253-.17-.273-.328-.583-.828-.89a2.699 2.699 0 0 0-1.014-.387 2.14 2.14 0 0 0-.47-.001l.099-.013c-.91 0-1.442.546-1.788 1.016-.344.47-.566.999-.71 1.577-.285 1.155-.289 2.651.81 3.767.575.588 1.251.863 1.863 1.027.118.032.223.04.336.063.399 1.892 1.58 3.492 3.158 4.381v.001h.002c.929.522 1.81.761 2.472 1.014.924.357 1.9.751 3.036.85l.06.006h.15c1.306 0 2.296-.527 3.152-.855.655-.25 1.54-.482 2.477-1.008a6.156 6.156 0 0 0 1.196-.88 6.759 6.759 0 0 0 1.967-3.45 3.913 3.913 0 0 0 2.19-1.15c1.098-1.115 1.094-2.611.809-3.766-.144-.578-.366-1.106-.71-1.577-.345-.47-.879-1.016-1.788-1.016l.1.013a2.14 2.14 0 0 0-.472.002 2.695 2.695 0 0 0-1.01.385c-.499.307-.658.616-.827.888-.055.089-.09.163-.139.249-1.617-1.426-4.076-2.103-6.985-2.103zm.023 1.37c3.557 0 6.013 1.065 7.057 2.97.63-.243 1.093-1.89 1.612-2.209.42-.26.665-.195.665-.195.95 0 1.93 2.797.712 4.032-.644.657-1.83.842-2.422.795-.045 1.906-1.155 3.626-2.624 4.45-.748.42-1.552.64-2.296.924-.921.352-1.786.763-2.662.763h-.092c-.872-.076-1.74-.407-2.662-.763-.744-.285-1.548-.51-2.296-.93-1.46-.824-2.571-2.54-2.616-4.445-.587.05-1.788-.132-2.436-.794-1.217-1.235-.238-4.032.712-4.032 0 0 .246-.064.666.195.521.321.987 1.984 1.62 2.214C6.013 7.3 8.47 6.236 12.032 6.236zm-3.876 2.33a3.053 3.053 0 1 0 0 6.105 3.053 3.053 0 0 0 0-6.105zm7.751 0a3.052 3.052 0 1 0 0 6.105 3.052 3.052 0 0 0 0-6.105zM8.591 10.28a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.313-1.694.57.57 0 0 0 1.098-.216.57.57 0 0 0-.547-.57 1.35 1.35 0 0 1 .762-.233zm6.888 0a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.314-1.694.57.57 0 1 0 .552-.785 1.35 1.35 0 0 1 .762-.234zM11.52 14.93c-.239.02-.377.146-.377.476 0 .21.138.365.378.365a.143.143 0 0 0 .033-.282c-.022-.005-.13-.044-.13-.136 0-.093 0-.125.183-.15.078-.012.116-.105.092-.18-.024-.075-.094-.1-.18-.093zm1.023 0c-.085-.006-.156.018-.18.093-.024.075.015.168.093.18.182.025.182.057.182.15 0 .092-.107.131-.13.136a.143.143 0 0 0 .033.282c.24 0 .379-.155.379-.365 0-.33-.139-.456-.377-.476z"
70
80
  }));
71
-
72
81
  export const Icon = Template.bind({});
73
82
  Icon.args = {
74
83
  icon: /*#__PURE__*/React.createElement(Globe, null),
75
84
  children: 'With an icon'
76
85
  };
77
-
78
86
  const GlobeResizable = () => /*#__PURE__*/React.createElement("svg", {
79
87
  role: "img",
80
88
  viewBox: "0 0 24 24",
@@ -85,7 +93,6 @@ const GlobeResizable = () => /*#__PURE__*/React.createElement("svg", {
85
93
  }, /*#__PURE__*/React.createElement("title", null, "LGTM icon"), /*#__PURE__*/React.createElement("path", {
86
94
  d: "M12.008 4.866c-2.914 0-5.377.679-6.995 2.11-.05-.088-.085-.163-.141-.253-.17-.273-.328-.583-.828-.89a2.699 2.699 0 0 0-1.014-.387 2.14 2.14 0 0 0-.47-.001l.099-.013c-.91 0-1.442.546-1.788 1.016-.344.47-.566.999-.71 1.577-.285 1.155-.289 2.651.81 3.767.575.588 1.251.863 1.863 1.027.118.032.223.04.336.063.399 1.892 1.58 3.492 3.158 4.381v.001h.002c.929.522 1.81.761 2.472 1.014.924.357 1.9.751 3.036.85l.06.006h.15c1.306 0 2.296-.527 3.152-.855.655-.25 1.54-.482 2.477-1.008a6.156 6.156 0 0 0 1.196-.88 6.759 6.759 0 0 0 1.967-3.45 3.913 3.913 0 0 0 2.19-1.15c1.098-1.115 1.094-2.611.809-3.766-.144-.578-.366-1.106-.71-1.577-.345-.47-.879-1.016-1.788-1.016l.1.013a2.14 2.14 0 0 0-.472.002 2.695 2.695 0 0 0-1.01.385c-.499.307-.658.616-.827.888-.055.089-.09.163-.139.249-1.617-1.426-4.076-2.103-6.985-2.103zm.023 1.37c3.557 0 6.013 1.065 7.057 2.97.63-.243 1.093-1.89 1.612-2.209.42-.26.665-.195.665-.195.95 0 1.93 2.797.712 4.032-.644.657-1.83.842-2.422.795-.045 1.906-1.155 3.626-2.624 4.45-.748.42-1.552.64-2.296.924-.921.352-1.786.763-2.662.763h-.092c-.872-.076-1.74-.407-2.662-.763-.744-.285-1.548-.51-2.296-.93-1.46-.824-2.571-2.54-2.616-4.445-.587.05-1.788-.132-2.436-.794-1.217-1.235-.238-4.032.712-4.032 0 0 .246-.064.666.195.521.321.987 1.984 1.62 2.214C6.013 7.3 8.47 6.236 12.032 6.236zm-3.876 2.33a3.053 3.053 0 1 0 0 6.105 3.053 3.053 0 0 0 0-6.105zm7.751 0a3.052 3.052 0 1 0 0 6.105 3.052 3.052 0 0 0 0-6.105zM8.591 10.28a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.313-1.694.57.57 0 0 0 1.098-.216.57.57 0 0 0-.547-.57 1.35 1.35 0 0 1 .762-.233zm6.888 0a1.357 1.357 0 0 1 0 2.713 1.356 1.356 0 0 1-1.314-1.694.57.57 0 1 0 .552-.785 1.35 1.35 0 0 1 .762-.234zM11.52 14.93c-.239.02-.377.146-.377.476 0 .21.138.365.378.365a.143.143 0 0 0 .033-.282c-.022-.005-.13-.044-.13-.136 0-.093 0-.125.183-.15.078-.012.116-.105.092-.18-.024-.075-.094-.1-.18-.093zm1.023 0c-.085-.006-.156.018-.18.093-.024.075.015.168.093.18.182.025.182.057.182.15 0 .092-.107.131-.13.136a.143.143 0 0 0 .033.282c.24 0 .379-.155.379-.365 0-.33-.139-.456-.377-.476z"
87
95
  }));
88
-
89
96
  export const IconContent = Template.bind({});
90
97
  IconContent.args = {
91
98
  children: /*#__PURE__*/React.createElement("span", {
@@ -108,12 +115,14 @@ Dense.args = {
108
115
  children: 'I am dense'
109
116
  };
110
117
  export const DenseRemoveable = Template.bind({});
111
- DenseRemoveable.args = { ...Dense.args,
118
+ DenseRemoveable.args = {
119
+ ...Dense.args,
112
120
  ...Removable.args,
113
121
  children: 'Removable and dense'
114
122
  };
115
123
  export const RTLRemovable = args => /*#__PURE__*/React.createElement("div", {
116
124
  dir: "rtl"
117
125
  }, /*#__PURE__*/React.createElement(Chip, args, "RTL removable"));
118
- RTLRemovable.args = { ...Removable.args
126
+ RTLRemovable.args = {
127
+ ...Removable.args
119
128
  };
@@ -15,7 +15,7 @@ export const Content = _ref => {
15
15
  }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
16
16
  id: "765109298",
17
17
  dynamic: [spacers.dp12]
18
- }, ["span.__jsx-style-dynamic-selector{margin:0 ".concat(spacers.dp12, ";color:inherit;white-space:nowrap;}"), ".overflow.__jsx-style-dynamic-selector{max-width:150px;overflow:hidden;text-overflow:ellipsis;}"]));
18
+ }, [`span.__jsx-style-dynamic-selector{margin:0 ${spacers.dp12};color:inherit;white-space:nowrap;}`, ".overflow.__jsx-style-dynamic-selector{max-width:150px;overflow:hidden;text-overflow:ellipsis;}"]));
19
19
  };
20
20
  Content.propTypes = {
21
21
  children: PropTypes.any,
@@ -1,6 +1,6 @@
1
1
  import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
2
2
  Given('a Chip with onClick handler is rendered', () => {
3
- cy.visitStory('Chip', 'With onClick');
3
+ cy.visitStory('Chip', 'With on click');
4
4
  });
5
5
  When('the Chip is clicked', () => {
6
6
  cy.get('[data-test="dhis2-uicore-chip"]').click();
@@ -1,6 +1,6 @@
1
1
  import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
2
2
  Given('a Chip with onRemove handler is rendered', () => {
3
- cy.visitStory('Chip', 'With onRemove');
3
+ cy.visitStory('Chip', 'With on remove');
4
4
  });
5
5
  When('the remove icon is clicked', () => {
6
6
  cy.get('[data-test="dhis2-uicore-chip-remove"]').click();
package/build/es/icon.js CHANGED
@@ -7,22 +7,19 @@ export const Icon = _ref => {
7
7
  icon,
8
8
  dataTest
9
9
  } = _ref;
10
-
11
10
  if (!icon) {
12
11
  return null;
13
12
  }
14
-
15
13
  return /*#__PURE__*/React.createElement("span", {
16
14
  "data-test": dataTest,
17
15
  className: _JSXStyle.dynamic([["1889825154", [spacers.dp4]]])
18
16
  }, icon, /*#__PURE__*/React.createElement(_JSXStyle, {
19
17
  id: "1889825154",
20
18
  dynamic: [spacers.dp4]
21
- }, ["span.__jsx-style-dynamic-selector{width:24px;height:24px;margin-inline-start:".concat(spacers.dp4, ";margin-inline-end:-6px;border-radius:50%;overflow:hidden;}"), "span.__jsx-style-dynamic-selector>*{max-height:24px;max-width:24px;}"]));
19
+ }, [`span.__jsx-style-dynamic-selector{width:24px;height:24px;margin-inline-start:${spacers.dp4};margin-inline-end:-6px;border-radius:50%;overflow:hidden;}`, "span.__jsx-style-dynamic-selector>*{max-height:24px;max-width:24px;}"]));
22
20
  };
23
21
  Icon.propTypes = {
24
22
  dataTest: PropTypes.string.isRequired,
25
-
26
23
  /** the slot for an icon is 24x24px, bigger elements will be clipped */
27
24
  icon: PropTypes.element
28
25
  };
@@ -2,7 +2,6 @@ import _JSXStyle from "styled-jsx/style";
2
2
  import { colors } from '@dhis2/ui-constants';
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
-
6
5
  function CancelOutline(_ref) {
7
6
  let {
8
7
  className
@@ -18,16 +17,15 @@ function CancelOutline(_ref) {
18
17
  id: "2898942518"
19
18
  }, ["svg.jsx-2898942518{fill:inherit;height:16px;width:16px;vertical-align:middle;pointer-events:none;}"]));
20
19
  }
21
-
22
20
  CancelOutline.propTypes = {
23
21
  className: PropTypes.string
24
22
  };
25
- const containerStyle = ["span.jsx-2824632002{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:20px;width:20px;margin-inline-end:4px;border-radius:12px;margin-inline-start:-8px;}", "span.jsx-2824632002:hover{background:".concat(colors.grey400, ";}")];
23
+ const containerStyle = ["span.jsx-2824632002{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:20px;width:20px;margin-inline-end:4px;border-radius:12px;margin-inline-start:-8px;}", `span.jsx-2824632002:hover{background:${colors.grey400};}`];
26
24
  containerStyle.__hash = "2824632002";
27
25
  const removeIcon = {
28
26
  styles: /*#__PURE__*/React.createElement(_JSXStyle, {
29
27
  id: "2658726446"
30
- }, ["svg.jsx-2658726446{fill:".concat(colors.grey600, ";height:16px;width:16px;cursor:pointer;opacity:1;pointer-events:all;}")]),
28
+ }, [`svg.jsx-2658726446{fill:${colors.grey600};height:16px;width:16px;cursor:pointer;opacity:1;pointer-events:all;}`]),
31
29
  className: "jsx-2658726446"
32
30
  };
33
31
  export const Remove = _ref2 => {
@@ -35,19 +33,16 @@ export const Remove = _ref2 => {
35
33
  onRemove,
36
34
  dataTest
37
35
  } = _ref2;
38
-
39
36
  if (!onRemove) {
40
37
  return null;
41
38
  }
42
-
43
39
  return /*#__PURE__*/React.createElement("span", {
44
40
  onClick: e => {
45
41
  e.stopPropagation(); // stop onRemove from triggering onClick on container
46
-
47
42
  onRemove({}, e);
48
43
  },
49
44
  "data-test": dataTest,
50
- className: "jsx-".concat(containerStyle.__hash)
45
+ className: `jsx-${containerStyle.__hash}`
51
46
  }, /*#__PURE__*/React.createElement(CancelOutline, {
52
47
  className: removeIcon.className
53
48
  }), removeIcon.styles, /*#__PURE__*/React.createElement(_JSXStyle, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/chip",
3
- "version": "9.11.0",
3
+ "version": "9.11.1-beta.1",
4
4
  "description": "UI Chip",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,18 +22,18 @@
22
22
  "access": "public"
23
23
  },
24
24
  "scripts": {
25
- "start": "start-storybook -c ../../storybook/config --port 5000",
25
+ "start": "storybook dev -c ../../storybook/config --port 5000",
26
26
  "build": "d2-app-scripts build",
27
27
  "test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^16.8",
31
- "react-dom": "^16.8",
30
+ "react": "^16.13",
31
+ "react-dom": "^16.13",
32
32
  "styled-jsx": "^4"
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2/ui-constants": "9.11.0",
36
+ "@dhis2/ui-constants": "9.11.1-beta.1",
37
37
  "classnames": "^2.3.1",
38
38
  "prop-types": "^15.7.2"
39
39
  },
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@storybook/react");
4
-
5
- var _react2 = _interopRequireDefault(require("react"));
6
-
7
- var _chip = require("./chip.js");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- window.onClick = window.Cypress && window.Cypress.cy.stub();
12
- window.onRemove = window.Cypress && window.Cypress.cy.stub();
13
- (0, _react.storiesOf)('Chip', module).add('Default', () => /*#__PURE__*/_react2.default.createElement(_chip.Chip, null, "Message")).add('With onClick', () => /*#__PURE__*/_react2.default.createElement(_chip.Chip, {
14
- onClick: window.onClick
15
- }, "Chippy")).add('With onRemove', () => /*#__PURE__*/_react2.default.createElement(_chip.Chip, {
16
- onRemove: window.onRemove
17
- }, "Chipmunk")).add('With children', () => /*#__PURE__*/_react2.default.createElement(_chip.Chip, null, "I am a child")).add('With icon', () => /*#__PURE__*/_react2.default.createElement(_chip.Chip, {
18
- icon: /*#__PURE__*/_react2.default.createElement("div", null, "Icon")
19
- }, "Message"));
@@ -1,12 +0,0 @@
1
- import { storiesOf } from '@storybook/react';
2
- import React from 'react';
3
- import { Chip } from './chip.js';
4
- window.onClick = window.Cypress && window.Cypress.cy.stub();
5
- window.onRemove = window.Cypress && window.Cypress.cy.stub();
6
- storiesOf('Chip', module).add('Default', () => /*#__PURE__*/React.createElement(Chip, null, "Message")).add('With onClick', () => /*#__PURE__*/React.createElement(Chip, {
7
- onClick: window.onClick
8
- }, "Chippy")).add('With onRemove', () => /*#__PURE__*/React.createElement(Chip, {
9
- onRemove: window.onRemove
10
- }, "Chipmunk")).add('With children', () => /*#__PURE__*/React.createElement(Chip, null, "I am a child")).add('With icon', () => /*#__PURE__*/React.createElement(Chip, {
11
- icon: /*#__PURE__*/React.createElement("div", null, "Icon")
12
- }, "Message"));