@pingux/astro 2.202.2-alpha.0 → 2.204.0-alpha.0
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/lib/cjs/components/Button/Button.stories.js +6 -1
- package/lib/cjs/components/Button/Buttons.styles.d.ts +80 -0
- package/lib/cjs/components/Button/Buttons.styles.js +5 -1
- package/lib/cjs/components/Button/buttonAttributes.js +1 -1
- package/lib/cjs/components/LinkSelectField/LinkSelectField.js +29 -10
- package/lib/cjs/components/LinkSelectField/LinkSelectField.stories.js +55 -1
- package/lib/cjs/components/LinkSelectField/LinkSelectField.test.js +33 -8
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.d.ts +13 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +13 -0
- package/lib/cjs/styles/themeOverrides/onyxDarkUiLibraryOverride.js +3 -1
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +16 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +16 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.js +8 -0
- package/lib/components/Button/Button.stories.js +5 -0
- package/lib/components/Button/Buttons.styles.js +4 -0
- package/lib/components/Button/buttonAttributes.js +1 -1
- package/lib/components/LinkSelectField/LinkSelectField.js +29 -10
- package/lib/components/LinkSelectField/LinkSelectField.stories.js +55 -1
- package/lib/components/LinkSelectField/LinkSelectField.test.js +33 -8
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +13 -0
- package/lib/styles/themeOverrides/onyxDarkUiLibraryOverride.js +3 -1
- package/lib/styles/themes/next-gen/variants/button.js +8 -0
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
12
12
|
_Object$defineProperty(exports, "__esModule", {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
exports["default"] = exports.WithLoading = exports.TextIconButton = exports.Primary = exports.LinkButton = exports.InlineButton = exports.Filter = exports.Disabled = exports.Default = exports.Critical = exports.ColorBlockButton = void 0;
|
|
15
|
+
exports["default"] = exports.WithLoading = exports.TextIconButton = exports.Primary = exports.LinkButton = exports.InlineButton = exports.Filter = exports.Disabled = exports.Default = exports.CriticalLink = exports.Critical = exports.ColorBlockButton = void 0;
|
|
16
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
17
17
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
18
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
@@ -75,6 +75,11 @@ Critical.parameters = {
|
|
|
75
75
|
url: _figmaLinks.FIGMA_LINKS.button.critical
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
+
var CriticalLink = exports.CriticalLink = function CriticalLink(args) {
|
|
79
|
+
return (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({}, args, {
|
|
80
|
+
variant: "criticalLink"
|
|
81
|
+
}), "Button Text");
|
|
82
|
+
};
|
|
78
83
|
var InlineButton = exports.InlineButton = function InlineButton(args) {
|
|
79
84
|
return (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({}, args, {
|
|
80
85
|
mb: "sm",
|
|
@@ -126,6 +126,46 @@ export declare const link: {
|
|
|
126
126
|
flexShrink: number;
|
|
127
127
|
whiteSpace: string;
|
|
128
128
|
};
|
|
129
|
+
export declare const criticalLink: {
|
|
130
|
+
color: string;
|
|
131
|
+
lineHeight: string;
|
|
132
|
+
textDecoration: string;
|
|
133
|
+
display: string;
|
|
134
|
+
justifyContent: string;
|
|
135
|
+
width: string;
|
|
136
|
+
'&.is-current': {
|
|
137
|
+
cursor: string;
|
|
138
|
+
color: string;
|
|
139
|
+
};
|
|
140
|
+
'&.is-focused': {
|
|
141
|
+
boxShadow: string;
|
|
142
|
+
outline: string;
|
|
143
|
+
outlineColor: string;
|
|
144
|
+
outlineOffset: string;
|
|
145
|
+
};
|
|
146
|
+
bg: string;
|
|
147
|
+
border: string;
|
|
148
|
+
borderColor: string;
|
|
149
|
+
height: string;
|
|
150
|
+
padding: string;
|
|
151
|
+
'&.is-hovered': {
|
|
152
|
+
textDecoration: string;
|
|
153
|
+
};
|
|
154
|
+
fontSize: string;
|
|
155
|
+
fontWeight: number;
|
|
156
|
+
fontFamily: string;
|
|
157
|
+
overflowWrap: import("../..").overflowWrap;
|
|
158
|
+
maxWidth: string;
|
|
159
|
+
wordWrap: import("../..").wordWrap;
|
|
160
|
+
wordBreak: import("../..").wordBreak;
|
|
161
|
+
cursor: string;
|
|
162
|
+
minWidth: string;
|
|
163
|
+
outline: string;
|
|
164
|
+
alignItems: string;
|
|
165
|
+
borderRadius: string;
|
|
166
|
+
flexShrink: number;
|
|
167
|
+
whiteSpace: string;
|
|
168
|
+
};
|
|
129
169
|
export declare const selectLink: {
|
|
130
170
|
textDecoration: string;
|
|
131
171
|
'&.is-hovered': {
|
|
@@ -724,6 +764,46 @@ declare const _default: {
|
|
|
724
764
|
flexShrink: number;
|
|
725
765
|
whiteSpace: string;
|
|
726
766
|
};
|
|
767
|
+
criticalLink: {
|
|
768
|
+
color: string;
|
|
769
|
+
lineHeight: string;
|
|
770
|
+
textDecoration: string;
|
|
771
|
+
display: string;
|
|
772
|
+
justifyContent: string;
|
|
773
|
+
width: string;
|
|
774
|
+
'&.is-current': {
|
|
775
|
+
cursor: string;
|
|
776
|
+
color: string;
|
|
777
|
+
};
|
|
778
|
+
'&.is-focused': {
|
|
779
|
+
boxShadow: string;
|
|
780
|
+
outline: string;
|
|
781
|
+
outlineColor: string;
|
|
782
|
+
outlineOffset: string;
|
|
783
|
+
};
|
|
784
|
+
bg: string;
|
|
785
|
+
border: string;
|
|
786
|
+
borderColor: string;
|
|
787
|
+
height: string;
|
|
788
|
+
padding: string;
|
|
789
|
+
'&.is-hovered': {
|
|
790
|
+
textDecoration: string;
|
|
791
|
+
};
|
|
792
|
+
fontSize: string;
|
|
793
|
+
fontWeight: number;
|
|
794
|
+
fontFamily: string;
|
|
795
|
+
overflowWrap: import("../..").overflowWrap;
|
|
796
|
+
maxWidth: string;
|
|
797
|
+
wordWrap: import("../..").wordWrap;
|
|
798
|
+
wordBreak: import("../..").wordBreak;
|
|
799
|
+
cursor: string;
|
|
800
|
+
minWidth: string;
|
|
801
|
+
outline: string;
|
|
802
|
+
alignItems: string;
|
|
803
|
+
borderRadius: string;
|
|
804
|
+
flexShrink: number;
|
|
805
|
+
whiteSpace: string;
|
|
806
|
+
};
|
|
727
807
|
listBoxLink: {
|
|
728
808
|
lineHeight: string;
|
|
729
809
|
textDecoration: string;
|
|
@@ -12,7 +12,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
12
12
|
_Object$defineProperty(exports, "__esModule", {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
exports.text = exports.selectLink = exports.quiet = exports.link = exports.focusWithCroppedOutline = exports.defaultHover = exports.defaultFocus = exports.defaultActive = exports["default"] = exports.base = void 0;
|
|
15
|
+
exports.text = exports.selectLink = exports.quiet = exports.link = exports.focusWithCroppedOutline = exports.defaultHover = exports.defaultFocus = exports.defaultActive = exports["default"] = exports.criticalLink = exports.base = void 0;
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
17
17
|
var _Text = require("../Text/Text.styles");
|
|
18
18
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -181,6 +181,9 @@ var link = exports.link = _objectSpread(_objectSpread({}, text), {}, {
|
|
|
181
181
|
},
|
|
182
182
|
'&.is-focused': _objectSpread({}, focusWithCroppedOutline)
|
|
183
183
|
});
|
|
184
|
+
var criticalLink = exports.criticalLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
185
|
+
color: 'critical.bright'
|
|
186
|
+
});
|
|
184
187
|
var selectLink = exports.selectLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
185
188
|
textDecoration: 'none',
|
|
186
189
|
'&.is-hovered': {
|
|
@@ -336,6 +339,7 @@ var _default = exports["default"] = {
|
|
|
336
339
|
inlinePrimaryWithIcon: inlinePrimaryWithIcon,
|
|
337
340
|
inlineWithIcon: inlineWithIcon,
|
|
338
341
|
link: link,
|
|
342
|
+
criticalLink: criticalLink,
|
|
339
343
|
listBoxLink: listBoxLink,
|
|
340
344
|
paginationMenu: paginationMenu,
|
|
341
345
|
primary: primary,
|
|
@@ -21,7 +21,7 @@ var _pressAttributes = require("../../utils/docUtils/pressAttributes");
|
|
|
21
21
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
23
|
// add designer approved variants for devs to use here
|
|
24
|
-
var variantOptions = ['critical', 'default', 'inline', 'inlinePrimary', 'link', 'primary'];
|
|
24
|
+
var variantOptions = ['critical', 'criticalLink', 'default', 'inline', 'inlinePrimary', 'link', 'primary'];
|
|
25
25
|
var descriptions = {
|
|
26
26
|
children: 'Button text.',
|
|
27
27
|
isDisabled: 'Whether the button is disabled.',
|
|
@@ -15,6 +15,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
exports["default"] = void 0;
|
|
18
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
18
19
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
19
20
|
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectDestructuringEmpty"));
|
|
20
21
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
@@ -31,6 +32,7 @@ var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
|
|
31
32
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
|
32
33
|
var _SelectFieldBase = _interopRequireDefault(require("../SelectFieldBase"));
|
|
33
34
|
var _react2 = require("@emotion/react");
|
|
35
|
+
var _excluded = ["sx"];
|
|
34
36
|
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
35
37
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
38
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -40,10 +42,11 @@ var LinkSelectField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
40
42
|
isDisabled = props.isDisabled,
|
|
41
43
|
status = props.status,
|
|
42
44
|
helperText = props.helperText,
|
|
43
|
-
iconProps = props.iconProps,
|
|
44
45
|
hasInlineLoader = props.hasInlineLoader,
|
|
45
46
|
popoverWidth = props.popoverWidth,
|
|
46
|
-
|
|
47
|
+
iconProps = props.iconProps,
|
|
48
|
+
triggerProps = props.triggerProps,
|
|
49
|
+
triggerProp = props.trigger;
|
|
47
50
|
var _getAriaAttributeProp = (0, _ariaAttributes.getAriaAttributeProps)(props),
|
|
48
51
|
ariaProps = _getAriaAttributeProp.ariaProps;
|
|
49
52
|
var _useGetTheme = (0, _hooks.useGetTheme)(),
|
|
@@ -67,7 +70,10 @@ var LinkSelectField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
67
70
|
state = selectFieldProps.state,
|
|
68
71
|
raTriggerProps = selectFieldProps.triggerProps,
|
|
69
72
|
triggerRef = selectFieldProps.triggerRef;
|
|
70
|
-
var
|
|
73
|
+
var _ref = iconProps || {},
|
|
74
|
+
iconPropsSx = _ref.sx,
|
|
75
|
+
restIconProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
76
|
+
var triggerNode = (0, _react2.jsx)(_.Button, (0, _extends2["default"])({
|
|
71
77
|
className: fieldControlInputProps.className,
|
|
72
78
|
ref: triggerRef,
|
|
73
79
|
variant: "selectLink",
|
|
@@ -87,23 +93,25 @@ var LinkSelectField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
87
93
|
variant: "forms.select.arrow"
|
|
88
94
|
}, (0, _react2.jsx)(_.Icon, (0, _extends2["default"])({
|
|
89
95
|
icon: MenuDown,
|
|
96
|
+
title: {
|
|
97
|
+
name: 'Menu Down Icon'
|
|
98
|
+
},
|
|
99
|
+
sx: _objectSpread(_objectSpread({}, state.isOpen ? {
|
|
100
|
+
transform: 'rotate(180deg)'
|
|
101
|
+
} : null), iconPropsSx)
|
|
102
|
+
}, restIconProps, {
|
|
90
103
|
title: {
|
|
91
104
|
name: ''
|
|
92
105
|
},
|
|
93
106
|
color: isOnyx ? 'font.link' : 'active',
|
|
94
107
|
size: linkSelectFieldIcon,
|
|
95
108
|
"aria-hidden": "true"
|
|
96
|
-
}, iconProps, {
|
|
97
|
-
sx: _objectSpread({
|
|
98
|
-
transform: state.isOpen ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
99
|
-
transition: 'transform 150ms ease'
|
|
100
|
-
}, iconProps === null || iconProps === void 0 ? void 0 : iconProps.sx)
|
|
101
109
|
})))), (0, _react2.jsx)(_reactAria.VisuallyHidden, {
|
|
102
110
|
"aria-live": "polite",
|
|
103
111
|
id: helperTextId
|
|
104
112
|
}, helperText));
|
|
105
113
|
return (0, _react2.jsx)(_SelectFieldBase["default"], (0, _extends2["default"])({}, props, selectFieldProps, {
|
|
106
|
-
trigger:
|
|
114
|
+
trigger: triggerProp || triggerNode
|
|
107
115
|
}));
|
|
108
116
|
});
|
|
109
117
|
LinkSelectField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
|
@@ -172,8 +180,19 @@ LinkSelectField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
|
|
172
180
|
onSelectionChange: _propTypes["default"].func,
|
|
173
181
|
/** Display an inline loader inside the select trigger while loading. */
|
|
174
182
|
hasInlineLoader: _propTypes["default"].bool,
|
|
183
|
+
/**
|
|
184
|
+
* Props object that is spread directly into the Icon inside the default trigger button.
|
|
185
|
+
* Supports all IconProps (icon, title, size, color, sx, etc.).
|
|
186
|
+
* The sx prop is merged with the rotation style.
|
|
187
|
+
*/
|
|
188
|
+
iconProps: _propTypes["default"].shape({}),
|
|
175
189
|
/** Width of the popover menu. Accepts any valid CSS unit. */
|
|
176
|
-
popoverWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])
|
|
190
|
+
popoverWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
191
|
+
/**
|
|
192
|
+
* A ReactNode that replaces the default Button trigger entirely.
|
|
193
|
+
* When provided, the local Button element is not rendered.
|
|
194
|
+
*/
|
|
195
|
+
trigger: _propTypes["default"].node
|
|
177
196
|
}, _statusProp.statusPropTypes), _fieldAttributes.inputFieldAttributesBasePropTypes), _ariaAttributes.ariaAttributesBasePropTypes);
|
|
178
197
|
LinkSelectField.defaultProps = _objectSpread({
|
|
179
198
|
placeholder: 'Select',
|
|
@@ -23,7 +23,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
23
23
|
_Object$defineProperty(exports, "__esModule", {
|
|
24
24
|
value: true
|
|
25
25
|
});
|
|
26
|
-
exports["default"] = exports.WithPopoverWidth = exports.WithNoneOption = exports.NoOptionsAvailable = exports.LeftLabel = exports.HelperText = exports.DynamicItems = exports.DisabledOptions = exports.DisabledField = exports.Default = exports.Controlled = exports.AsyncLoading = void 0;
|
|
26
|
+
exports["default"] = exports.WithPopoverWidth = exports.WithNoneOption = exports.WithIconProps = exports.WithCustomTrigger = exports.NoOptionsAvailable = exports.LeftLabel = exports.HelperText = exports.DynamicItems = exports.DisabledOptions = exports.DisabledField = exports.Default = exports.Controlled = exports.AsyncLoading = void 0;
|
|
27
27
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
28
28
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
29
29
|
var _fill = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/fill"));
|
|
@@ -32,6 +32,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
|
32
32
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
33
33
|
var _react = _interopRequireWildcard(require("react"));
|
|
34
34
|
var _reactAria = require("react-aria");
|
|
35
|
+
var _EarthIcon = _interopRequireDefault(require("@pingux/mdi-react/EarthIcon"));
|
|
35
36
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
|
36
37
|
var _users = require("../../api/users");
|
|
37
38
|
var _index = require("../../index");
|
|
@@ -94,6 +95,14 @@ var _default = exports["default"] = {
|
|
|
94
95
|
isRequired: {},
|
|
95
96
|
selectedKey: {
|
|
96
97
|
control: false
|
|
98
|
+
},
|
|
99
|
+
iconProps: {
|
|
100
|
+
control: false,
|
|
101
|
+
description: 'Props object spread into the Icon inside the default trigger button. Supports icon, title, size, color, sx, and other IconProps. The sx prop is merged with the rotation style.'
|
|
102
|
+
},
|
|
103
|
+
trigger: {
|
|
104
|
+
control: false,
|
|
105
|
+
description: 'A ReactNode that replaces the default Button trigger entirely. When provided, the local Button element is not rendered.'
|
|
97
106
|
}
|
|
98
107
|
}, _statusProp.statusArgTypes), _ariaAttributes.ariaAttributeBaseArgTypes), _fieldAttributes.inputFieldAttributeBaseArgTypes),
|
|
99
108
|
args: {
|
|
@@ -352,4 +361,49 @@ WithPopoverWidth.parameters = {
|
|
|
352
361
|
story: 'The `popoverWidth` prop can be used to set a custom width for the dropdown/popover.'
|
|
353
362
|
}
|
|
354
363
|
}
|
|
364
|
+
};
|
|
365
|
+
var WithIconProps = exports.WithIconProps = function WithIconProps() {
|
|
366
|
+
return (0, _react2.jsx)(_reactAria.OverlayProvider, null, (0, _react2.jsx)(_index.LinkSelectField, {
|
|
367
|
+
label: "What's your favorite color?",
|
|
368
|
+
iconProps: {
|
|
369
|
+
icon: _EarthIcon["default"],
|
|
370
|
+
sx: {
|
|
371
|
+
color: 'accent.40'
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}, (0, _react2.jsx)(_index.Item, {
|
|
375
|
+
key: "red"
|
|
376
|
+
}, "Red"), (0, _react2.jsx)(_index.Item, {
|
|
377
|
+
key: "blue"
|
|
378
|
+
}, "Blue"), (0, _react2.jsx)(_index.Item, {
|
|
379
|
+
key: "yellow"
|
|
380
|
+
}, "Yellow")));
|
|
381
|
+
};
|
|
382
|
+
WithIconProps.parameters = {
|
|
383
|
+
docs: {
|
|
384
|
+
description: {
|
|
385
|
+
story: 'Use the `iconProps` prop to customize the icon inside the default trigger button. Here a different icon and custom `sx` color are passed via `iconProps`.'
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
var WithCustomTrigger = exports.WithCustomTrigger = function WithCustomTrigger() {
|
|
390
|
+
return (0, _react2.jsx)(_reactAria.OverlayProvider, null, (0, _react2.jsx)(_index.LinkSelectField, {
|
|
391
|
+
label: "What's your favorite color?",
|
|
392
|
+
trigger: (0, _react2.jsx)(_index.Button, {
|
|
393
|
+
variant: "primary"
|
|
394
|
+
}, "Open menu")
|
|
395
|
+
}, (0, _react2.jsx)(_index.Item, {
|
|
396
|
+
key: "red"
|
|
397
|
+
}, "Red"), (0, _react2.jsx)(_index.Item, {
|
|
398
|
+
key: "blue"
|
|
399
|
+
}, "Blue"), (0, _react2.jsx)(_index.Item, {
|
|
400
|
+
key: "yellow"
|
|
401
|
+
}, "Yellow")));
|
|
402
|
+
};
|
|
403
|
+
WithCustomTrigger.parameters = {
|
|
404
|
+
docs: {
|
|
405
|
+
description: {
|
|
406
|
+
story: 'Use the `trigger` prop to supply a fully custom ReactNode trigger, replacing the default `Button` element entirely.'
|
|
407
|
+
}
|
|
408
|
+
}
|
|
355
409
|
};
|
|
@@ -15,6 +15,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
15
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
16
16
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
17
17
|
var _react = _interopRequireDefault(require("react"));
|
|
18
|
+
var _EarthIcon = _interopRequireDefault(require("@pingux/mdi-react/EarthIcon"));
|
|
18
19
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
19
20
|
var _index = require("../../index");
|
|
20
21
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
|
@@ -231,23 +232,47 @@ test('passing helper text should display it and correct aria attributes on input
|
|
|
231
232
|
var helperTextID = helper.getAttribute('id');
|
|
232
233
|
expect(_testWrapper.screen.getByRole('button')).toHaveAttribute('aria-describedby', helperTextID);
|
|
233
234
|
});
|
|
234
|
-
test('iconProps
|
|
235
|
-
var iconTestId = 'custom-icon';
|
|
235
|
+
test('iconProps data-testid is applied to the inner Icon element', function () {
|
|
236
236
|
getComponent({
|
|
237
237
|
iconProps: {
|
|
238
|
-
'data-testid':
|
|
238
|
+
'data-testid': 'custom-icon',
|
|
239
|
+
sx: {
|
|
240
|
+
color: 'red'
|
|
241
|
+
}
|
|
239
242
|
}
|
|
240
243
|
});
|
|
241
|
-
|
|
244
|
+
var icon = _testWrapper.screen.getByTestId('custom-icon');
|
|
245
|
+
expect(icon).toBeInTheDocument();
|
|
246
|
+
expect(icon).toBeInstanceOf(SVGSVGElement);
|
|
242
247
|
});
|
|
243
|
-
test('
|
|
248
|
+
test('iconProps with a custom icon renders the substitute icon without throwing', function () {
|
|
244
249
|
getComponent({
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
iconProps: {
|
|
251
|
+
icon: _EarthIcon["default"]
|
|
247
252
|
}
|
|
248
253
|
});
|
|
254
|
+
// The default trigger button is still present when only iconProps is provided
|
|
255
|
+
var button = _testWrapper.screen.getByRole('button');
|
|
256
|
+
expect(button).toBeInTheDocument();
|
|
257
|
+
});
|
|
258
|
+
test('trigger prop replaces the default Button trigger', function () {
|
|
259
|
+
getComponent({
|
|
260
|
+
trigger: (0, _react2.jsx)("button", {
|
|
261
|
+
type: "button",
|
|
262
|
+
"data-testid": "custom-trigger"
|
|
263
|
+
}, "Custom")
|
|
264
|
+
});
|
|
265
|
+
expect(_testWrapper.screen.getByTestId('custom-trigger')).toBeInTheDocument();
|
|
266
|
+
// The default Button trigger (identified by its pendo data attribute) should not be rendered
|
|
267
|
+
expect(document.querySelector('[data-pendo-id="LinkSelectField"]')).not.toBeInTheDocument();
|
|
268
|
+
});
|
|
269
|
+
test('default render is unchanged when neither iconProps nor trigger is provided', function () {
|
|
270
|
+
getComponent();
|
|
271
|
+
// The default trigger button is present via getByRole
|
|
249
272
|
var button = _testWrapper.screen.getByRole('button');
|
|
250
|
-
expect(button).
|
|
273
|
+
expect(button).toBeInTheDocument();
|
|
274
|
+
// The default button has the pendo ID set by the component
|
|
275
|
+
expect(document.querySelector('[data-pendo-id="LinkSelectField"]')).toBeInTheDocument();
|
|
251
276
|
});
|
|
252
277
|
|
|
253
278
|
// Needs to be added to each components test file
|
|
@@ -189,6 +189,19 @@ declare const buttons: {
|
|
|
189
189
|
outline: string;
|
|
190
190
|
};
|
|
191
191
|
};
|
|
192
|
+
criticalLink: {
|
|
193
|
+
color: any;
|
|
194
|
+
'&.is-pressed': {
|
|
195
|
+
textDecoration: string;
|
|
196
|
+
outline: string;
|
|
197
|
+
color: string;
|
|
198
|
+
};
|
|
199
|
+
'&.is-focused': {
|
|
200
|
+
textDecoration: string;
|
|
201
|
+
color: string;
|
|
202
|
+
outline: string;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
192
205
|
iconButtons: {
|
|
193
206
|
base: {
|
|
194
207
|
path: {
|
|
@@ -290,6 +290,19 @@ var buttons = {
|
|
|
290
290
|
outline: 'none'
|
|
291
291
|
}
|
|
292
292
|
},
|
|
293
|
+
criticalLink: {
|
|
294
|
+
color: _onyxTokens.astroTokensDark.color.red[400],
|
|
295
|
+
'&.is-pressed': {
|
|
296
|
+
textDecoration: 'underline',
|
|
297
|
+
outline: 'none',
|
|
298
|
+
color: _chromaJs["default"].mix(_onyxTokens.astroTokensDark.color.red[500], 'white', 0.45, 'rgb').hex()
|
|
299
|
+
},
|
|
300
|
+
'&.is-focused': {
|
|
301
|
+
textDecoration: 'underline',
|
|
302
|
+
color: _chromaJs["default"].mix(_onyxTokens.astroTokensDark.color.red[500], 'white', 0.3, 'rgb').hex(),
|
|
303
|
+
outline: 'none'
|
|
304
|
+
}
|
|
305
|
+
},
|
|
293
306
|
iconButtons: iconButtons,
|
|
294
307
|
searchNavTabLabel: searchNavTabLabel,
|
|
295
308
|
modalCloseButton: modalCloseButton,
|
|
@@ -118,7 +118,9 @@ var forms = {
|
|
|
118
118
|
'& input[type=search]': _objectSpread(_objectSpread({}, _nextGenDarkMode["default"].text.inputValue), {}, {
|
|
119
119
|
borderColor: _onyxTokens.astroTokensDark.color.gray[500],
|
|
120
120
|
fontSize: '15px',
|
|
121
|
-
bg:
|
|
121
|
+
bg: _onyxTokens.astroTokensDark.color.gray[900],
|
|
122
|
+
height: '50px',
|
|
123
|
+
borderRadius: '4px',
|
|
122
124
|
'::placeholder': _objectSpread(_objectSpread({}, _nextGenDarkMode["default"].text.placeholder), {}, {
|
|
123
125
|
fontStyle: 'unset',
|
|
124
126
|
fontSize: '15px'
|
|
@@ -794,6 +794,22 @@ declare const _default: {
|
|
|
794
794
|
outline: string;
|
|
795
795
|
};
|
|
796
796
|
};
|
|
797
|
+
criticalLink: {
|
|
798
|
+
color: string;
|
|
799
|
+
'&.is-pressed': {
|
|
800
|
+
textDecoration: string;
|
|
801
|
+
outline: string;
|
|
802
|
+
};
|
|
803
|
+
transition: string;
|
|
804
|
+
fontSize: string;
|
|
805
|
+
textDecoration: string;
|
|
806
|
+
px: string;
|
|
807
|
+
py: string;
|
|
808
|
+
'&.is-focused': {
|
|
809
|
+
textDecoration: string;
|
|
810
|
+
outline: string;
|
|
811
|
+
};
|
|
812
|
+
};
|
|
797
813
|
listBoxLink: {
|
|
798
814
|
color: string;
|
|
799
815
|
transition: string;
|
|
@@ -490,6 +490,22 @@ declare const buttons: {
|
|
|
490
490
|
outline: string;
|
|
491
491
|
};
|
|
492
492
|
};
|
|
493
|
+
criticalLink: {
|
|
494
|
+
color: string;
|
|
495
|
+
'&.is-pressed': {
|
|
496
|
+
textDecoration: string;
|
|
497
|
+
outline: string;
|
|
498
|
+
};
|
|
499
|
+
transition: string;
|
|
500
|
+
fontSize: string;
|
|
501
|
+
textDecoration: string;
|
|
502
|
+
px: string;
|
|
503
|
+
py: string;
|
|
504
|
+
'&.is-focused': {
|
|
505
|
+
textDecoration: string;
|
|
506
|
+
outline: string;
|
|
507
|
+
};
|
|
508
|
+
};
|
|
493
509
|
listBoxLink: {
|
|
494
510
|
color: string;
|
|
495
511
|
transition: string;
|
|
@@ -249,6 +249,13 @@ var link = {
|
|
|
249
249
|
outline: 'none'
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
+
var criticalLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
253
|
+
color: 'critical.bright',
|
|
254
|
+
'&.is-pressed': {
|
|
255
|
+
textDecoration: 'underline',
|
|
256
|
+
outline: 'none'
|
|
257
|
+
}
|
|
258
|
+
});
|
|
252
259
|
var selectLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
253
260
|
textDecoration: 'none',
|
|
254
261
|
px: '0',
|
|
@@ -628,6 +635,7 @@ var buttons = {
|
|
|
628
635
|
searchNavTabLabel: searchNavTabLabel,
|
|
629
636
|
outlineCritical: outlineCritical,
|
|
630
637
|
link: link,
|
|
638
|
+
criticalLink: criticalLink,
|
|
631
639
|
listBoxLink: listBoxLink,
|
|
632
640
|
withIcon: withIcon,
|
|
633
641
|
primaryWithIcon: primaryWithIcon,
|
|
@@ -68,6 +68,11 @@ Critical.parameters = {
|
|
|
68
68
|
url: FIGMA_LINKS.button.critical
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
+
export var CriticalLink = function CriticalLink(args) {
|
|
72
|
+
return ___EmotionJSX(Button, _extends({}, args, {
|
|
73
|
+
variant: "criticalLink"
|
|
74
|
+
}), "Button Text");
|
|
75
|
+
};
|
|
71
76
|
export var InlineButton = function InlineButton(args) {
|
|
72
77
|
return ___EmotionJSX(Box, null, ___EmotionJSX(Button, _extends({}, args, {
|
|
73
78
|
mb: "sm",
|
|
@@ -174,6 +174,9 @@ export var link = _objectSpread(_objectSpread({}, text), {}, {
|
|
|
174
174
|
},
|
|
175
175
|
'&.is-focused': _objectSpread({}, focusWithCroppedOutline)
|
|
176
176
|
});
|
|
177
|
+
export var criticalLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
178
|
+
color: 'critical.bright'
|
|
179
|
+
});
|
|
177
180
|
export var selectLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
178
181
|
textDecoration: 'none',
|
|
179
182
|
'&.is-hovered': {
|
|
@@ -329,6 +332,7 @@ export default {
|
|
|
329
332
|
inlinePrimaryWithIcon: inlinePrimaryWithIcon,
|
|
330
333
|
inlineWithIcon: inlineWithIcon,
|
|
331
334
|
link: link,
|
|
335
|
+
criticalLink: criticalLink,
|
|
332
336
|
listBoxLink: listBoxLink,
|
|
333
337
|
paginationMenu: paginationMenu,
|
|
334
338
|
primary: primary,
|
|
@@ -14,7 +14,7 @@ import { booleanArg } from '../../utils/docUtils/docArgTypes';
|
|
|
14
14
|
import { onHoverArgTypes } from '../../utils/docUtils/hoverProps';
|
|
15
15
|
import { onPressArgTypes } from '../../utils/docUtils/pressAttributes';
|
|
16
16
|
// add designer approved variants for devs to use here
|
|
17
|
-
var variantOptions = ['critical', 'default', 'inline', 'inlinePrimary', 'link', 'primary'];
|
|
17
|
+
var variantOptions = ['critical', 'criticalLink', 'default', 'inline', 'inlinePrimary', 'link', 'primary'];
|
|
18
18
|
var descriptions = {
|
|
19
19
|
children: 'Button text.',
|
|
20
20
|
isDisabled: 'Whether the button is disabled.',
|
|
@@ -6,9 +6,11 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
|
|
|
6
6
|
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
7
7
|
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
8
8
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
9
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
9
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
10
11
|
import _objectDestructuringEmpty from "@babel/runtime-corejs3/helpers/esm/objectDestructuringEmpty";
|
|
11
12
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
13
|
+
var _excluded = ["sx"];
|
|
12
14
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
16
|
import React, { forwardRef } from 'react';
|
|
@@ -30,10 +32,11 @@ var LinkSelectField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
30
32
|
isDisabled = props.isDisabled,
|
|
31
33
|
status = props.status,
|
|
32
34
|
helperText = props.helperText,
|
|
33
|
-
iconProps = props.iconProps,
|
|
34
35
|
hasInlineLoader = props.hasInlineLoader,
|
|
35
36
|
popoverWidth = props.popoverWidth,
|
|
36
|
-
|
|
37
|
+
iconProps = props.iconProps,
|
|
38
|
+
triggerProps = props.triggerProps,
|
|
39
|
+
triggerProp = props.trigger;
|
|
37
40
|
var _getAriaAttributeProp = getAriaAttributeProps(props),
|
|
38
41
|
ariaProps = _getAriaAttributeProp.ariaProps;
|
|
39
42
|
var _useGetTheme = useGetTheme(),
|
|
@@ -57,7 +60,10 @@ var LinkSelectField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
57
60
|
state = selectFieldProps.state,
|
|
58
61
|
raTriggerProps = selectFieldProps.triggerProps,
|
|
59
62
|
triggerRef = selectFieldProps.triggerRef;
|
|
60
|
-
var
|
|
63
|
+
var _ref = iconProps || {},
|
|
64
|
+
iconPropsSx = _ref.sx,
|
|
65
|
+
restIconProps = _objectWithoutProperties(_ref, _excluded);
|
|
66
|
+
var triggerNode = ___EmotionJSX(Button, _extends({
|
|
61
67
|
className: fieldControlInputProps.className,
|
|
62
68
|
ref: triggerRef,
|
|
63
69
|
variant: "selectLink",
|
|
@@ -77,23 +83,25 @@ var LinkSelectField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
77
83
|
variant: "forms.select.arrow"
|
|
78
84
|
}, ___EmotionJSX(Icon, _extends({
|
|
79
85
|
icon: MenuDown,
|
|
86
|
+
title: {
|
|
87
|
+
name: 'Menu Down Icon'
|
|
88
|
+
},
|
|
89
|
+
sx: _objectSpread(_objectSpread({}, state.isOpen ? {
|
|
90
|
+
transform: 'rotate(180deg)'
|
|
91
|
+
} : null), iconPropsSx)
|
|
92
|
+
}, restIconProps, {
|
|
80
93
|
title: {
|
|
81
94
|
name: ''
|
|
82
95
|
},
|
|
83
96
|
color: isOnyx ? 'font.link' : 'active',
|
|
84
97
|
size: linkSelectFieldIcon,
|
|
85
98
|
"aria-hidden": "true"
|
|
86
|
-
}, iconProps, {
|
|
87
|
-
sx: _objectSpread({
|
|
88
|
-
transform: state.isOpen ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
89
|
-
transition: 'transform 150ms ease'
|
|
90
|
-
}, iconProps === null || iconProps === void 0 ? void 0 : iconProps.sx)
|
|
91
99
|
})))), ___EmotionJSX(VisuallyHidden, {
|
|
92
100
|
"aria-live": "polite",
|
|
93
101
|
id: helperTextId
|
|
94
102
|
}, helperText));
|
|
95
103
|
return ___EmotionJSX(SelectFieldBase, _extends({}, props, selectFieldProps, {
|
|
96
|
-
trigger:
|
|
104
|
+
trigger: triggerProp || triggerNode
|
|
97
105
|
}));
|
|
98
106
|
});
|
|
99
107
|
LinkSelectField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
|
@@ -162,8 +170,19 @@ LinkSelectField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
|
|
162
170
|
onSelectionChange: PropTypes.func,
|
|
163
171
|
/** Display an inline loader inside the select trigger while loading. */
|
|
164
172
|
hasInlineLoader: PropTypes.bool,
|
|
173
|
+
/**
|
|
174
|
+
* Props object that is spread directly into the Icon inside the default trigger button.
|
|
175
|
+
* Supports all IconProps (icon, title, size, color, sx, etc.).
|
|
176
|
+
* The sx prop is merged with the rotation style.
|
|
177
|
+
*/
|
|
178
|
+
iconProps: PropTypes.shape({}),
|
|
165
179
|
/** Width of the popover menu. Accepts any valid CSS unit. */
|
|
166
|
-
popoverWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
180
|
+
popoverWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
181
|
+
/**
|
|
182
|
+
* A ReactNode that replaces the default Button trigger entirely.
|
|
183
|
+
* When provided, the local Button element is not rendered.
|
|
184
|
+
*/
|
|
185
|
+
trigger: PropTypes.node
|
|
167
186
|
}, statusPropTypes), inputFieldAttributesBasePropTypes), ariaAttributesBasePropTypes);
|
|
168
187
|
LinkSelectField.defaultProps = _objectSpread({
|
|
169
188
|
placeholder: 'Select',
|
|
@@ -36,9 +36,10 @@ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymb
|
|
|
36
36
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
37
37
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
38
38
|
import { OverlayProvider } from 'react-aria';
|
|
39
|
+
import EarthIcon from '@pingux/mdi-react/EarthIcon';
|
|
39
40
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
|
40
41
|
import { getAllUsers } from '../../api/users';
|
|
41
|
-
import { Box, Item, LinkSelectField, Section } from '../../index';
|
|
42
|
+
import { Box, Button, Item, LinkSelectField, Section } from '../../index';
|
|
42
43
|
import { LIMIT } from '../../mocks/constants';
|
|
43
44
|
import { ariaAttributeBaseArgTypes } from '../../utils/docUtils/ariaAttributes';
|
|
44
45
|
import { inputFieldAttributeBaseArgTypes } from '../../utils/docUtils/fieldAttributes';
|
|
@@ -85,6 +86,14 @@ export default {
|
|
|
85
86
|
isRequired: {},
|
|
86
87
|
selectedKey: {
|
|
87
88
|
control: false
|
|
89
|
+
},
|
|
90
|
+
iconProps: {
|
|
91
|
+
control: false,
|
|
92
|
+
description: 'Props object spread into the Icon inside the default trigger button. Supports icon, title, size, color, sx, and other IconProps. The sx prop is merged with the rotation style.'
|
|
93
|
+
},
|
|
94
|
+
trigger: {
|
|
95
|
+
control: false,
|
|
96
|
+
description: 'A ReactNode that replaces the default Button trigger entirely. When provided, the local Button element is not rendered.'
|
|
88
97
|
}
|
|
89
98
|
}, statusArgTypes), ariaAttributeBaseArgTypes), inputFieldAttributeBaseArgTypes),
|
|
90
99
|
args: {
|
|
@@ -343,4 +352,49 @@ WithPopoverWidth.parameters = {
|
|
|
343
352
|
story: 'The `popoverWidth` prop can be used to set a custom width for the dropdown/popover.'
|
|
344
353
|
}
|
|
345
354
|
}
|
|
355
|
+
};
|
|
356
|
+
export var WithIconProps = function WithIconProps() {
|
|
357
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(LinkSelectField, {
|
|
358
|
+
label: "What's your favorite color?",
|
|
359
|
+
iconProps: {
|
|
360
|
+
icon: EarthIcon,
|
|
361
|
+
sx: {
|
|
362
|
+
color: 'accent.40'
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}, ___EmotionJSX(Item, {
|
|
366
|
+
key: "red"
|
|
367
|
+
}, "Red"), ___EmotionJSX(Item, {
|
|
368
|
+
key: "blue"
|
|
369
|
+
}, "Blue"), ___EmotionJSX(Item, {
|
|
370
|
+
key: "yellow"
|
|
371
|
+
}, "Yellow")));
|
|
372
|
+
};
|
|
373
|
+
WithIconProps.parameters = {
|
|
374
|
+
docs: {
|
|
375
|
+
description: {
|
|
376
|
+
story: 'Use the `iconProps` prop to customize the icon inside the default trigger button. Here a different icon and custom `sx` color are passed via `iconProps`.'
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
export var WithCustomTrigger = function WithCustomTrigger() {
|
|
381
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(LinkSelectField, {
|
|
382
|
+
label: "What's your favorite color?",
|
|
383
|
+
trigger: ___EmotionJSX(Button, {
|
|
384
|
+
variant: "primary"
|
|
385
|
+
}, "Open menu")
|
|
386
|
+
}, ___EmotionJSX(Item, {
|
|
387
|
+
key: "red"
|
|
388
|
+
}, "Red"), ___EmotionJSX(Item, {
|
|
389
|
+
key: "blue"
|
|
390
|
+
}, "Blue"), ___EmotionJSX(Item, {
|
|
391
|
+
key: "yellow"
|
|
392
|
+
}, "Yellow")));
|
|
393
|
+
};
|
|
394
|
+
WithCustomTrigger.parameters = {
|
|
395
|
+
docs: {
|
|
396
|
+
description: {
|
|
397
|
+
story: 'Use the `trigger` prop to supply a fully custom ReactNode trigger, replacing the default `Button` element entirely.'
|
|
398
|
+
}
|
|
399
|
+
}
|
|
346
400
|
};
|
|
@@ -21,6 +21,7 @@ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present,
|
|
|
21
21
|
function _regeneratorDefine2(e, r, n, t) { var i = _Object$defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
22
22
|
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
23
23
|
import React from 'react';
|
|
24
|
+
import EarthIcon from '@pingux/mdi-react/EarthIcon';
|
|
24
25
|
import userEvent from '@testing-library/user-event';
|
|
25
26
|
import { Item, LinkSelectField } from '../../index';
|
|
26
27
|
import statuses from '../../utils/devUtils/constants/statuses';
|
|
@@ -228,23 +229,47 @@ test('passing helper text should display it and correct aria attributes on input
|
|
|
228
229
|
var helperTextID = helper.getAttribute('id');
|
|
229
230
|
expect(screen.getByRole('button')).toHaveAttribute('aria-describedby', helperTextID);
|
|
230
231
|
});
|
|
231
|
-
test('iconProps
|
|
232
|
-
var iconTestId = 'custom-icon';
|
|
232
|
+
test('iconProps data-testid is applied to the inner Icon element', function () {
|
|
233
233
|
getComponent({
|
|
234
234
|
iconProps: {
|
|
235
|
-
'data-testid':
|
|
235
|
+
'data-testid': 'custom-icon',
|
|
236
|
+
sx: {
|
|
237
|
+
color: 'red'
|
|
238
|
+
}
|
|
236
239
|
}
|
|
237
240
|
});
|
|
238
|
-
|
|
241
|
+
var icon = screen.getByTestId('custom-icon');
|
|
242
|
+
expect(icon).toBeInTheDocument();
|
|
243
|
+
expect(icon).toBeInstanceOf(SVGSVGElement);
|
|
239
244
|
});
|
|
240
|
-
test('
|
|
245
|
+
test('iconProps with a custom icon renders the substitute icon without throwing', function () {
|
|
241
246
|
getComponent({
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
iconProps: {
|
|
248
|
+
icon: EarthIcon
|
|
244
249
|
}
|
|
245
250
|
});
|
|
251
|
+
// The default trigger button is still present when only iconProps is provided
|
|
252
|
+
var button = screen.getByRole('button');
|
|
253
|
+
expect(button).toBeInTheDocument();
|
|
254
|
+
});
|
|
255
|
+
test('trigger prop replaces the default Button trigger', function () {
|
|
256
|
+
getComponent({
|
|
257
|
+
trigger: ___EmotionJSX("button", {
|
|
258
|
+
type: "button",
|
|
259
|
+
"data-testid": "custom-trigger"
|
|
260
|
+
}, "Custom")
|
|
261
|
+
});
|
|
262
|
+
expect(screen.getByTestId('custom-trigger')).toBeInTheDocument();
|
|
263
|
+
// The default Button trigger (identified by its pendo data attribute) should not be rendered
|
|
264
|
+
expect(document.querySelector('[data-pendo-id="LinkSelectField"]')).not.toBeInTheDocument();
|
|
265
|
+
});
|
|
266
|
+
test('default render is unchanged when neither iconProps nor trigger is provided', function () {
|
|
267
|
+
getComponent();
|
|
268
|
+
// The default trigger button is present via getByRole
|
|
246
269
|
var button = screen.getByRole('button');
|
|
247
|
-
expect(button).
|
|
270
|
+
expect(button).toBeInTheDocument();
|
|
271
|
+
// The default button has the pendo ID set by the component
|
|
272
|
+
expect(document.querySelector('[data-pendo-id="LinkSelectField"]')).toBeInTheDocument();
|
|
248
273
|
});
|
|
249
274
|
|
|
250
275
|
// Needs to be added to each components test file
|
|
@@ -283,6 +283,19 @@ var buttons = {
|
|
|
283
283
|
outline: 'none'
|
|
284
284
|
}
|
|
285
285
|
},
|
|
286
|
+
criticalLink: {
|
|
287
|
+
color: astroTokensDark.color.red[400],
|
|
288
|
+
'&.is-pressed': {
|
|
289
|
+
textDecoration: 'underline',
|
|
290
|
+
outline: 'none',
|
|
291
|
+
color: chroma.mix(astroTokensDark.color.red[500], 'white', 0.45, 'rgb').hex()
|
|
292
|
+
},
|
|
293
|
+
'&.is-focused': {
|
|
294
|
+
textDecoration: 'underline',
|
|
295
|
+
color: chroma.mix(astroTokensDark.color.red[500], 'white', 0.3, 'rgb').hex(),
|
|
296
|
+
outline: 'none'
|
|
297
|
+
}
|
|
298
|
+
},
|
|
286
299
|
iconButtons: iconButtons,
|
|
287
300
|
searchNavTabLabel: searchNavTabLabel,
|
|
288
301
|
modalCloseButton: modalCloseButton,
|
|
@@ -111,7 +111,9 @@ var forms = {
|
|
|
111
111
|
'& input[type=search]': _objectSpread(_objectSpread({}, theme.text.inputValue), {}, {
|
|
112
112
|
borderColor: astroTokensDark.color.gray[500],
|
|
113
113
|
fontSize: '15px',
|
|
114
|
-
bg:
|
|
114
|
+
bg: astroTokensDark.color.gray[900],
|
|
115
|
+
height: '50px',
|
|
116
|
+
borderRadius: '4px',
|
|
115
117
|
'::placeholder': _objectSpread(_objectSpread({}, theme.text.placeholder), {}, {
|
|
116
118
|
fontStyle: 'unset',
|
|
117
119
|
fontSize: '15px'
|
|
@@ -242,6 +242,13 @@ var link = {
|
|
|
242
242
|
outline: 'none'
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
|
+
var criticalLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
246
|
+
color: 'critical.bright',
|
|
247
|
+
'&.is-pressed': {
|
|
248
|
+
textDecoration: 'underline',
|
|
249
|
+
outline: 'none'
|
|
250
|
+
}
|
|
251
|
+
});
|
|
245
252
|
var selectLink = _objectSpread(_objectSpread({}, link), {}, {
|
|
246
253
|
textDecoration: 'none',
|
|
247
254
|
px: '0',
|
|
@@ -621,6 +628,7 @@ var buttons = {
|
|
|
621
628
|
searchNavTabLabel: searchNavTabLabel,
|
|
622
629
|
outlineCritical: outlineCritical,
|
|
623
630
|
link: link,
|
|
631
|
+
criticalLink: criticalLink,
|
|
624
632
|
listBoxLink: listBoxLink,
|
|
625
633
|
withIcon: withIcon,
|
|
626
634
|
primaryWithIcon: primaryWithIcon,
|