@pingux/astro 1.0.0-alpha.13 → 1.0.0-alpha.14

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.14](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.0.0-alpha.13...@pingux/astro@1.0.0-alpha.14) (2022-01-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * [UIP-4953] Chip component cleanup ([d2f10ec](https://gitlab.corp.pingidentity.com/ux/pingux/commit/d2f10ece82749d723ac35b6262c1b918f81abba1))
12
+
13
+
14
+
15
+
16
+
6
17
  # [1.0.0-alpha.13](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.0.0-alpha.12...@pingux/astro@1.0.0-alpha.13) (2022-01-10)
7
18
 
8
19
 
@@ -18,6 +18,8 @@ var _react = _interopRequireDefault(require("react"));
18
18
 
19
19
  var _propTypes = _interopRequireDefault(require("prop-types"));
20
20
 
21
+ var _ChipContext = require("./ChipContext");
22
+
21
23
  var _Box = _interopRequireDefault(require("../Box/Box"));
22
24
 
23
25
  var _Text = _interopRequireDefault(require("../Text/Text"));
@@ -32,21 +34,31 @@ var _react2 = require("@emotion/react");
32
34
  * available [props from Theme-UI](https://theme-ui.com/sx-prop).
33
35
  */
34
36
  var Chip = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
35
- var children = props.children,
37
+ var bg = props.bg,
38
+ children = props.children,
36
39
  textColor = props.textColor,
37
40
  textProps = props.textProps,
38
- label = props.label;
39
- return (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
41
+ label = props.label,
42
+ isUppercase = props.isUppercase;
43
+ return (0, _react2.jsx)(_ChipContext.ChipContext.Provider, {
44
+ value: {
45
+ bg: bg
46
+ }
47
+ }, (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
40
48
  isRow: true,
41
49
  variant: "boxes.chip",
50
+ sx: isUppercase && {
51
+ paddingBottom: '3px'
52
+ },
42
53
  ref: ref
43
54
  }, props), (0, _react2.jsx)(_Text["default"], (0, _extends2["default"])({
44
55
  variant: "label",
45
- sx: {
46
- textTransform: 'uppercase'
47
- },
48
- color: textColor
49
- }, textProps), label), children);
56
+ color: textColor,
57
+ sx: isUppercase && {
58
+ textTransform: 'uppercase',
59
+ fontSize: '11px'
60
+ }
61
+ }, textProps), label), children));
50
62
  });
51
63
 
52
64
  Chip.propTypes = {
@@ -60,11 +72,15 @@ Chip.propTypes = {
60
72
  label: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]),
61
73
 
62
74
  /** Props object that is spread directly into the textfield. */
63
- textProps: _propTypes["default"].shape({})
75
+ textProps: _propTypes["default"].shape({}),
76
+
77
+ /** When true, display chip label as uppercase. */
78
+ isUppercase: _propTypes["default"].bool
64
79
  };
65
80
  Chip.defaultProps = {
66
81
  textColor: 'white',
67
- bg: colors.neutral[10]
82
+ bg: colors.neutral[10],
83
+ isUppercase: false
68
84
  };
69
85
  var _default = Chip;
70
86
  exports["default"] = _default;
@@ -20,9 +20,15 @@ var _react = _interopRequireDefault(require("react"));
20
20
 
21
21
  var _CloseIcon = _interopRequireDefault(require("mdi-react/CloseIcon"));
22
22
 
23
- var _Chip = _interopRequireDefault(require("../Chip/Chip"));
23
+ var _ContentCopyIcon = _interopRequireDefault(require("mdi-react/ContentCopyIcon"));
24
24
 
25
- var _Icon = _interopRequireDefault(require("../Icon/Icon"));
25
+ var _EarthIcon = _interopRequireDefault(require("mdi-react/EarthIcon"));
26
+
27
+ var _Chip = _interopRequireDefault(require("../Chip"));
28
+
29
+ var _Icon = _interopRequireDefault(require("../Icon"));
30
+
31
+ var _IconButton = _interopRequireDefault(require("../IconButton"));
26
32
 
