@pingux/astro 2.134.0-alpha.0 → 2.134.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/IconButton/IconButton.styles.d.ts +41 -0
- package/lib/cjs/components/IconButton/IconButton.styles.js +14 -1
- package/lib/cjs/components/ListBox/Option.js +11 -2
- package/lib/cjs/components/SelectField/SelectField.stories.d.ts +1 -0
- package/lib/cjs/components/SelectField/SelectField.stories.js +22 -2
- package/lib/cjs/components/SelectField/SelectField.test.js +11 -0
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +48 -27
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.test.js +26 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.d.ts +0 -5
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.js +0 -5
- package/lib/cjs/styles/themes/next-gen/forms.d.ts +22 -0
- package/lib/cjs/styles/themes/next-gen/forms.js +12 -0
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +51 -3
- package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +38 -2
- package/lib/cjs/styles/themes/next-gen/variants/button.js +29 -19
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +2 -1
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +3 -2
- package/lib/cjs/types/selectField.d.ts +5 -0
- package/lib/components/IconButton/IconButton.styles.js +14 -1
- package/lib/components/ListBox/Option.js +12 -3
- package/lib/components/SelectField/SelectField.stories.js +19 -0
- package/lib/components/SelectField/SelectField.test.js +11 -0
- package/lib/components/SelectFieldBase/SelectFieldBase.js +41 -20
- package/lib/components/SelectFieldBase/SelectFieldBase.test.js +26 -0
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/variants.js +0 -5
- package/lib/styles/themes/next-gen/forms.js +12 -0
- package/lib/styles/themes/next-gen/variants/button.js +29 -19
- package/lib/styles/themes/next-gen/variants/variants.js +3 -2
- package/package.json +1 -1
@@ -722,5 +722,46 @@ declare const _default: {
|
|
722
722
|
cursor: string;
|
723
723
|
p: string;
|
724
724
|
};
|
725
|
+
clearSelectionButton: {
|
726
|
+
width: string;
|
727
|
+
height: string;
|
728
|
+
position: string;
|
729
|
+
right: string;
|
730
|
+
top: string;
|
731
|
+
bg: string;
|
732
|
+
'.is-float-label &': {
|
733
|
+
top: string;
|
734
|
+
};
|
735
|
+
justifyContent: string;
|
736
|
+
appearance: string;
|
737
|
+
alignItems: string;
|
738
|
+
alignSelf: string;
|
739
|
+
display: string;
|
740
|
+
flexGrow: number;
|
741
|
+
flexShrink: number;
|
742
|
+
borderRadius: string;
|
743
|
+
cursor: string;
|
744
|
+
p: string;
|
745
|
+
path: {
|
746
|
+
fill: string;
|
747
|
+
};
|
748
|
+
outline: string;
|
749
|
+
'&.is-focused': {
|
750
|
+
outline: string;
|
751
|
+
outlineColor: string;
|
752
|
+
outlineOffset: string;
|
753
|
+
};
|
754
|
+
'&.is-hovered': {
|
755
|
+
bg: string;
|
756
|
+
boxShadow: string;
|
757
|
+
};
|
758
|
+
'&.is-pressed': {
|
759
|
+
path: {
|
760
|
+
fill: string;
|
761
|
+
};
|
762
|
+
bg: string;
|
763
|
+
boxShadow: string;
|
764
|
+
};
|
765
|
+
};
|
725
766
|
};
|
726
767
|
export default _default;
|
@@ -14,6 +14,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
14
14
|
});
|
15
15
|
exports.square = exports["default"] = exports.base = void 0;
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
17
|
+
var _tShirtSizes = _interopRequireDefault(require("../../styles/themes/astro/customProperties/tShirtSizes"));
|
17
18
|
var _Badge = require("../Badge/Badge.styles");
|
18
19
|
var _Buttons = require("../Button/Buttons.styles");
|
19
20
|
var _CollapsiblePanel = require("../CollapsiblePanel/CollapsiblePanel.styles");
|
@@ -147,6 +148,17 @@ var searchClearButton = _objectSpread(_objectSpread({}, base), {}, {
|
|
147
148
|
position: 'absolute',
|
148
149
|
right: 10
|
149
150
|
});
|
151
|
+
var clearSelectionButton = _objectSpread(_objectSpread({}, base), {}, {
|
152
|
+
width: _tShirtSizes["default"].md,
|
153
|
+
height: _tShirtSizes["default"].md,
|
154
|
+
position: 'absolute',
|
155
|
+
right: '15px',
|
156
|
+
top: '7px',
|
157
|
+
bg: 'white',
|
158
|
+
'.is-float-label &': {
|
159
|
+
top: '9px'
|
160
|
+
}
|
161
|
+
});
|
150
162
|
var filter = _objectSpread(_objectSpread({}, base), {}, {
|
151
163
|
bg: 'white',
|
152
164
|
border: '1px solid',
|
@@ -196,6 +208,7 @@ var _default = {
|
|
196
208
|
applicationPortal: applicationPortal,
|
197
209
|
applicationPortalPinned: applicationPortalPinned,
|
198
210
|
searchClearButton: searchClearButton,
|
199
|
-
filter: filter
|
211
|
+
filter: filter,
|
212
|
+
clearSelectionButton: clearSelectionButton
|
200
213
|
};
|
201
214
|
exports["default"] = _default;
|
@@ -19,6 +19,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
19
19
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
20
20
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
21
21
|
var _react = _interopRequireWildcard(require("react"));
|
22
|
+
var _CheckIcon = _interopRequireDefault(require("@pingux/mdi-react/CheckIcon"));
|
22
23
|
var _CircleSmallIcon = _interopRequireDefault(require("@pingux/mdi-react/CircleSmallIcon"));
|
23
24
|
var _listbox = require("@react-aria/listbox");
|
24
25
|
var _MultivaluesContext = require("../../context/MultivaluesContext");
|
@@ -99,6 +100,8 @@ var Option = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
99
100
|
state.selectionManager.setFocusedKey(item.key);
|
100
101
|
}
|
101
102
|
};
|
103
|
+
var _useGetTheme = (0, _hooks.useGetTheme)(),
|
104
|
+
isOnyx = _useGetTheme.themeState.isOnyx;
|
102
105
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(null, {
|
103
106
|
isDisabled: isDisabled || isSeparator,
|
104
107
|
isFocused: focused,
|
@@ -139,12 +142,18 @@ var Option = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
139
142
|
mr: "xs",
|
140
143
|
className: classNames,
|
141
144
|
variant: "listBox.checkboxIcon"
|
142
|
-
}) : isSelected && (0, _react2.jsx)(_Icon["default"], {
|
145
|
+
}) : isSelected && !isOnyx && (0, _react2.jsx)(_Icon["default"], {
|
143
146
|
icon: _CircleSmallIcon["default"],
|
144
147
|
title: {
|
145
148
|
name: 'Circle Small Icon'
|
146
149
|
}
|
147
|
-
}), rendered)
|
150
|
+
}), rendered, isSelected && isOnyx && (0, _react2.jsx)(_Icon["default"], {
|
151
|
+
icon: _CheckIcon["default"],
|
152
|
+
title: {
|
153
|
+
name: 'Check Icon'
|
154
|
+
},
|
155
|
+
color: "green-500"
|
156
|
+
}));
|
148
157
|
});
|
149
158
|
var _default = Option;
|
150
159
|
exports["default"] = _default;
|
@@ -57,3 +57,4 @@ export declare const DynamicItems: {
|
|
57
57
|
export declare const AsyncLoading: () => React.JSX.Element;
|
58
58
|
export declare const WithoutStatusIndicator: (args: any) => React.JSX.Element;
|
59
59
|
export declare const WithHelpHint: (args: any) => React.JSX.Element;
|
60
|
+
export declare const WithClearButton: (args: any) => React.JSX.Element;
|
@@ -21,7 +21,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
21
21
|
_Object$defineProperty(exports, "__esModule", {
|
22
22
|
value: true
|
23
23
|
});
|
24
|
-
exports["default"] = exports.WithoutStatusIndicator = exports.WithSlots = exports.WithSections = exports.WithNoneOption = exports.WithHelpHint = exports.WithCustomHeight = exports.NoOptionsAvailable = exports.HelperText = exports.FloatLabel = exports.DynamicItems = exports.DisabledOptions = exports.DisabledField = exports.Default = exports.Controlled = exports.AsyncLoading = void 0;
|
24
|
+
exports["default"] = exports.WithoutStatusIndicator = exports.WithSlots = exports.WithSections = exports.WithNoneOption = exports.WithHelpHint = exports.WithCustomHeight = exports.WithClearButton = exports.NoOptionsAvailable = exports.HelperText = exports.FloatLabel = exports.DynamicItems = exports.DisabledOptions = exports.DisabledField = exports.Default = exports.Controlled = exports.AsyncLoading = void 0;
|
25
25
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
26
26
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
27
27
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
@@ -484,4 +484,24 @@ var WithHelpHint = function WithHelpHint(args) {
|
|
484
484
|
key: "yellow"
|
485
485
|
}, "Yellow")));
|
486
486
|
};
|
487
|
-
exports.WithHelpHint = WithHelpHint;
|
487
|
+
exports.WithHelpHint = WithHelpHint;
|
488
|
+
var WithClearButton = function WithClearButton(args) {
|
489
|
+
var _useState5 = (0, _react.useState)('red'),
|
490
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
491
|
+
selectedKey = _useState6[0],
|
492
|
+
setSelectedKey = _useState6[1];
|
493
|
+
return (0, _react2.jsx)(_reactAria.OverlayProvider, null, (0, _react2.jsx)(_index.SelectField, (0, _extends2["default"])({}, args, {
|
494
|
+
width: "100%",
|
495
|
+
label: "What's your favorite color?",
|
496
|
+
hasClearButton: true,
|
497
|
+
selectedKey: selectedKey,
|
498
|
+
onSelectionChange: setSelectedKey
|
499
|
+
}), (0, _react2.jsx)(_index.Item, {
|
500
|
+
key: "red"
|
501
|
+
}, "Red"), (0, _react2.jsx)(_index.Item, {
|
502
|
+
key: "blue"
|
503
|
+
}, "Blue"), (0, _react2.jsx)(_index.Item, {
|
504
|
+
key: "yellow"
|
505
|
+
}, "Yellow")));
|
506
|
+
};
|
507
|
+
exports.WithClearButton = WithClearButton;
|
@@ -194,4 +194,15 @@ test('should show hintText text if prop is passed', function () {
|
|
194
194
|
_testWrapper.fireEvent.mouseMove(helpHintButton);
|
195
195
|
_testWrapper.fireEvent.mouseEnter(helpHintButton);
|
196
196
|
expect(_testWrapper.screen.getByText(hintText)).toBeInTheDocument();
|
197
|
+
});
|
198
|
+
test('should have clear button if hasClearButton prop is true', function () {
|
199
|
+
getComponent({
|
200
|
+
selectedKey: 'a',
|
201
|
+
hasClearButton: true,
|
202
|
+
clearButtonProps: {
|
203
|
+
'data-testid': 'clear-button'
|
204
|
+
}
|
205
|
+
});
|
206
|
+
var clearButton = _testWrapper.screen.getByTestId('clear-button');
|
207
|
+
expect(clearButton).toBeInTheDocument();
|
197
208
|
});
|
@@ -19,21 +19,16 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
19
19
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
20
20
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
21
21
|
var _react = _interopRequireWildcard(require("react"));
|
22
|
+
var _CloseIcon = _interopRequireDefault(require("@pingux/mdi-react/CloseIcon"));
|
22
23
|
var _uuid = require("uuid");
|
24
|
+
var _ = require("../..");
|
23
25
|
var _useGetTheme2 = _interopRequireDefault(require("../../hooks/useGetTheme"));
|
24
26
|
var _labelModes = require("../../utils/devUtils/constants/labelModes");
|
25
27
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
26
28
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
27
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
28
|
-
var _Button = _interopRequireDefault(require("../Button"));
|
29
|
-
var _FieldHelperText = _interopRequireDefault(require("../FieldHelperText"));
|
30
|
-
var _Icon = _interopRequireDefault(require("../Icon"));
|
31
|
-
var _Label = _interopRequireDefault(require("../Label"));
|
32
|
-
var _Loader = _interopRequireDefault(require("../Loader"));
|
33
|
-
var _Text = _interopRequireDefault(require("../Text"));
|
34
29
|
var _HiddenSelect = require("./HiddenSelect");
|
35
30
|
var _react2 = require("@emotion/react");
|
36
|
-
var _excluded = ["columnStyleProps", "defaultText", "fieldContainerProps", "fieldControlInputProps", "fieldControlWrapperProps", "fieldLabelProps", "helperText", "isLoadingInitial", "isDisabled", "label", "labelMode", "name", "overlay", "placeholder", "slots", "state", "status", "trigger", "triggerProps", "triggerRef", "valueProps", "selectProps"];
|
31
|
+
var _excluded = ["columnStyleProps", "defaultText", "fieldContainerProps", "fieldControlInputProps", "fieldControlWrapperProps", "fieldLabelProps", "helperText", "isLoadingInitial", "isDisabled", "label", "labelMode", "name", "overlay", "placeholder", "slots", "state", "status", "trigger", "triggerProps", "triggerRef", "valueProps", "selectProps", "hasClearButton", "clearButtonProps", "onClear"];
|
37
32
|
/**
|
38
33
|
* Select field (dropdown) that does not rely on native browser or mobile implementations.
|
39
34
|
*
|
@@ -68,6 +63,9 @@ var SelectFieldBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
68
63
|
triggerRef = props.triggerRef,
|
69
64
|
valueProps = props.valueProps,
|
70
65
|
selectProps = props.selectProps,
|
66
|
+
hasClearButton = props.hasClearButton,
|
67
|
+
clearButtonProps = props.clearButtonProps,
|
68
|
+
onClear = props.onClear,
|
71
69
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
72
70
|
var _getAriaAttributeProp = (0, _ariaAttributes.getAriaAttributeProps)(others),
|
73
71
|
ariaProps = _getAriaAttributeProp.ariaProps;
|
@@ -78,44 +76,67 @@ var SelectFieldBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
78
76
|
var helperTextId = (0, _react.useMemo)(function () {
|
79
77
|
return (0, _uuid.v4)();
|
80
78
|
}, []);
|
81
|
-
var
|
79
|
+
var handleOnClear = function handleOnClear() {
|
80
|
+
if (onClear) {
|
81
|
+
onClear();
|
82
|
+
}
|
83
|
+
state.setSelectedKey(null);
|
84
|
+
};
|
85
|
+
var buttonRendered = !(hasClearButton && state.selectedKey) && (0, _react2.jsx)(_.Box, {
|
86
|
+
as: "span",
|
87
|
+
"aria-hidden": "true",
|
88
|
+
variant: "forms.select.arrow"
|
89
|
+
}, (0, _react2.jsx)(_.Icon, {
|
90
|
+
icon: state.isOpen ? MenuUp : MenuDown,
|
91
|
+
title: {
|
92
|
+
name: 'Menu down'
|
93
|
+
},
|
94
|
+
size: "md"
|
95
|
+
}));
|
96
|
+
var clearButton = hasClearButton && state.selectedKey && (0, _react2.jsx)(_.IconButton, (0, _extends2["default"])({
|
97
|
+
tabIndex: 0,
|
98
|
+
as: "span",
|
99
|
+
role: "button",
|
100
|
+
"aria-label": "Clear selection",
|
101
|
+
variant: "clearSelectionButton",
|
102
|
+
onPress: handleOnClear,
|
103
|
+
color: "text.secondary"
|
104
|
+
}, clearButtonProps), (0, _react2.jsx)(_.Icon, {
|
105
|
+
icon: _CloseIcon["default"],
|
106
|
+
title: {
|
107
|
+
name: 'Clear selection Icon'
|
108
|
+
}
|
109
|
+
}));
|
110
|
+
var defaultTrigger = (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
111
|
+
isRow: true
|
112
|
+
}, fieldControlWrapperProps, {
|
82
113
|
variant: "forms.input.fieldControlWrapper"
|
83
|
-
}), (0, _react2.jsx)(
|
114
|
+
}), (0, _react2.jsx)(_.Button, (0, _extends2["default"])({
|
84
115
|
className: fieldControlInputProps.className,
|
85
116
|
ref: triggerRef,
|
86
117
|
variant: "forms.select"
|
87
118
|
}, triggerProps, ariaProps, {
|
88
119
|
"aria-describedby": helperText && helperTextId
|
89
|
-
}), slots === null || slots === void 0 ? void 0 : slots.leftOfData, (0, _react2.jsx)(
|
120
|
+
}), slots === null || slots === void 0 ? void 0 : slots.leftOfData, (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
90
121
|
as: "span",
|
91
122
|
variant: "forms.select.currentValue"
|
92
|
-
}, valueProps), state.selectedItem ? state.selectedItem.rendered : (0, _react2.jsx)(
|
123
|
+
}, valueProps), state.selectedItem ? state.selectedItem.rendered : (0, _react2.jsx)(_.Text, {
|
93
124
|
variant: "placeholder"
|
94
|
-
}, labelMode === _labelModes.modes.FLOAT ? '' : placeholder || defaultText)), isLoadingInitial && (0, _react2.jsx)(
|
125
|
+
}, labelMode === _labelModes.modes.FLOAT ? '' : placeholder || defaultText)), isLoadingInitial && (0, _react2.jsx)(_.Loader, {
|
95
126
|
variant: "loader.withinInput"
|
96
|
-
}),
|
97
|
-
|
98
|
-
"aria-hidden": "true",
|
99
|
-
variant: "forms.select.arrow"
|
100
|
-
}, (0, _react2.jsx)(_Icon["default"], {
|
101
|
-
icon: state.isOpen ? MenuUp : MenuDown,
|
102
|
-
title: {
|
103
|
-
name: 'Menu down'
|
104
|
-
},
|
105
|
-
size: "md"
|
106
|
-
}))), slots === null || slots === void 0 ? void 0 : slots.inContainer);
|
107
|
-
return (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
127
|
+
}), buttonRendered), clearButton, slots === null || slots === void 0 ? void 0 : slots.inContainer);
|
128
|
+
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
108
129
|
ref: ref,
|
109
130
|
variant: "forms.input.fieldContainer"
|
110
131
|
}, (0, _pendoID.getPendoID)('SelectField'), fieldContainerProps, {
|
111
132
|
sx: _objectSpread(_objectSpread({}, columnStyleProps === null || columnStyleProps === void 0 ? void 0 : columnStyleProps.sx), fieldContainerProps === null || fieldContainerProps === void 0 ? void 0 : fieldContainerProps.sx)
|
112
|
-
}), (0, _react2.jsx)(
|
133
|
+
}), (0, _react2.jsx)(_.Label, fieldLabelProps, label), (0, _react2.jsx)(_HiddenSelect.HiddenSelect, (0, _extends2["default"])({
|
113
134
|
state: state,
|
114
135
|
triggerRef: triggerRef,
|
115
136
|
label: label,
|
116
137
|
name: name,
|
117
138
|
isDisabled: isDisabled
|
118
|
-
}, selectProps)), trigger || defaultTrigger, overlay, helperText && (0, _react2.jsx)(
|
139
|
+
}, selectProps)), trigger || defaultTrigger, overlay, helperText && (0, _react2.jsx)(_.FieldHelperText, {
|
119
140
|
status: status,
|
120
141
|
id: helperTextId
|
121
142
|
}, helperText));
|
@@ -51,6 +51,7 @@ var defaultProps = {
|
|
51
51
|
value: testValue,
|
52
52
|
items: items
|
53
53
|
};
|
54
|
+
var onClear = jest.fn();
|
54
55
|
var SelectFieldWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
55
56
|
var _useSelectField = (0, _hooks.useSelectField)(props, ref),
|
56
57
|
selectFieldProps = (0, _extends2["default"])({}, ((0, _objectDestructuringEmpty2["default"])(_useSelectField), _useSelectField));
|
@@ -436,4 +437,29 @@ test('popover closes on button blur', function () {
|
|
436
437
|
}, item.name);
|
437
438
|
});
|
438
439
|
}
|
440
|
+
});
|
441
|
+
test('should have clear button if hasClearButton prop is true', function () {
|
442
|
+
getComponent({
|
443
|
+
selectedKey: 'a',
|
444
|
+
hasClearButton: true,
|
445
|
+
clearButtonProps: {
|
446
|
+
'data-testid': 'clear-button'
|
447
|
+
}
|
448
|
+
});
|
449
|
+
var clearButton = _testWrapper.screen.getByTestId('clear-button');
|
450
|
+
expect(clearButton).toBeInTheDocument();
|
451
|
+
});
|
452
|
+
test('should have call onClear function', function () {
|
453
|
+
getComponent({
|
454
|
+
selectedKey: 'a',
|
455
|
+
hasClearButton: true,
|
456
|
+
clearButtonProps: {
|
457
|
+
'data-testid': 'clear-button'
|
458
|
+
},
|
459
|
+
onClear: onClear
|
460
|
+
});
|
461
|
+
var clearButton = _testWrapper.screen.getByTestId('clear-button');
|
462
|
+
expect(clearButton).toBeInTheDocument();
|
463
|
+
_userEvent["default"].click(clearButton);
|
464
|
+
expect(onClear).toHaveBeenCalledTimes(1);
|
439
465
|
});
|
@@ -345,10 +345,6 @@ declare const _default: {
|
|
345
345
|
borderRadius: string;
|
346
346
|
};
|
347
347
|
option: {
|
348
|
-
py: string;
|
349
|
-
pl: string;
|
350
|
-
pr: string;
|
351
|
-
bg: string;
|
352
348
|
'&.is-focused': {
|
353
349
|
color: string;
|
354
350
|
bg: string;
|
@@ -356,7 +352,6 @@ declare const _default: {
|
|
356
352
|
'&.is-selected': {
|
357
353
|
color: string;
|
358
354
|
bg: string;
|
359
|
-
pl: number;
|
360
355
|
'&.is-focused': {
|
361
356
|
color: string;
|
362
357
|
};
|
@@ -23,10 +23,6 @@ var listBox = {
|
|
23
23
|
borderRadius: '4px'
|
24
24
|
},
|
25
25
|
option: {
|
26
|
-
py: '.75rem',
|
27
|
-
pl: '.75rem',
|
28
|
-
pr: '1rem',
|
29
|
-
bg: 'background.base',
|
30
26
|
'&.is-focused': {
|
31
27
|
color: 'text.primary',
|
32
28
|
bg: 'gray-800'
|
@@ -34,7 +30,6 @@ var listBox = {
|
|
34
30
|
'&.is-selected': {
|
35
31
|
color: 'text.primary',
|
36
32
|
bg: 'gray-800',
|
37
|
-
pl: 0,
|
38
33
|
'&.is-focused': {
|
39
34
|
color: 'text.primary'
|
40
35
|
}
|
@@ -20,6 +20,17 @@ export declare const select: {
|
|
20
20
|
currentValue: {
|
21
21
|
color: string;
|
22
22
|
};
|
23
|
+
arrow: {
|
24
|
+
width: string;
|
25
|
+
height: string;
|
26
|
+
alignItems: string;
|
27
|
+
justifyContent: string;
|
28
|
+
'& > svg': {
|
29
|
+
minWidth: string;
|
30
|
+
width: string;
|
31
|
+
height: string;
|
32
|
+
};
|
33
|
+
};
|
23
34
|
};
|
24
35
|
export declare const search: {
|
25
36
|
wrapper: {
|
@@ -148,6 +159,17 @@ declare const _default: {
|
|
148
159
|
currentValue: {
|
149
160
|
color: string;
|
150
161
|
};
|
162
|
+
arrow: {
|
163
|
+
width: string;
|
164
|
+
height: string;
|
165
|
+
alignItems: string;
|
166
|
+
justifyContent: string;
|
167
|
+
'& > svg': {
|
168
|
+
minWidth: string;
|
169
|
+
width: string;
|
170
|
+
height: string;
|
171
|
+
};
|
172
|
+
};
|
151
173
|
};
|
152
174
|
radio: {
|
153
175
|
base: {
|
@@ -15,6 +15,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
15
15
|
exports.select = exports.search = exports.radio = exports.numberField = exports["default"] = exports.comboBox = exports.checkbox = void 0;
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
17
17
|
var _colors = _interopRequireDefault(require("./colors/colors"));
|
18
|
+
var _tShirtSizes = _interopRequireDefault(require("./customProperties/tShirtSizes"));
|
18
19
|
var _input = require("./variants/input");
|
19
20
|
var _label = require("./variants/label");
|
20
21
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -41,6 +42,17 @@ var select = {
|
|
41
42
|
},
|
42
43
|
currentValue: {
|
43
44
|
color: 'text.primary'
|
45
|
+
},
|
46
|
+
arrow: {
|
47
|
+
width: '20px',
|
48
|
+
height: '20px',
|
49
|
+
alignItems: 'center',
|
50
|
+
justifyContent: 'center',
|
51
|
+
'& > svg': {
|
52
|
+
minWidth: _tShirtSizes["default"].xs,
|
53
|
+
width: _tShirtSizes["default"].xs,
|
54
|
+
height: _tShirtSizes["default"].xs
|
55
|
+
}
|
44
56
|
}
|
45
57
|
};
|
46
58
|
exports.select = select;
|
@@ -1316,6 +1316,8 @@ declare const _default: {
|
|
1316
1316
|
width: string;
|
1317
1317
|
height: string;
|
1318
1318
|
border: string;
|
1319
|
+
position: string;
|
1320
|
+
right: string;
|
1319
1321
|
'& > svg': {
|
1320
1322
|
minWidth: string;
|
1321
1323
|
width: string;
|
@@ -1327,8 +1329,6 @@ declare const _default: {
|
|
1327
1329
|
'&.is-pressed': {
|
1328
1330
|
bg: string;
|
1329
1331
|
};
|
1330
|
-
position: string;
|
1331
|
-
right: number;
|
1332
1332
|
cursor: string;
|
1333
1333
|
transition: string;
|
1334
1334
|
outline: string;
|
@@ -1383,6 +1383,42 @@ declare const _default: {
|
|
1383
1383
|
bg: string;
|
1384
1384
|
};
|
1385
1385
|
};
|
1386
|
+
clearSelectionButton: {
|
1387
|
+
top: string;
|
1388
|
+
right: string;
|
1389
|
+
bg: string;
|
1390
|
+
'.is-float-label &': {
|
1391
|
+
top: string;
|
1392
|
+
};
|
1393
|
+
width: string;
|
1394
|
+
height: string;
|
1395
|
+
border: string;
|
1396
|
+
position: string;
|
1397
|
+
'& > svg': {
|
1398
|
+
minWidth: string;
|
1399
|
+
width: string;
|
1400
|
+
height: string;
|
1401
|
+
};
|
1402
|
+
'&.is-hovered': {
|
1403
|
+
bg: string;
|
1404
|
+
};
|
1405
|
+
'&.is-pressed': {
|
1406
|
+
bg: string;
|
1407
|
+
};
|
1408
|
+
cursor: string;
|
1409
|
+
transition: string;
|
1410
|
+
outline: string;
|
1411
|
+
borderRadius: string;
|
1412
|
+
borderColor: string;
|
1413
|
+
path: {
|
1414
|
+
fill: string;
|
1415
|
+
};
|
1416
|
+
'&.is-focused': {
|
1417
|
+
outline: string;
|
1418
|
+
outlineColor: string;
|
1419
|
+
outlineOffset: string;
|
1420
|
+
};
|
1421
|
+
};
|
1386
1422
|
};
|
1387
1423
|
modalCloseButton: {
|
1388
1424
|
position: string;
|
@@ -1515,6 +1551,17 @@ declare const _default: {
|
|
1515
1551
|
currentValue: {
|
1516
1552
|
color: string;
|
1517
1553
|
};
|
1554
|
+
arrow: {
|
1555
|
+
width: string;
|
1556
|
+
height: string;
|
1557
|
+
alignItems: string;
|
1558
|
+
justifyContent: string;
|
1559
|
+
'& > svg': {
|
1560
|
+
minWidth: string;
|
1561
|
+
width: string;
|
1562
|
+
height: string;
|
1563
|
+
};
|
1564
|
+
};
|
1518
1565
|
};
|
1519
1566
|
radio: {
|
1520
1567
|
base: {
|
@@ -2894,6 +2941,7 @@ declare const _default: {
|
|
2894
2941
|
py: string;
|
2895
2942
|
pl: string;
|
2896
2943
|
pr: string;
|
2944
|
+
justifyContent: string;
|
2897
2945
|
'&.is-focused': {
|
2898
2946
|
color: string;
|
2899
2947
|
bg: string;
|
@@ -2901,7 +2949,7 @@ declare const _default: {
|
|
2901
2949
|
'&.is-selected': {
|
2902
2950
|
color: string;
|
2903
2951
|
bg: string;
|
2904
|
-
pl:
|
2952
|
+
pl: string;
|
2905
2953
|
'&.is-focused': {
|
2906
2954
|
color: string;
|
2907
2955
|
};
|
@@ -1064,6 +1064,8 @@ declare const buttons: {
|
|
1064
1064
|
width: string;
|
1065
1065
|
height: string;
|
1066
1066
|
border: string;
|
1067
|
+
position: string;
|
1068
|
+
right: string;
|
1067
1069
|
'& > svg': {
|
1068
1070
|
minWidth: string;
|
1069
1071
|
width: string;
|
@@ -1075,8 +1077,6 @@ declare const buttons: {
|
|
1075
1077
|
'&.is-pressed': {
|
1076
1078
|
bg: string;
|
1077
1079
|
};
|
1078
|
-
position: string;
|
1079
|
-
right: number;
|
1080
1080
|
cursor: string;
|
1081
1081
|
transition: string;
|
1082
1082
|
outline: string;
|
@@ -1131,6 +1131,42 @@ declare const buttons: {
|
|
1131
1131
|
bg: string;
|
1132
1132
|
};
|
1133
1133
|
};
|
1134
|
+
clearSelectionButton: {
|
1135
|
+
top: string;
|
1136
|
+
right: string;
|
1137
|
+
bg: string;
|
1138
|
+
'.is-float-label &': {
|
1139
|
+
top: string;
|
1140
|
+
};
|
1141
|
+
width: string;
|
1142
|
+
height: string;
|
1143
|
+
border: string;
|
1144
|
+
position: string;
|
1145
|
+
'& > svg': {
|
1146
|
+
minWidth: string;
|
1147
|
+
width: string;
|
1148
|
+
height: string;
|
1149
|
+
};
|
1150
|
+
'&.is-hovered': {
|
1151
|
+
bg: string;
|
1152
|
+
};
|
1153
|
+
'&.is-pressed': {
|
1154
|
+
bg: string;
|
1155
|
+
};
|
1156
|
+
cursor: string;
|
1157
|
+
transition: string;
|
1158
|
+
outline: string;
|
1159
|
+
borderRadius: string;
|
1160
|
+
borderColor: string;
|
1161
|
+
path: {
|
1162
|
+
fill: string;
|
1163
|
+
};
|
1164
|
+
'&.is-focused': {
|
1165
|
+
outline: string;
|
1166
|
+
outlineColor: string;
|
1167
|
+
outlineOffset: string;
|
1168
|
+
};
|
1169
|
+
};
|
1134
1170
|
};
|
1135
1171
|
modalCloseButton: {
|
1136
1172
|
position: string;
|
@@ -17,6 +17,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
17
17
|
var _chromaJs = _interopRequireDefault(require("chroma-js"));
|
18
18
|
var _codeView = require("../codeView/codeView");
|
19
19
|
var _colors = _interopRequireDefault(require("../colors/colors"));
|
20
|
+
var _tShirtSizes = _interopRequireDefault(require("../customProperties/tShirtSizes"));
|
20
21
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
21
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
22
23
|
var primaryBlue = _colors["default"].primary,
|
@@ -384,6 +385,24 @@ var onyxIconButton = _objectSpread(_objectSpread(_objectSpread({}, baseIconButto
|
|
384
385
|
alignItems: 'center',
|
385
386
|
justifyContent: 'center'
|
386
387
|
});
|
388
|
+
var searchClearButton = _objectSpread(_objectSpread({}, baseIconButton), {}, {
|
389
|
+
width: '20px',
|
390
|
+
height: '20px',
|
391
|
+
border: 'none',
|
392
|
+
position: 'absolute',
|
393
|
+
right: '20px',
|
394
|
+
'& > svg': {
|
395
|
+
minWidth: _tShirtSizes["default"].xs,
|
396
|
+
width: _tShirtSizes["default"].xs,
|
397
|
+
height: _tShirtSizes["default"].xs
|
398
|
+
},
|
399
|
+
'&.is-hovered': {
|
400
|
+
bg: 'background.hover'
|
401
|
+
},
|
402
|
+
'&.is-pressed': {
|
403
|
+
bg: 'background.hover'
|
404
|
+
}
|
405
|
+
});
|
387
406
|
var iconButtons = {
|
388
407
|
base: _objectSpread({}, baseIconButton),
|
389
408
|
nextGen: _objectSpread({}, onyxIconButton),
|
@@ -474,24 +493,7 @@ var iconButtons = {
|
|
474
493
|
backgroundColor: 'gray-300'
|
475
494
|
}
|
476
495
|
},
|
477
|
-
searchClearButton:
|
478
|
-
width: '20px',
|
479
|
-
height: '20px',
|
480
|
-
border: 'none',
|
481
|
-
'& > svg': {
|
482
|
-
minWidth: '18px',
|
483
|
-
width: '18px',
|
484
|
-
height: '18px'
|
485
|
-
},
|
486
|
-
'&.is-hovered': {
|
487
|
-
bg: 'background.hover'
|
488
|
-
},
|
489
|
-
'&.is-pressed': {
|
490
|
-
bg: 'background.hover'
|
491
|
-
},
|
492
|
-
position: 'absolute',
|
493
|
-
right: 20
|
494
|
-
}),
|
496
|
+
searchClearButton: searchClearButton,
|
495
497
|
filter: _objectSpread(_objectSpread({}, baseIconButton), {}, {
|
496
498
|
bg: 'transparent',
|
497
499
|
border: '2px solid',
|
@@ -519,7 +521,15 @@ var iconButtons = {
|
|
519
521
|
'&.is-hovered': {
|
520
522
|
bg: 'gray-900'
|
521
523
|
}
|
522
|
-
}
|
524
|
+
},
|
525
|
+
clearSelectionButton: _objectSpread(_objectSpread({}, searchClearButton), {}, {
|
526
|
+
top: '15px',
|
527
|
+
right: '1rem',
|
528
|
+
bg: 'transparent',
|
529
|
+
'.is-float-label &': {
|
530
|
+
top: '12px'
|
531
|
+
}
|
532
|
+
})
|
523
533
|
};
|
524
534
|
var buttons = {
|
525
535
|
neutral: neutral,
|
@@ -494,6 +494,7 @@ declare const _default: {
|
|
494
494
|
py: string;
|
495
495
|
pl: string;
|
496
496
|
pr: string;
|
497
|
+
justifyContent: string;
|
497
498
|
'&.is-focused': {
|
498
499
|
color: string;
|
499
500
|
bg: string;
|
@@ -501,7 +502,7 @@ declare const _default: {
|
|
501
502
|
'&.is-selected': {
|
502
503
|
color: string;
|
503
504
|
bg: string;
|
504
|
-
pl:
|
505
|
+
pl: string;
|
505
506
|
'&.is-focused': {
|
506
507
|
color: string;
|
507
508
|
};
|
@@ -213,7 +213,8 @@ var listBox = {
|
|
213
213
|
option: {
|
214
214
|
py: '.75rem',
|
215
215
|
pl: '.75rem',
|
216
|
-
pr: '
|
216
|
+
pr: 'md',
|
217
|
+
justifyContent: 'space-between',
|
217
218
|
'&.is-focused': {
|
218
219
|
color: 'text.primary',
|
219
220
|
bg: 'gray-100'
|
@@ -221,7 +222,7 @@ var listBox = {
|
|
221
222
|
'&.is-selected': {
|
222
223
|
color: 'text.primary',
|
223
224
|
bg: 'lightblue',
|
224
|
-
pl:
|
225
|
+
pl: '.75rem',
|
225
226
|
'&.is-focused': {
|
226
227
|
color: 'text.primary'
|
227
228
|
}
|
@@ -12,6 +12,8 @@ export interface SelectFieldProps<T> extends Omit<StyleProps, 'direction'>, UseS
|
|
12
12
|
};
|
13
13
|
'data-testid'?: string;
|
14
14
|
hintText?: string;
|
15
|
+
hasClearButton?: boolean;
|
16
|
+
onClear?: () => void;
|
15
17
|
}
|
16
18
|
export interface SelectFieldBaseProps extends UseSelectFieldReturnProps<object>, SharedFieldProps {
|
17
19
|
slots?: {
|
@@ -25,4 +27,7 @@ export interface SelectFieldBaseProps extends UseSelectFieldReturnProps<object>,
|
|
25
27
|
selectProps?: Record<string, unknown>;
|
26
28
|
isDisabled?: boolean;
|
27
29
|
helpHintProps?: HelpHintProps;
|
30
|
+
hasClearButton?: boolean;
|
31
|
+
clearButtonProps?: Record<string, unknown>;
|
32
|
+
onClear?: () => void;
|
28
33
|
}
|
@@ -9,6 +9,7 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
|
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
11
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
12
|
+
import tShirtSizes from '../../styles/themes/astro/customProperties/tShirtSizes';
|
12
13
|
import { badgeDeleteButton, deleteButton, invertedBadgeDeleteButton } from '../Badge/Badge.styles';
|
13
14
|
import { defaultActive, defaultFocus, defaultHover } from '../Button/Buttons.styles';
|
14
15
|
import { toggle } from '../CollapsiblePanel/CollapsiblePanel.styles';
|
@@ -138,6 +139,17 @@ var searchClearButton = _objectSpread(_objectSpread({}, base), {}, {
|
|
138
139
|
position: 'absolute',
|
139
140
|
right: 10
|
140
141
|
});
|
142
|
+
var clearSelectionButton = _objectSpread(_objectSpread({}, base), {}, {
|
143
|
+
width: tShirtSizes.md,
|
144
|
+
height: tShirtSizes.md,
|
145
|
+
position: 'absolute',
|
146
|
+
right: '15px',
|
147
|
+
top: '7px',
|
148
|
+
bg: 'white',
|
149
|
+
'.is-float-label &': {
|
150
|
+
top: '9px'
|
151
|
+
}
|
152
|
+
});
|
141
153
|
var filter = _objectSpread(_objectSpread({}, base), {}, {
|
142
154
|
bg: 'white',
|
143
155
|
border: '1px solid',
|
@@ -187,5 +199,6 @@ export default {
|
|
187
199
|
applicationPortal: applicationPortal,
|
188
200
|
applicationPortalPinned: applicationPortalPinned,
|
189
201
|
searchClearButton: searchClearButton,
|
190
|
-
filter: filter
|
202
|
+
filter: filter,
|
203
|
+
clearSelectionButton: clearSelectionButton
|
191
204
|
};
|
@@ -14,10 +14,11 @@ var _excluded = ["item", "hasVirtualFocus", "isCondensed"],
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
16
16
|
import React, { forwardRef, useContext, useEffect, useImperativeHandle, useRef } from 'react';
|
17
|
+
import CheckIcon from '@pingux/mdi-react/CheckIcon';
|
17
18
|
import CircleSmallIcon from '@pingux/mdi-react/CircleSmallIcon';
|
18
19
|
import { useOption } from '@react-aria/listbox';
|
19
20
|
import { useMultivaluesContext } from '../../context/MultivaluesContext';
|
20
|
-
import { useStatusClasses } from '../../hooks';
|
21
|
+
import { useGetTheme, useStatusClasses } from '../../hooks';
|
21
22
|
import Box from '../Box';
|
22
23
|
import Icon from '../Icon';
|
23
24
|
import { ListBoxContext } from './ListBoxContext';
|
@@ -88,6 +89,8 @@ var Option = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
88
89
|
state.selectionManager.setFocusedKey(item.key);
|
89
90
|
}
|
90
91
|
};
|
92
|
+
var _useGetTheme = useGetTheme(),
|
93
|
+
isOnyx = _useGetTheme.themeState.isOnyx;
|
91
94
|
var _useStatusClasses = useStatusClasses(null, {
|
92
95
|
isDisabled: isDisabled || isSeparator,
|
93
96
|
isFocused: focused,
|
@@ -128,11 +131,17 @@ var Option = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
128
131
|
mr: "xs",
|
129
132
|
className: classNames,
|
130
133
|
variant: "listBox.checkboxIcon"
|
131
|
-
}) : isSelected && ___EmotionJSX(Icon, {
|
134
|
+
}) : isSelected && !isOnyx && ___EmotionJSX(Icon, {
|
132
135
|
icon: CircleSmallIcon,
|
133
136
|
title: {
|
134
137
|
name: 'Circle Small Icon'
|
135
138
|
}
|
136
|
-
}), rendered
|
139
|
+
}), rendered, isSelected && isOnyx && ___EmotionJSX(Icon, {
|
140
|
+
icon: CheckIcon,
|
141
|
+
title: {
|
142
|
+
name: 'Check Icon'
|
143
|
+
},
|
144
|
+
color: "green-500"
|
145
|
+
}));
|
137
146
|
});
|
138
147
|
export default Option;
|
@@ -457,4 +457,23 @@ export var WithHelpHint = function WithHelpHint(args) {
|
|
457
457
|
}, "Blue"), ___EmotionJSX(Item, {
|
458
458
|
key: "yellow"
|
459
459
|
}, "Yellow")));
|
460
|
+
};
|
461
|
+
export var WithClearButton = function WithClearButton(args) {
|
462
|
+
var _useState5 = useState('red'),
|
463
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
464
|
+
selectedKey = _useState6[0],
|
465
|
+
setSelectedKey = _useState6[1];
|
466
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(SelectField, _extends({}, args, {
|
467
|
+
width: "100%",
|
468
|
+
label: "What's your favorite color?",
|
469
|
+
hasClearButton: true,
|
470
|
+
selectedKey: selectedKey,
|
471
|
+
onSelectionChange: setSelectedKey
|
472
|
+
}), ___EmotionJSX(Item, {
|
473
|
+
key: "red"
|
474
|
+
}, "Red"), ___EmotionJSX(Item, {
|
475
|
+
key: "blue"
|
476
|
+
}, "Blue"), ___EmotionJSX(Item, {
|
477
|
+
key: "yellow"
|
478
|
+
}, "Yellow")));
|
460
479
|
};
|
@@ -191,4 +191,15 @@ test('should show hintText text if prop is passed', function () {
|
|
191
191
|
fireEvent.mouseMove(helpHintButton);
|
192
192
|
fireEvent.mouseEnter(helpHintButton);
|
193
193
|
expect(screen.getByText(hintText)).toBeInTheDocument();
|
194
|
+
});
|
195
|
+
test('should have clear button if hasClearButton prop is true', function () {
|
196
|
+
getComponent({
|
197
|
+
selectedKey: 'a',
|
198
|
+
hasClearButton: true,
|
199
|
+
clearButtonProps: {
|
200
|
+
'data-testid': 'clear-button'
|
201
|
+
}
|
202
|
+
});
|
203
|
+
var clearButton = screen.getByTestId('clear-button');
|
204
|
+
expect(clearButton).toBeInTheDocument();
|
194
205
|
});
|
@@ -9,22 +9,17 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
|
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["columnStyleProps", "defaultText", "fieldContainerProps", "fieldControlInputProps", "fieldControlWrapperProps", "fieldLabelProps", "helperText", "isLoadingInitial", "isDisabled", "label", "labelMode", "name", "overlay", "placeholder", "slots", "state", "status", "trigger", "triggerProps", "triggerRef", "valueProps", "selectProps"];
|
12
|
+
var _excluded = ["columnStyleProps", "defaultText", "fieldContainerProps", "fieldControlInputProps", "fieldControlWrapperProps", "fieldLabelProps", "helperText", "isLoadingInitial", "isDisabled", "label", "labelMode", "name", "overlay", "placeholder", "slots", "state", "status", "trigger", "triggerProps", "triggerRef", "valueProps", "selectProps", "hasClearButton", "clearButtonProps", "onClear"];
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
15
|
import React, { forwardRef, useMemo } from 'react';
|
16
|
+
import CloseIcon from '@pingux/mdi-react/CloseIcon';
|
16
17
|
import { v4 as uuid } from 'uuid';
|
18
|
+
import { Box, Button, FieldHelperText, Icon, IconButton, Label, Loader, Text } from '../..';
|
17
19
|
import useGetTheme from '../../hooks/useGetTheme';
|
18
20
|
import { modes } from '../../utils/devUtils/constants/labelModes';
|
19
21
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
20
22
|
import { getAriaAttributeProps } from '../../utils/docUtils/ariaAttributes';
|
21
|
-
import Box from '../Box';
|
22
|
-
import Button from '../Button';
|
23
|
-
import FieldHelperText from '../FieldHelperText';
|
24
|
-
import Icon from '../Icon';
|
25
|
-
import Label from '../Label';
|
26
|
-
import Loader from '../Loader';
|
27
|
-
import Text from '../Text';
|
28
23
|
import { HiddenSelect } from './HiddenSelect';
|
29
24
|
|
30
25
|
/**
|
@@ -58,6 +53,9 @@ var SelectFieldBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
58
53
|
triggerRef = props.triggerRef,
|
59
54
|
valueProps = props.valueProps,
|
60
55
|
selectProps = props.selectProps,
|
56
|
+
hasClearButton = props.hasClearButton,
|
57
|
+
clearButtonProps = props.clearButtonProps,
|
58
|
+
onClear = props.onClear,
|
61
59
|
others = _objectWithoutProperties(props, _excluded);
|
62
60
|
var _getAriaAttributeProp = getAriaAttributeProps(others),
|
63
61
|
ariaProps = _getAriaAttributeProp.ariaProps;
|
@@ -68,7 +66,40 @@ var SelectFieldBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
68
66
|
var helperTextId = useMemo(function () {
|
69
67
|
return uuid();
|
70
68
|
}, []);
|
71
|
-
var
|
69
|
+
var handleOnClear = function handleOnClear() {
|
70
|
+
if (onClear) {
|
71
|
+
onClear();
|
72
|
+
}
|
73
|
+
state.setSelectedKey(null);
|
74
|
+
};
|
75
|
+
var buttonRendered = !(hasClearButton && state.selectedKey) && ___EmotionJSX(Box, {
|
76
|
+
as: "span",
|
77
|
+
"aria-hidden": "true",
|
78
|
+
variant: "forms.select.arrow"
|
79
|
+
}, ___EmotionJSX(Icon, {
|
80
|
+
icon: state.isOpen ? MenuUp : MenuDown,
|
81
|
+
title: {
|
82
|
+
name: 'Menu down'
|
83
|
+
},
|
84
|
+
size: "md"
|
85
|
+
}));
|
86
|
+
var clearButton = hasClearButton && state.selectedKey && ___EmotionJSX(IconButton, _extends({
|
87
|
+
tabIndex: 0,
|
88
|
+
as: "span",
|
89
|
+
role: "button",
|
90
|
+
"aria-label": "Clear selection",
|
91
|
+
variant: "clearSelectionButton",
|
92
|
+
onPress: handleOnClear,
|
93
|
+
color: "text.secondary"
|
94
|
+
}, clearButtonProps), ___EmotionJSX(Icon, {
|
95
|
+
icon: CloseIcon,
|
96
|
+
title: {
|
97
|
+
name: 'Clear selection Icon'
|
98
|
+
}
|
99
|
+
}));
|
100
|
+
var defaultTrigger = ___EmotionJSX(Box, _extends({
|
101
|
+
isRow: true
|
102
|
+
}, fieldControlWrapperProps, {
|
72
103
|
variant: "forms.input.fieldControlWrapper"
|
73
104
|
}), ___EmotionJSX(Button, _extends({
|
74
105
|
className: fieldControlInputProps.className,
|
@@ -83,17 +114,7 @@ var SelectFieldBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
83
114
|
variant: "placeholder"
|
84
115
|
}, labelMode === modes.FLOAT ? '' : placeholder || defaultText)), isLoadingInitial && ___EmotionJSX(Loader, {
|
85
116
|
variant: "loader.withinInput"
|
86
|
-
}),
|
87
|
-
as: "span",
|
88
|
-
"aria-hidden": "true",
|
89
|
-
variant: "forms.select.arrow"
|
90
|
-
}, ___EmotionJSX(Icon, {
|
91
|
-
icon: state.isOpen ? MenuUp : MenuDown,
|
92
|
-
title: {
|
93
|
-
name: 'Menu down'
|
94
|
-
},
|
95
|
-
size: "md"
|
96
|
-
}))), slots === null || slots === void 0 ? void 0 : slots.inContainer);
|
117
|
+
}), buttonRendered), clearButton, slots === null || slots === void 0 ? void 0 : slots.inContainer);
|
97
118
|
return ___EmotionJSX(Box, _extends({
|
98
119
|
ref: ref,
|
99
120
|
variant: "forms.input.fieldContainer"
|
@@ -44,6 +44,7 @@ var defaultProps = {
|
|
44
44
|
value: testValue,
|
45
45
|
items: items
|
46
46
|
};
|
47
|
+
var onClear = jest.fn();
|
47
48
|
var SelectFieldWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
|
48
49
|
var _useSelectField = useSelectField(props, ref),
|
49
50
|
selectFieldProps = _extends({}, (_objectDestructuringEmpty(_useSelectField), _useSelectField));
|
@@ -429,4 +430,29 @@ universalComponentTests({
|
|
429
430
|
}, item.name);
|
430
431
|
});
|
431
432
|
}
|
433
|
+
});
|
434
|
+
test('should have clear button if hasClearButton prop is true', function () {
|
435
|
+
getComponent({
|
436
|
+
selectedKey: 'a',
|
437
|
+
hasClearButton: true,
|
438
|
+
clearButtonProps: {
|
439
|
+
'data-testid': 'clear-button'
|
440
|
+
}
|
441
|
+
});
|
442
|
+
var clearButton = screen.getByTestId('clear-button');
|
443
|
+
expect(clearButton).toBeInTheDocument();
|
444
|
+
});
|
445
|
+
test('should have call onClear function', function () {
|
446
|
+
getComponent({
|
447
|
+
selectedKey: 'a',
|
448
|
+
hasClearButton: true,
|
449
|
+
clearButtonProps: {
|
450
|
+
'data-testid': 'clear-button'
|
451
|
+
},
|
452
|
+
onClear: onClear
|
453
|
+
});
|
454
|
+
var clearButton = screen.getByTestId('clear-button');
|
455
|
+
expect(clearButton).toBeInTheDocument();
|
456
|
+
userEvent.click(clearButton);
|
457
|
+
expect(onClear).toHaveBeenCalledTimes(1);
|
432
458
|
});
|
@@ -15,10 +15,6 @@ var listBox = {
|
|
15
15
|
borderRadius: '4px'
|
16
16
|
},
|
17
17
|
option: {
|
18
|
-
py: '.75rem',
|
19
|
-
pl: '.75rem',
|
20
|
-
pr: '1rem',
|
21
|
-
bg: 'background.base',
|
22
18
|
'&.is-focused': {
|
23
19
|
color: 'text.primary',
|
24
20
|
bg: 'gray-800'
|
@@ -26,7 +22,6 @@ var listBox = {
|
|
26
22
|
'&.is-selected': {
|
27
23
|
color: 'text.primary',
|
28
24
|
bg: 'gray-800',
|
29
|
-
pl: 0,
|
30
25
|
'&.is-focused': {
|
31
26
|
color: 'text.primary'
|
32
27
|
}
|
@@ -10,6 +10,7 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
10
10
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
11
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
12
12
|
import colors from './colors/colors';
|
13
|
+
import tShirtSizes from './customProperties/tShirtSizes';
|
13
14
|
import { fieldControlWrapper, input } from './variants/input';
|
14
15
|
import { label } from './variants/label';
|
15
16
|
export var checkbox = {
|
@@ -33,6 +34,17 @@ export var select = {
|
|
33
34
|
},
|
34
35
|
currentValue: {
|
35
36
|
color: 'text.primary'
|
37
|
+
},
|
38
|
+
arrow: {
|
39
|
+
width: '20px',
|
40
|
+
height: '20px',
|
41
|
+
alignItems: 'center',
|
42
|
+
justifyContent: 'center',
|
43
|
+
'& > svg': {
|
44
|
+
minWidth: tShirtSizes.xs,
|
45
|
+
width: tShirtSizes.xs,
|
46
|
+
height: tShirtSizes.xs
|
47
|
+
}
|
36
48
|
}
|
37
49
|
};
|
38
50
|
export var search = {
|
@@ -12,6 +12,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
12
12
|
import chroma from 'chroma-js';
|
13
13
|
import { copyButton } from '../codeView/codeView';
|
14
14
|
import colors from '../colors/colors';
|
15
|
+
import tShirtSizes from '../customProperties/tShirtSizes';
|
15
16
|
var primaryBlue = colors.primary,
|
16
17
|
primaryBlueHover = colors.active_hover,
|
17
18
|
primaryBluePress = colors.active_pressed,
|
@@ -376,6 +377,24 @@ var onyxIconButton = _objectSpread(_objectSpread(_objectSpread({}, baseIconButto
|
|
376
377
|
alignItems: 'center',
|
377
378
|
justifyContent: 'center'
|
378
379
|
});
|
380
|
+
var searchClearButton = _objectSpread(_objectSpread({}, baseIconButton), {}, {
|
381
|
+
width: '20px',
|
382
|
+
height: '20px',
|
383
|
+
border: 'none',
|
384
|
+
position: 'absolute',
|
385
|
+
right: '20px',
|
386
|
+
'& > svg': {
|
387
|
+
minWidth: tShirtSizes.xs,
|
388
|
+
width: tShirtSizes.xs,
|
389
|
+
height: tShirtSizes.xs
|
390
|
+
},
|
391
|
+
'&.is-hovered': {
|
392
|
+
bg: 'background.hover'
|
393
|
+
},
|
394
|
+
'&.is-pressed': {
|
395
|
+
bg: 'background.hover'
|
396
|
+
}
|
397
|
+
});
|
379
398
|
var iconButtons = {
|
380
399
|
base: _objectSpread({}, baseIconButton),
|
381
400
|
nextGen: _objectSpread({}, onyxIconButton),
|
@@ -466,24 +485,7 @@ var iconButtons = {
|
|
466
485
|
backgroundColor: 'gray-300'
|
467
486
|
}
|
468
487
|
},
|
469
|
-
searchClearButton:
|
470
|
-
width: '20px',
|
471
|
-
height: '20px',
|
472
|
-
border: 'none',
|
473
|
-
'& > svg': {
|
474
|
-
minWidth: '18px',
|
475
|
-
width: '18px',
|
476
|
-
height: '18px'
|
477
|
-
},
|
478
|
-
'&.is-hovered': {
|
479
|
-
bg: 'background.hover'
|
480
|
-
},
|
481
|
-
'&.is-pressed': {
|
482
|
-
bg: 'background.hover'
|
483
|
-
},
|
484
|
-
position: 'absolute',
|
485
|
-
right: 20
|
486
|
-
}),
|
488
|
+
searchClearButton: searchClearButton,
|
487
489
|
filter: _objectSpread(_objectSpread({}, baseIconButton), {}, {
|
488
490
|
bg: 'transparent',
|
489
491
|
border: '2px solid',
|
@@ -511,7 +513,15 @@ var iconButtons = {
|
|
511
513
|
'&.is-hovered': {
|
512
514
|
bg: 'gray-900'
|
513
515
|
}
|
514
|
-
}
|
516
|
+
},
|
517
|
+
clearSelectionButton: _objectSpread(_objectSpread({}, searchClearButton), {}, {
|
518
|
+
top: '15px',
|
519
|
+
right: '1rem',
|
520
|
+
bg: 'transparent',
|
521
|
+
'.is-float-label &': {
|
522
|
+
top: '12px'
|
523
|
+
}
|
524
|
+
})
|
515
525
|
};
|
516
526
|
var buttons = {
|
517
527
|
neutral: neutral,
|
@@ -200,7 +200,8 @@ var listBox = {
|
|
200
200
|
option: {
|
201
201
|
py: '.75rem',
|
202
202
|
pl: '.75rem',
|
203
|
-
pr: '
|
203
|
+
pr: 'md',
|
204
|
+
justifyContent: 'space-between',
|
204
205
|
'&.is-focused': {
|
205
206
|
color: 'text.primary',
|
206
207
|
bg: 'gray-100'
|
@@ -208,7 +209,7 @@ var listBox = {
|
|
208
209
|
'&.is-selected': {
|
209
210
|
color: 'text.primary',
|
210
211
|
bg: 'lightblue',
|
211
|
-
pl:
|
212
|
+
pl: '.75rem',
|
212
213
|
'&.is-focused': {
|
213
214
|
color: 'text.primary'
|
214
215
|
}
|