@pingux/astro 1.0.0-alpha.10 → 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 +44 -0
- package/lib/cjs/components/Button/Button.stories.js +5 -11
- package/lib/cjs/components/Chip/Chip.js +26 -10
- package/lib/cjs/components/Chip/Chip.stories.js +44 -5
- package/lib/cjs/components/Chip/Chip.test.js +9 -0
- package/lib/cjs/components/Chip/ChipContext.js +19 -0
- package/lib/cjs/components/IconButton/IconButton.js +11 -1
- package/lib/cjs/components/ListView/ListView.js +4 -3
- package/lib/cjs/components/ListViewItem/ListViewItem.js +3 -6
- package/lib/cjs/layouts/ListLayout.stories.js +2 -1
- package/lib/cjs/recipes/InputBoxWithLinkedChip.stories.js +1 -1
- package/lib/cjs/styles/variants/boxes.js +20 -3
- package/lib/cjs/styles/variants/buttons.js +1 -1
- package/lib/components/Button/Button.stories.js +5 -10
- package/lib/components/Chip/Chip.js +25 -10
- package/lib/components/Chip/Chip.stories.js +41 -5
- package/lib/components/Chip/Chip.test.js +9 -0
- package/lib/components/Chip/ChipContext.js +3 -0
- package/lib/components/IconButton/IconButton.js +11 -2
- package/lib/components/ListView/ListView.js +4 -3
- package/lib/components/ListViewItem/ListViewItem.js +3 -5
- package/lib/layouts/ListLayout.stories.js +2 -1
- package/lib/recipes/InputBoxWithLinkedChip.stories.js +1 -1
- package/lib/styles/variants/boxes.js +20 -3
- package/lib/styles/variants/buttons.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,50 @@
|
|
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
|
+
|
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)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* [UIP-5063] Inline Button Text Size ([6f03c64](https://gitlab.corp.pingidentity.com/ux/pingux/commit/6f03c64b13dc2237d09acb565282394effd419b8))
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
# [1.0.0-alpha.12](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.0.0-alpha.11...@pingux/astro@1.0.0-alpha.12) (2022-01-10)
|
29
|
+
|
30
|
+
|
31
|
+
### Bug Fixes
|
32
|
+
|
33
|
+
* [UIP-5061] hide variants that aren't used for <Button> specifically ([85a494c](https://gitlab.corp.pingidentity.com/ux/pingux/commit/85a494cc3fa656a2fc6bb37dc0e718bdcfee7829))
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# [1.0.0-alpha.11](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.0.0-alpha.10...@pingux/astro@1.0.0-alpha.11) (2022-01-08)
|
40
|
+
|
41
|
+
|
42
|
+
### Features
|
43
|
+
|
44
|
+
* [UIP-4887] ListView hides Separators on zoom ([92ca2bb](https://gitlab.corp.pingidentity.com/ux/pingux/commit/92ca2bb40bb49ce9a69eb097cc88b5e210acce8a))
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
6
50
|
# [1.0.0-alpha.10](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.0.0-alpha.9...@pingux/astro@1.0.0-alpha.10) (2022-01-07)
|
7
51
|
|
8
52
|
|
@@ -10,10 +10,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
10
10
|
|
11
11
|
exports.InlineButton = exports.TextButton = exports.TextIconButton = exports.Disabled = exports.Default = exports["default"] = void 0;
|
12
12
|
|
13
|
-
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
14
|
-
|
15
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
16
|
-
|
17
13
|
var _react = _interopRequireDefault(require("react"));
|
18
14
|
|
19
15
|
var _AddCircleIcon = _interopRequireDefault(require("mdi-react/AddCircleIcon"));
|
@@ -30,13 +26,13 @@ var _variants = require("../../utils/devUtils/constants/variants");
|
|
30
26
|
|
31
27
|
var _react2 = require("@emotion/react");
|
32
28
|
|
33
|
-
var _context;
|
34
|
-
|
35
29
|
// removing the iconButton variants from this story.
|
36
30
|
var variants = _variants.buttonVariants;
|
37
31
|
delete variants.ICON;
|
38
32
|
delete variants.ICON_BUTTON;
|
39
|
-
delete variants.INVERTED;
|
33
|
+
delete variants.INVERTED; // add designer approved variants for devs to use here
|
34
|
+
|
35
|
+
var variantOptions = ['critical', 'danger', 'default', 'inline', 'link', 'primary', 'success', 'text'];
|
40
36
|
var _default = {
|
41
37
|
title: 'Button',
|
42
38
|
component: _["default"],
|
@@ -44,11 +40,9 @@ var _default = {
|
|
44
40
|
variant: {
|
45
41
|
control: {
|
46
42
|
type: 'select',
|
47
|
-
options:
|
43
|
+
options: variantOptions
|
48
44
|
},
|
49
|
-
defaultValue:
|
50
|
-
return value === 'default';
|
51
|
-
})
|
45
|
+
defaultValue: 'default'
|
52
46
|
},
|
53
47
|
children: {
|
54
48
|
description: 'Button text.',
|
@@ -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
|
37
|
+
var bg = props.bg,
|
38
|
+
children = props.children,
|
36
39
|
textColor = props.textColor,
|
37
40
|
textProps = props.textProps,
|
38
|
-
label = props.label
|
39
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
23
|
+
var _ContentCopyIcon = _interopRequireDefault(require("mdi-react/ContentCopyIcon"));
|
24
24
|
|
25
|
-
var
|
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) {
|
@@ -81,18 +81,19 @@ var collectionTypes = {
|
|
81
81
|
exports.collectionTypes = collectionTypes;
|
82
82
|
|
83
83
|
function useListLayout(state) {
|
84
|
+
var ROW_HEIGHT = 81;
|
84
85
|
var collator = (0, _i18n.useCollator)({
|
85
86
|
usage: 'search',
|
86
87
|
sensitivity: 'base'
|
87
88
|
});
|
88
89
|
var layout = (0, _react.useMemo)(function () {
|
89
90
|
return new _layout.ListLayout({
|
90
|
-
estimatedRowHeight:
|
91
|
+
estimatedRowHeight: ROW_HEIGHT,
|
91
92
|
estimatedHeadingHeight: 26,
|
92
93
|
paddingRight: 4,
|
93
94
|
paddingLeft: 4,
|
94
|
-
loaderHeight:
|
95
|
-
placeholderHeight:
|
95
|
+
loaderHeight: ROW_HEIGHT,
|
96
|
+
placeholderHeight: ROW_HEIGHT,
|
96
97
|
collator: collator
|
97
98
|
});
|
98
99
|
}, [collator]);
|
@@ -32,8 +32,6 @@ var _ListViewContext = require("../ListView/ListViewContext");
|
|
32
32
|
|
33
33
|
var _Box = _interopRequireDefault(require("../Box"));
|
34
34
|
|
35
|
-
var _Separator = _interopRequireDefault(require("../Separator"));
|
36
|
-
|
37
35
|
var _hooks = require("../../hooks");
|
38
36
|
|
39
37
|
var _react2 = require("@emotion/react");
|
@@ -90,7 +88,8 @@ var ListViewItem = function ListViewItem(props) {
|
|
90
88
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
91
89
|
isHovered: isHovered,
|
92
90
|
isSelected: isSelected,
|
93
|
-
isFocused: isDisabled ? false : isFocusVisible
|
91
|
+
isFocused: isDisabled ? false : isFocusVisible,
|
92
|
+
hasSeparator: hasSeparator
|
94
93
|
}),
|
95
94
|
classNames = _useStatusClasses.classNames;
|
96
95
|
|
@@ -111,9 +110,7 @@ var ListViewItem = function ListViewItem(props) {
|
|
111
110
|
isSelected: isSelected,
|
112
111
|
className: classNames,
|
113
112
|
"data-id": dataId
|
114
|
-
}, listItemProps), item.rendered))
|
115
|
-
m: "0px"
|
116
|
-
}));
|
113
|
+
}, listItemProps), item.rendered)));
|
117
114
|
};
|
118
115
|
|
119
116
|
ListViewItem.propTypes = {
|
@@ -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"
|
@@ -106,6 +106,10 @@ var listViewItem = _objectSpread(_objectSpread({}, base), {}, {
|
|
106
106
|
},
|
107
107
|
'&.is-focused': {
|
108
108
|
boxShadow: 'inset 0 0 5px #5873bdbf'
|
109
|
+
},
|
110
|
+
'&.has-separator': {
|
111
|
+
borderBottom: '1px solid',
|
112
|
+
borderBottomColor: 'line.hairline'
|
109
113
|
}
|
110
114
|
});
|
111
115
|
|
@@ -119,14 +123,27 @@ var listBoxSectionTitle = {
|
|
119
123
|
};
|
120
124
|
var chip = {
|
121
125
|
cursor: 'pointer',
|
122
|
-
|
123
|
-
p: '10px',
|
126
|
+
p: '3px 5px 4px 5px',
|
124
127
|
alignItems: 'center',
|
125
128
|
justifyContent: 'center',
|
126
129
|
minWidth: '50px',
|
127
130
|
alignSelf: 'flex-start',
|
128
131
|
display: 'inline-flex !important',
|
129
|
-
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
|
+
}
|
130
147
|
};
|
131
148
|
var inputInContainerSlot = {
|
132
149
|
position: 'absolute',
|
@@ -1,8 +1,3 @@
|
|
1
|
-
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
2
|
-
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
3
|
-
|
4
|
-
var _context;
|
5
|
-
|
6
1
|
import React from 'react';
|
7
2
|
import AddCircleIcon from 'mdi-react/AddCircleIcon';
|
8
3
|
import Box from '../Box';
|
@@ -15,7 +10,9 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
15
10
|
var variants = buttonVariants;
|
16
11
|
delete variants.ICON;
|
17
12
|
delete variants.ICON_BUTTON;
|
18
|
-
delete variants.INVERTED;
|
13
|
+
delete variants.INVERTED; // add designer approved variants for devs to use here
|
14
|
+
|
15
|
+
var variantOptions = ['critical', 'danger', 'default', 'inline', 'link', 'primary', 'success', 'text'];
|
19
16
|
export default {
|
20
17
|
title: 'Button',
|
21
18
|
component: Button,
|
@@ -23,11 +20,9 @@ export default {
|
|
23
20
|
variant: {
|
24
21
|
control: {
|
25
22
|
type: 'select',
|
26
|
-
options:
|
23
|
+
options: variantOptions
|
27
24
|
},
|
28
|
-
defaultValue:
|
29
|
-
return value === 'default';
|
30
|
-
})
|
25
|
+
defaultValue: 'default'
|
31
26
|
},
|
32
27
|
children: {
|
33
28
|
description: 'Button text.',
|
@@ -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
|
16
|
+
var bg = props.bg,
|
17
|
+
children = props.children,
|
16
18
|
textColor = props.textColor,
|
17
19
|
textProps = props.textProps,
|
18
|
-
label = props.label
|
19
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
7
|
-
import
|
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
|
});
|
@@ -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) {
|
@@ -37,18 +37,19 @@ export var collectionTypes = {
|
|
37
37
|
PLACEHOLDER: 'placeholder'
|
38
38
|
};
|
39
39
|
export function useListLayout(state) {
|
40
|
+
var ROW_HEIGHT = 81;
|
40
41
|
var collator = useCollator({
|
41
42
|
usage: 'search',
|
42
43
|
sensitivity: 'base'
|
43
44
|
});
|
44
45
|
var layout = useMemo(function () {
|
45
46
|
return new ListLayout({
|
46
|
-
estimatedRowHeight:
|
47
|
+
estimatedRowHeight: ROW_HEIGHT,
|
47
48
|
estimatedHeadingHeight: 26,
|
48
49
|
paddingRight: 4,
|
49
50
|
paddingLeft: 4,
|
50
|
-
loaderHeight:
|
51
|
-
placeholderHeight:
|
51
|
+
loaderHeight: ROW_HEIGHT,
|
52
|
+
placeholderHeight: ROW_HEIGHT,
|
52
53
|
collator: collator
|
53
54
|
});
|
54
55
|
}, [collator]);
|
@@ -8,7 +8,6 @@ import { useGridCell, useGridRow } from '@react-aria/grid';
|
|
8
8
|
import { useHover } from '@react-aria/interactions';
|
9
9
|
import { ListViewContext } from '../ListView/ListViewContext';
|
10
10
|
import Box from '../Box';
|
11
|
-
import Separator from '../Separator';
|
12
11
|
import { useStatusClasses } from '../../hooks';
|
13
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
14
13
|
|
@@ -65,7 +64,8 @@ var ListViewItem = function ListViewItem(props) {
|
|
65
64
|
var _useStatusClasses = useStatusClasses(className, {
|
66
65
|
isHovered: isHovered,
|
67
66
|
isSelected: isSelected,
|
68
|
-
isFocused: isDisabled ? false : isFocusVisible
|
67
|
+
isFocused: isDisabled ? false : isFocusVisible,
|
68
|
+
hasSeparator: hasSeparator
|
69
69
|
}),
|
70
70
|
classNames = _useStatusClasses.classNames;
|
71
71
|
|
@@ -86,9 +86,7 @@ var ListViewItem = function ListViewItem(props) {
|
|
86
86
|
isSelected: isSelected,
|
87
87
|
className: classNames,
|
88
88
|
"data-id": dataId
|
89
|
-
}, listItemProps), item.rendered))
|
90
|
-
m: "0px"
|
91
|
-
}));
|
89
|
+
}, listItemProps), item.rendered)));
|
92
90
|
};
|
93
91
|
|
94
92
|
ListViewItem.propTypes = {
|
@@ -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"
|
@@ -85,6 +85,10 @@ var listViewItem = _objectSpread(_objectSpread({}, base), {}, {
|
|
85
85
|
},
|
86
86
|
'&.is-focused': {
|
87
87
|
boxShadow: 'inset 0 0 5px #5873bdbf'
|
88
|
+
},
|
89
|
+
'&.has-separator': {
|
90
|
+
borderBottom: '1px solid',
|
91
|
+
borderBottomColor: 'line.hairline'
|
88
92
|
}
|
89
93
|
});
|
90
94
|
|
@@ -98,14 +102,27 @@ var listBoxSectionTitle = {
|
|
98
102
|
};
|
99
103
|
var chip = {
|
100
104
|
cursor: 'pointer',
|
101
|
-
|
102
|
-
p: '10px',
|
105
|
+
p: '3px 5px 4px 5px',
|
103
106
|
alignItems: 'center',
|
104
107
|
justifyContent: 'center',
|
105
108
|
minWidth: '50px',
|
106
109
|
alignSelf: 'flex-start',
|
107
110
|
display: 'inline-flex !important',
|
108
|
-
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
|
+
}
|
109
126
|
};
|
110
127
|
var inputInContainerSlot = {
|
111
128
|
position: 'absolute',
|