27
33
  var _colors = require("../../styles/colors.js");
28
34
 
@@ -61,6 +67,12 @@ var _default = {
61
67
  control: {
62
68
  type: 'text'
63
69
  }
70
+ },
71
+ isUppercase: {
72
+ defaultValue: false,
73
+ control: {
74
+ type: 'boolean'
75
+ }
64
76
  }
65
77
  }
66
78
  };
@@ -87,15 +99,42 @@ var ChipWithCustomColors = function ChipWithCustomColors() {
87
99
  exports.ChipWithCustomColors = ChipWithCustomColors;
88
100
 
89
101
  var ChipWithIcon = function ChipWithIcon() {
90
- return (0, _react2.jsx)(_Chip["default"], {
91
- label: "Chip with Icon",
102
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Chip["default"], {
103
+ label: "Chip with Icon Button",
92
104
  bg: "navy"
105
+ }, (0, _react2.jsx)(_IconButton["default"], {
106
+ "aria-label": "Clear Chip with Icon Button",
107
+ variant: "inverted"
93
108
  }, (0, _react2.jsx)(_Icon["default"], {
94
109
  icon: _CloseIcon["default"],
95
110
  ml: "xs",
111
+ size: "14px"
112
+ }))), (0, _react2.jsx)("div", {
113
+ style: {
114
+ padding: '5px'
115
+ }
116
+ }), (0, _react2.jsx)(_Chip["default"], {
117
+ label: "Chip with Icon Button"
118
+ }, (0, _react2.jsx)(_IconButton["default"], {
119
+ "aria-label": "Clear Chip with Icon Button",
120
+ variant: "inverted"
121
+ }, (0, _react2.jsx)(_Icon["default"], {
122
+ icon: _EarthIcon["default"],
123
+ ml: "xs",
124
+ size: "14px"
125
+ }))), (0, _react2.jsx)("div", {
126
+ style: {
127
+ padding: '5px'
128
+ }
129
+ }), (0, _react2.jsx)(_Chip["default"], {
130
+ label: "Chip with Icon",
131
+ bg: "green"
132
+ }, (0, _react2.jsx)(_Icon["default"], {
133
+ icon: _ContentCopyIcon["default"],
134
+ ml: "xs",
96
135
  size: "14px",
97
136
  color: "white"
98
- }));
137
+ })));
99
138
  };
100
139
 
101
140
  exports.ChipWithIcon = ChipWithIcon;
@@ -45,4 +45,13 @@ test('renders children within Chip component', function () {
45
45
  var mockedChildren = _react2.screen.getByRole('button');
46
46
 
47
47
  expect(mockedChildren).toBeInTheDocument();
48
+ });
49
+ test('renders Chip component with uppercase', function () {
50
+ var label = 'uppercase';
51
+ var isUppercase = true;
52
+ getComponent({
53
+ label: label,
54
+ isUppercase: isUppercase
55
+ });
56
+ expect(_react2.screen.queryByText('uppercase')).toHaveStyleRule('text-transform', 'uppercase');
48
57
  });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.ChipContext = void 0;
12
+
13
+ var _react = _interopRequireDefault(require("react"));
14
+
15
+ var defaultValue = 'inherit';
16
+
17
+ var ChipContext = /*#__PURE__*/_react["default"].createContext(defaultValue);
18
+
19
+ exports.ChipContext = ChipContext;
@@ -48,6 +48,8 @@ var _utils = require("@react-aria/utils");
48
48
 
49
49
  var _hooks = require("../../hooks");
50
50
 
51
+ var _ChipContext = require("../Chip/ChipContext");
52
+
51
53
  var _TooltipTrigger = _interopRequireWildcard(require("../TooltipTrigger"));
52
54
 
53
55
  var _react2 = require("@emotion/react");
@@ -82,6 +84,9 @@ var IconButton = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
82
84
  return buttonRef.current;
83
85
  });
84
86
 
87
+ var _useContext = (0, _react.useContext)(_ChipContext.ChipContext),
88
+ chipBg = _useContext.bg;
89
+
85
90
  var _usePress = (0, _interactions.usePress)(_objectSpread({
86
91
  ref: buttonRef
87
92
  }, props)),
@@ -110,7 +115,12 @@ var IconButton = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
110
115
  tabIndex: 0,
111
116
  ref: buttonRef,
112
117
  className: classNames,
113
- "aria-label": ariaLabel || 'Icon Button'
118
+ "aria-label": ariaLabel || 'Icon Button',
119
+ sx: chipBg && isHovered && {
120
+ 'path': {
121
+ fill: chipBg
122
+ }
123
+ }
114
124
  }, others, (0, _utils.mergeProps)(hoverProps, focusProps, pressProps)), children);
115
125
 
116
126
  if (title) {
@@ -301,7 +301,8 @@ var Default = function Default() {
301
301
  }, (0, _react2.jsx)(_index.Chip, {
302
302
  bg: "success.light",
303
303
  textColor: "success.dark",
304
- label: "New"
304
+ label: "New",
305
+ isUppercase: true
305
306
  })) : null)), (0, _react2.jsx)(_index.Box, {
306
307
  isRow: true,
307
308
  alignSelf: "center"
@@ -52,7 +52,7 @@ var Default = function Default() {
52
52
  }, (0, _react2.jsx)(_Icon["default"], {
53
53
  icon: _LinkVariantIcon["default"],
54
54
  color: "#253746",
55
- size: 15,
55
+ size: 12,
56
56
  alignSelf: "center",
57
57
  mr: "xs"
58
58
  }), (0, _react2.jsx)(_Text["default"], {
@@ -123,14 +123,27 @@ var listBoxSectionTitle = {
123
123
  };
124
124
  var chip = {
125
125
  cursor: 'pointer',
126
- height: '15px',
127
- p: '10px',
126
+ p: '3px 5px 4px 5px',
128
127
  alignItems: 'center',
129
128
  justifyContent: 'center',
130
129
  minWidth: '50px',
131
130
  alignSelf: 'flex-start',
132
131
  display: 'inline-flex !important',
133
- borderRadius: '5px'
132
+ borderRadius: '5px',
133
+ fontWeight: 1,
134
+ '& button': {
135
+ backgroundColor: 'transparent',
136
+ marginLeft: 'xs',
137
+ marginTop: '1px',
138
+ padding: '0',
139
+ '&.is-hovered': {
140
+ backgroundColor: 'white'
141
+ },
142
+ '& .mdi-icon': {
143
+ marginLeft: '0',
144
+ padding: '2px'
145
+ }
146
+ }
134
147
  };
135
148
  var inputInContainerSlot = {
136
149
  position: 'absolute',
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
+ import { ChipContext } from './ChipContext';
4
5
  import Box from '../Box/Box';
5
6
  import Text from '../Text/Text';
6
7
  import * as colors from '../../styles/colors';
@@ -12,21 +13,31 @@ import * as colors from '../../styles/colors';
12
13
 
13
14
  import { jsx as ___EmotionJSX } from "@emotion/react";
14
15
  var Chip = /*#__PURE__*/React.forwardRef(function (props, ref) {
15
- var children = props.children,
16
+ var bg = props.bg,
17
+ children = props.children,
16
18
  textColor = props.textColor,
17
19
  textProps = props.textProps,
18
- label = props.label;
19
- return ___EmotionJSX(Box, _extends({
20
+ label = props.label,
21
+ isUppercase = props.isUppercase;
22
+ return ___EmotionJSX(ChipContext.Provider, {
23
+ value: {
24
+ bg: bg
25
+ }
26
+ }, ___EmotionJSX(Box, _extends({
20
27
  isRow: true,
21
28
  variant: "boxes.chip",
29
+ sx: isUppercase && {
30
+ paddingBottom: '3px'
31
+ },
22
32
  ref: ref
23
33
  }, props), ___EmotionJSX(Text, _extends({
24
34
  variant: "label",
25
- sx: {
26
- textTransform: 'uppercase'
27
- },
28
- color: textColor
29
- }, textProps), label), children);
35
+ color: textColor,
36
+ sx: isUppercase && {
37
+ textTransform: 'uppercase',
38
+ fontSize: '11px'
39
+ }
40
+ }, textProps), label), children));
30
41
  });
31
42
  Chip.propTypes = {
32
43
  /** The text color of the chip. */
@@ -39,10 +50,14 @@ Chip.propTypes = {
39
50
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
40
51
 
41
52
  /** Props object that is spread directly into the textfield. */
42
- textProps: PropTypes.shape({})
53
+ textProps: PropTypes.shape({}),
54
+
55
+ /** When true, display chip label as uppercase. */
56
+ isUppercase: PropTypes.bool
43
57
  };
44
58
  Chip.defaultProps = {
45
59
  textColor: 'white',
46
- bg: colors.neutral[10]
60
+ bg: colors.neutral[10],
61
+ isUppercase: false
47
62
  };
48
63
  export default Chip;
@@ -3,8 +3,11 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
3
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
4
  import React from 'react';
5
5
  import Clear from 'mdi-react/CloseIcon';
6
- import Chip from '../Chip/Chip';
7
- import Icon from '../Icon/Icon';
6
+ import ContentCopy from 'mdi-react/ContentCopyIcon';
7
+ import Earth from 'mdi-react/EarthIcon';
8
+ import Chip from '../Chip';
9
+ import Icon from '../Icon';
10
+ import IconButton from '../IconButton';
8
11
  import { flatColorList } from '../../styles/colors.js';
9
12
  import { jsx as ___EmotionJSX } from "@emotion/react";
10
13
  export default {
@@ -40,6 +43,12 @@ export default {
40
43
  control: {
41
44
  type: 'text'
42
45
  }
46
+ },
47
+ isUppercase: {
48
+ defaultValue: false,
49
+ control: {
50
+ type: 'boolean'
51
+ }
43
52
  }
44
53
  }
45
54
  };
@@ -59,13 +68,40 @@ export var ChipWithCustomColors = function ChipWithCustomColors() {
59
68
  });
60
69
  };
61
70
  export var ChipWithIcon = function ChipWithIcon() {
62
- return ___EmotionJSX(Chip, {
63
- label: "Chip with Icon",
71
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Chip, {
72
+ label: "Chip with Icon Button",
64
73
  bg: "navy"
74
+ }, ___EmotionJSX(IconButton, {
75
+ "aria-label": "Clear Chip with Icon Button",
76
+ variant: "inverted"
65
77
  }, ___EmotionJSX(Icon, {
66
78
  icon: Clear,
67
79
  ml: "xs",
80
+ size: "14px"
81
+ }))), ___EmotionJSX("div", {
82
+ style: {
83
+ padding: '5px'
84
+ }
85
+ }), ___EmotionJSX(Chip, {
86
+ label: "Chip with Icon Button"
87
+ }, ___EmotionJSX(IconButton, {
88
+ "aria-label": "Clear Chip with Icon Button",
89
+ variant: "inverted"
90
+ }, ___EmotionJSX(Icon, {
91
+ icon: Earth,
92
+ ml: "xs",
93
+ size: "14px"
94
+ }))), ___EmotionJSX("div", {
95
+ style: {
96
+ padding: '5px'
97
+ }
98
+ }), ___EmotionJSX(Chip, {
99
+ label: "Chip with Icon",
100
+ bg: "green"
101
+ }, ___EmotionJSX(Icon, {
102
+ icon: ContentCopy,
103
+ ml: "xs",
68
104
  size: "14px",
69
105
  color: "white"
70
- }));
106
+ })));
71
107
  };
@@ -31,4 +31,13 @@ test('renders children within Chip component', function () {
31
31
  });
32
32
  var mockedChildren = screen.getByRole('button');
33
33
  expect(mockedChildren).toBeInTheDocument();
34
+ });
35
+ test('renders Chip component with uppercase', function () {
36
+ var label = 'uppercase';
37
+ var isUppercase = true;
38
+ getComponent({
39
+ label: label,
40
+ isUppercase: isUppercase
41
+ });
42
+ expect(screen.queryByText('uppercase')).toHaveStyleRule('text-transform', 'uppercase');
34
43
  });
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ var defaultValue = 'inherit';
3
+ export var ChipContext = /*#__PURE__*/React.createContext(defaultValue);
@@ -14,13 +14,14 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
14
14
 
15
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
16
 
17
- import React, { forwardRef, useRef, useImperativeHandle } from 'react';
17
+ import React, { forwardRef, useRef, useImperativeHandle, useContext } from 'react';
18
18
  import PropTypes from 'prop-types';
19
19
  import { IconButton as ThemeUIIconButton } from 'theme-ui';
20
20
  import { useFocusRing } from '@react-aria/focus';
21
21
  import { Pressable, useHover, usePress } from '@react-aria/interactions';
22
22
  import { mergeProps } from '@react-aria/utils';
23
23
  import { useAriaLabelWarning, useStatusClasses } from '../../hooks';
24
+ import { ChipContext } from '../Chip/ChipContext';
24
25
  import TooltipTrigger, { Tooltip } from '../TooltipTrigger';
25
26
  /**
26
27
  * Convenience wrapper for a Button + Icon. This component applies specific styles necessary for
@@ -51,6 +52,9 @@ var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
51
52
  return buttonRef.current;
52
53
  });
53
54
 
55
+ var _useContext = useContext(ChipContext),
56
+ chipBg = _useContext.bg;
57
+
54
58
  var _usePress = usePress(_objectSpread({
55
59
  ref: buttonRef
56
60
  }, props)),
@@ -80,7 +84,12 @@ var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
80
84
  tabIndex: 0,
81
85
  ref: buttonRef,
82
86
  className: classNames,
83
- "aria-label": ariaLabel || 'Icon Button'
87
+ "aria-label": ariaLabel || 'Icon Button',
88
+ sx: chipBg && isHovered && {
89
+ 'path': {
90
+ fill: chipBg
91
+ }
92
+ }
84
93
  }, others, mergeProps(hoverProps, focusProps, pressProps)), children);
85
94
 
86
95
  if (title) {
@@ -274,7 +274,8 @@ export var Default = function Default() {
274
274
  }, ___EmotionJSX(Chip, {
275
275
  bg: "success.light",
276
276
  textColor: "success.dark",
277
- label: "New"
277
+ label: "New",
278
+ isUppercase: true
278
279
  })) : null)), ___EmotionJSX(Box, {
279
280
  isRow: true,
280
281
  alignSelf: "center"
@@ -30,7 +30,7 @@ export var Default = function Default() {
30
30
  }, ___EmotionJSX(Icon, {
31
31
  icon: Link,
32
32
  color: "#253746",
33
- size: 15,
33
+ size: 12,
34
34
  alignSelf: "center",
35
35
  mr: "xs"
36
36
  }), ___EmotionJSX(Text, {
@@ -102,14 +102,27 @@ var listBoxSectionTitle = {
102
102
  };
103
103
  var chip = {
104
104
  cursor: 'pointer',
105
- height: '15px',
106
- p: '10px',
105
+ p: '3px 5px 4px 5px',
107
106
  alignItems: 'center',
108
107
  justifyContent: 'center',
109
108
  minWidth: '50px',
110
109
  alignSelf: 'flex-start',
111
110
  display: 'inline-flex !important',
112
- borderRadius: '5px'
111
+ borderRadius: '5px',
112
+ fontWeight: 1,
113
+ '& button': {
114
+ backgroundColor: 'transparent',
115
+ marginLeft: 'xs',
116
+ marginTop: '1px',
117
+ padding: '0',
118
+ '&.is-hovered': {
119
+ backgroundColor: 'white'
120
+ },
121
+ '& .mdi-icon': {
122
+ marginLeft: '0',
123
+ padding: '2px'
124
+ }
125
+ }
113
126
  };
114
127
  var inputInContainerSlot = {
115
128
  position: 'absolute',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.14",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "uxdev@pingidentity.com",
6
6
  "license": "Apache-2.0",