@pingux/astro 2.234.1 → 2.235.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/ComboBox/ComboBox.styles.d.ts +897 -0
- package/lib/cjs/components/ComboBox/ComboBoxInput.d.ts +4 -0
- package/lib/cjs/components/ComboBox/ComboBoxInput.js +8 -37
- package/lib/cjs/components/ComboBox/index.d.ts +1 -0
- package/lib/cjs/components/ComboBoxField/ComboBoxField.d.ts +9 -0
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +11 -133
- package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +5 -4
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +2 -3
- package/lib/cjs/components/ComboBoxField/index.d.ts +1 -0
- package/lib/cjs/types/ComboBox.d.ts +36 -0
- package/lib/cjs/types/ComboBox.js +6 -0
- package/lib/cjs/types/ComboBoxField.d.ts +110 -0
- package/lib/cjs/types/ComboBoxField.js +6 -0
- package/lib/cjs/types/index.d.ts +2 -0
- package/lib/cjs/types/index.js +79 -57
- package/lib/cjs/types/popoverContainer.d.ts +1 -0
- package/lib/cjs/types/textField.d.ts +6 -0
- package/lib/components/ComboBox/ComboBoxInput.js +8 -37
- package/lib/components/ComboBoxField/ComboBoxField.js +12 -134
- package/lib/components/ComboBoxField/ComboBoxField.stories.js +5 -4
- package/lib/components/ComboBoxField/ComboBoxField.test.js +2 -3
- package/lib/types/ComboBox.js +1 -0
- package/lib/types/ComboBoxField.js +1 -0
- package/lib/types/index.js +2 -0
- package/package.json +1 -1
|
@@ -15,20 +15,16 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
exports["default"] = void 0;
|
|
18
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
|
19
18
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
20
19
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
21
20
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
22
21
|
var _react = _interopRequireWildcard(require("react"));
|
|
23
22
|
var _reactAria = require("react-aria");
|
|
24
23
|
var _interactions = require("@react-aria/interactions");
|
|
25
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
26
24
|
var _ = require("../..");
|
|
27
25
|
var _hooks = require("../../hooks");
|
|
28
26
|
var _useGetTheme2 = _interopRequireDefault(require("../../hooks/useGetTheme"));
|
|
29
27
|
var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/constants/loadingStates"));
|
|
30
|
-
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
|
31
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
|
32
28
|
var _react2 = require("@emotion/react");
|
|
33
29
|
var _excluded = ["controlProps", "containerProps", "hasAutoFocus", "isDisabled", "isReadOnly", "isOpen", "loadingState", "style", "inputWrapperRef", "inputRef", "inputProps", "triggerRef", "triggerProps", "menuTrigger", "onInputChange", "onLoadMore", "onOpenChange", "onSelectionChange", "wrapperProps"];
|
|
34
30
|
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); }
|
|
@@ -55,6 +51,9 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
55
51
|
onSelectionChange = props.onSelectionChange,
|
|
56
52
|
wrapperProps = props.wrapperProps,
|
|
57
53
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
54
|
+
var _useHover = (0, _interactions.useHover)({}),
|
|
55
|
+
hoverProps = _useHover.hoverProps,
|
|
56
|
+
isHovered = _useHover.isHovered;
|
|
58
57
|
var textFieldProps = _objectSpread({
|
|
59
58
|
isDisabled: isDisabled,
|
|
60
59
|
isReadOnly: isReadOnly,
|
|
@@ -69,12 +68,10 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
69
68
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
70
69
|
return inputRef.current;
|
|
71
70
|
});
|
|
72
|
-
var _useHover = (0, _interactions.useHover)({}),
|
|
73
|
-
hoverProps = _useHover.hoverProps,
|
|
74
|
-
isHovered = _useHover.isHovered;
|
|
75
71
|
var _useInputLoader = (0, _hooks.useInputLoader)({
|
|
76
72
|
loadingState: loadingState,
|
|
77
|
-
|
|
73
|
+
// eslint-disable-next-line max-len
|
|
74
|
+
inputValue: inputProps === null || inputProps === void 0 ? void 0 : inputProps.value
|
|
78
75
|
}),
|
|
79
76
|
isLoading = _useInputLoader.isLoading;
|
|
80
77
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
|
@@ -101,7 +98,7 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
101
98
|
size: isOnyx ? 'sm' : 'md',
|
|
102
99
|
sx: isOpen ? {
|
|
103
100
|
transform: 'rotate(180deg)'
|
|
104
|
-
} :
|
|
101
|
+
} : undefined,
|
|
105
102
|
title: {
|
|
106
103
|
name: ''
|
|
107
104
|
},
|
|
@@ -124,40 +121,14 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
124
121
|
controlProps: _objectSpread({
|
|
125
122
|
variant: 'forms.comboBox.input'
|
|
126
123
|
}, controlProps),
|
|
124
|
+
tabIndex: -1,
|
|
127
125
|
statusClasses: {
|
|
128
126
|
isHovered: isHovered
|
|
129
127
|
},
|
|
130
128
|
ref: inputRef,
|
|
131
129
|
slots: {
|
|
132
130
|
inContainer: button
|
|
133
|
-
}
|
|
134
|
-
tabIndex: -1
|
|
131
|
+
}
|
|
135
132
|
}))));
|
|
136
133
|
});
|
|
137
|
-
ComboBoxInput.propTypes = _objectSpread(_objectSpread({
|
|
138
|
-
containerProps: _propTypes["default"].shape({}),
|
|
139
|
-
controlProps: _propTypes["default"].shape({}),
|
|
140
|
-
hasAutoFocus: _propTypes["default"].bool,
|
|
141
|
-
helperText: _propTypes["default"].node,
|
|
142
|
-
inputProps: _propTypes["default"].shape({
|
|
143
|
-
value: _propTypes["default"].string
|
|
144
|
-
}),
|
|
145
|
-
inputRef: _propTypes["default"].shape({}),
|
|
146
|
-
inputWrapperRef: _propTypes["default"].shape({}),
|
|
147
|
-
isDisabled: _propTypes["default"].bool,
|
|
148
|
-
isOpen: _propTypes["default"].bool,
|
|
149
|
-
isReadOnly: _propTypes["default"].bool,
|
|
150
|
-
label: _propTypes["default"].node,
|
|
151
|
-
labelProps: _propTypes["default"].shape({}),
|
|
152
|
-
loadingState: _propTypes["default"].oneOf((0, _values["default"])(_loadingStates["default"])),
|
|
153
|
-
menuTrigger: _propTypes["default"].oneOf(['focus', 'input', 'manual']),
|
|
154
|
-
onInputChange: _propTypes["default"].func,
|
|
155
|
-
onLoadMore: _propTypes["default"].func,
|
|
156
|
-
onOpenChange: _propTypes["default"].func,
|
|
157
|
-
onSelectionChange: _propTypes["default"].func,
|
|
158
|
-
style: _propTypes["default"].shape({}),
|
|
159
|
-
triggerProps: _propTypes["default"].shape({}),
|
|
160
|
-
triggerRef: _propTypes["default"].shape({}),
|
|
161
|
-
wrapperProps: _propTypes["default"].shape({})
|
|
162
|
-
}, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes);
|
|
163
134
|
var _default = exports["default"] = ComboBoxInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ComboBoxInput';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComboBoxFieldProps } from '../../types';
|
|
3
|
+
interface ComboBoxFieldFC {
|
|
4
|
+
<T extends object>(props: ComboBoxFieldProps<T> & React.RefAttributes<HTMLInputElement>): React.ReactElement | null;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
defaultProps?: Partial<ComboBoxFieldProps> | undefined;
|
|
7
|
+
}
|
|
8
|
+
declare const ComboBoxField: ComboBoxFieldFC;
|
|
9
|
+
export default ComboBoxField;
|
|
@@ -17,7 +17,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
17
17
|
exports["default"] = void 0;
|
|
18
18
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
19
19
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
|
20
|
-
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
|
21
20
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
22
21
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
23
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
@@ -27,13 +26,10 @@ var _reactAria = require("react-aria");
|
|
|
27
26
|
var _reactStately = require("react-stately");
|
|
28
27
|
var _i18n = require("@react-aria/i18n");
|
|
29
28
|
var _utils = require("@react-aria/utils");
|
|
30
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
29
|
var _hooks = require("../../hooks");
|
|
32
30
|
var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/constants/loadingStates"));
|
|
33
31
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
|
34
|
-
var _isIterable = require("../../utils/devUtils/props/isIterable");
|
|
35
32
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
|
36
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
|
37
33
|
var _ComboBox = _interopRequireDefault(require("../ComboBox"));
|
|
38
34
|
var _ListBox = _interopRequireDefault(require("../ListBox"));
|
|
39
35
|
var _Popover = _interopRequireDefault(require("../Popover"));
|
|
@@ -86,11 +82,11 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
86
82
|
label: 'default',
|
|
87
83
|
allowsEmptyCollection: allowsEmptyCollection
|
|
88
84
|
}, nonAriaProps);
|
|
89
|
-
var popoverRef = (0, _react.useRef)();
|
|
90
|
-
var buttonRef = (0, _react.useRef)();
|
|
91
|
-
var listBoxRef = (0, _react.useRef)();
|
|
92
|
-
var inputRef = (0, _react.useRef)();
|
|
93
|
-
var inputWrapperRef = (0, _react.useRef)();
|
|
85
|
+
var popoverRef = (0, _react.useRef)(null);
|
|
86
|
+
var buttonRef = (0, _react.useRef)(null);
|
|
87
|
+
var listBoxRef = (0, _react.useRef)(null);
|
|
88
|
+
var inputRef = (0, _react.useRef)(null);
|
|
89
|
+
var inputWrapperRef = (0, _react.useRef)(null);
|
|
94
90
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
|
95
91
|
/* istanbul ignore next */
|
|
96
92
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
@@ -101,7 +97,7 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
101
97
|
var getItemsArr = function getItemsArr(initialArr) {
|
|
102
98
|
if (initialArr && shouldShowAddOption) {
|
|
103
99
|
var _context;
|
|
104
|
-
return (0, _concat["default"])(_context = []).call(_context, initialArr, [{
|
|
100
|
+
return (0, _concat["default"])(_context = []).call(_context, (0, _from["default"])(initialArr), [{
|
|
105
101
|
name: addOption,
|
|
106
102
|
key: addOption
|
|
107
103
|
}]);
|
|
@@ -143,10 +139,11 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
143
139
|
inputProps = _useComboBox.inputProps,
|
|
144
140
|
listBoxProps = _useComboBox.listBoxProps,
|
|
145
141
|
labelProps = _useComboBox.labelProps;
|
|
146
|
-
var
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
var _ref = listBoxProps,
|
|
143
|
+
shouldFocusOnHover = _ref.shouldFocusOnHover,
|
|
144
|
+
shouldSelectOnPressUp = _ref.shouldSelectOnPressUp,
|
|
145
|
+
action = _ref['UNSTABLE_itemBehavior'],
|
|
146
|
+
otherListBoxProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
|
|
150
147
|
var _useOverlayPosition = (0, _reactAria.useOverlayPosition)({
|
|
151
148
|
offset: 1,
|
|
152
149
|
targetRef: inputWrapperRef,
|
|
@@ -234,125 +231,6 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
234
231
|
"aria-invalid": status === 'error' && true
|
|
235
232
|
})), listBox);
|
|
236
233
|
});
|
|
237
|
-
ComboBoxField.propTypes = _objectSpread(_objectSpread({
|
|
238
|
-
/* Whether or not adding new options to the list is enabled. */
|
|
239
|
-
hasAddOption: _propTypes["default"].bool,
|
|
240
|
-
/** Whether the ComboBox allows a non-item matching input value to be set. */
|
|
241
|
-
hasCustomValue: _propTypes["default"].bool,
|
|
242
|
-
/** Whether the collection allows empty selection. */
|
|
243
|
-
hasNoEmptySelection: _propTypes["default"].bool,
|
|
244
|
-
/**
|
|
245
|
-
* The item keys that are disabled. These items cannot be selected, focused, or otherwise
|
|
246
|
-
* interacted with.
|
|
247
|
-
*/
|
|
248
|
-
disabledKeys: _isIterable.isIterableProp,
|
|
249
|
-
/** The interaction required to display the ComboBox menu. */
|
|
250
|
-
menuTrigger: _propTypes["default"].oneOf(['focus', 'input', 'manual']),
|
|
251
|
-
/**
|
|
252
|
-
* Whether the ComboBox menu is prevented from flipping directions when insufficient space is
|
|
253
|
-
* available for the given `direction` placement.
|
|
254
|
-
*/
|
|
255
|
-
isNotFlippable: _propTypes["default"].bool,
|
|
256
|
-
/** Where the ComboBox menu opens relative to its trigger. */
|
|
257
|
-
direction: _propTypes["default"].oneOf(['top', 'right', 'bottom', 'left']),
|
|
258
|
-
/** Text rendered below the input. */
|
|
259
|
-
helperText: _propTypes["default"].node,
|
|
260
|
-
/** The initial selected key in the collection (uncontrolled). */
|
|
261
|
-
defaultSelectedKey: _propTypes["default"].string,
|
|
262
|
-
/** The currently selected key in the collection (controlled). */
|
|
263
|
-
selectedKey: _propTypes["default"].string,
|
|
264
|
-
/**
|
|
265
|
-
* Handler that is called when the selection changes.
|
|
266
|
-
*
|
|
267
|
-
* `(key: Key) => any`
|
|
268
|
-
*/
|
|
269
|
-
onSelectionChange: _propTypes["default"].func,
|
|
270
|
-
/** The list of ComboBox items (uncontrolled). */
|
|
271
|
-
defaultItems: _isIterable.isIterableProp,
|
|
272
|
-
/** The list of ComboBox items (controlled). */
|
|
273
|
-
items: _isIterable.isIterableProp,
|
|
274
|
-
/**
|
|
275
|
-
* Method that is called when the open state of the menu changes.
|
|
276
|
-
* Returns the new open state and the action that caused the opening of the menu.
|
|
277
|
-
*
|
|
278
|
-
* `(isOpen: boolean, menuTrigger: MenuTriggerAction) => void`
|
|
279
|
-
*/
|
|
280
|
-
onOpenChange: _propTypes["default"].func,
|
|
281
|
-
loadingState: _propTypes["default"].oneOf((0, _values["default"])(_loadingStates["default"])),
|
|
282
|
-
onLoadMore: _propTypes["default"].func,
|
|
283
|
-
/** The default value of the ComboBox input (uncontrolled). */
|
|
284
|
-
defaultInputValue: _propTypes["default"].string,
|
|
285
|
-
/** The value of the ComboBox input (controlled). */
|
|
286
|
-
inputValue: _propTypes["default"].string,
|
|
287
|
-
/**
|
|
288
|
-
* Handler that is called when the ComboBox input value changes.
|
|
289
|
-
*
|
|
290
|
-
* `(value: string) => void`
|
|
291
|
-
*/
|
|
292
|
-
onInputChange: _propTypes["default"].func,
|
|
293
|
-
/** Whether user input is required on the input before form submission. */
|
|
294
|
-
isRequired: _propTypes["default"].bool,
|
|
295
|
-
/** Whether the input is disabled. */
|
|
296
|
-
isDisabled: _propTypes["default"].bool,
|
|
297
|
-
/** Whether the input can be selected but not changed by the user. */
|
|
298
|
-
isReadOnly: _propTypes["default"].bool,
|
|
299
|
-
/** The rendered label for the field. */
|
|
300
|
-
label: _propTypes["default"].node,
|
|
301
|
-
/** Temporary text that occupies the text input when it is empty. */
|
|
302
|
-
placeholder: _propTypes["default"].string,
|
|
303
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
|
304
|
-
id: _propTypes["default"].string,
|
|
305
|
-
/** Whether the element should receive focus on render. */
|
|
306
|
-
hasAutoFocus: _propTypes["default"].bool,
|
|
307
|
-
/** Whether the field has a status indicator. */
|
|
308
|
-
hasNoStatusIndicator: _propTypes["default"].bool,
|
|
309
|
-
/**
|
|
310
|
-
* Handler that is called when the element receives focus.
|
|
311
|
-
*
|
|
312
|
-
* `(e: FocusEvent) => void`
|
|
313
|
-
*/
|
|
314
|
-
onFocus: _propTypes["default"].func,
|
|
315
|
-
/**
|
|
316
|
-
* Handler that is called when the element loses focus.
|
|
317
|
-
*
|
|
318
|
-
* `(e: FocusEvent) => void`
|
|
319
|
-
*/
|
|
320
|
-
onBlur: _propTypes["default"].func,
|
|
321
|
-
/**
|
|
322
|
-
* Handler that is called when the element's focus status changes.
|
|
323
|
-
*
|
|
324
|
-
* `(isFocused: boolean) => void`
|
|
325
|
-
*/
|
|
326
|
-
onFocusChange: _propTypes["default"].func,
|
|
327
|
-
/**
|
|
328
|
-
* Handler that is called when a key is pressed.
|
|
329
|
-
*
|
|
330
|
-
* `(e: KeyboardEvent) => void`
|
|
331
|
-
*/
|
|
332
|
-
onKeyDown: _propTypes["default"].func,
|
|
333
|
-
/**
|
|
334
|
-
* Handler that is called when a key is released.
|
|
335
|
-
*
|
|
336
|
-
* `(e: KeyboardEvent) => void`
|
|
337
|
-
*/
|
|
338
|
-
onKeyUp: _propTypes["default"].func,
|
|
339
|
-
/**
|
|
340
|
-
* Handler that determines the default filtering for items. If undefined, `contains` from
|
|
341
|
-
* [useFilter](https://react-spectrum.adobe.com/react-aria/useFilter.html) is used.
|
|
342
|
-
*
|
|
343
|
-
* `(option: string, inputValue: string) => boolean`
|
|
344
|
-
*/
|
|
345
|
-
defaultFilter: _propTypes["default"].func,
|
|
346
|
-
// /** Props object that is spread directly into the ScrollBox element. */
|
|
347
|
-
/** @ignore */
|
|
348
|
-
scrollBoxProps: _propTypes["default"].shape({
|
|
349
|
-
maxHeight: _propTypes["default"].string
|
|
350
|
-
}),
|
|
351
|
-
/** Props object that is spread directly into the ComboBoxInput element. */
|
|
352
|
-
controlProps: _propTypes["default"].shape({
|
|
353
|
-
onClick: _propTypes["default"].func
|
|
354
|
-
})
|
|
355
|
-
}, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes);
|
|
356
234
|
ComboBoxField.defaultProps = {
|
|
357
235
|
menuTrigger: 'focus',
|
|
358
236
|
direction: 'bottom',
|
|
@@ -340,9 +340,10 @@ var AsyncLoading = exports.AsyncLoading = function AsyncLoading() {
|
|
|
340
340
|
loadingState: loading,
|
|
341
341
|
onLoadMore: handleLoadMore
|
|
342
342
|
}), function (item) {
|
|
343
|
+
var _item$name, _item$name2;
|
|
343
344
|
return (0, _react2.jsx)(_index.Item, {
|
|
344
|
-
key: item.name.given
|
|
345
|
-
}, item.name.given);
|
|
345
|
+
key: (_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name.given
|
|
346
|
+
}, (_item$name2 = item.name) === null || _item$name2 === void 0 ? void 0 : _item$name2.given);
|
|
346
347
|
}));
|
|
347
348
|
};
|
|
348
349
|
var ControlledInput = exports.ControlledInput = function ControlledInput() {
|
|
@@ -421,8 +422,8 @@ var ControlledFiltering = exports.ControlledFiltering = function ControlledFilte
|
|
|
421
422
|
inputValue: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.name,
|
|
422
423
|
selectedKey: key,
|
|
423
424
|
itemsList: (0, _filter["default"])(items).call(items, function (item) {
|
|
424
|
-
var
|
|
425
|
-
return startsWith(item.name, (
|
|
425
|
+
var _name;
|
|
426
|
+
return startsWith(item.name, (_name = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.name) !== null && _name !== void 0 ? _name : '');
|
|
426
427
|
})
|
|
427
428
|
});
|
|
428
429
|
};
|
|
@@ -152,8 +152,8 @@ var ComboBoxWithCustomFilter = function ComboBoxWithCustomFilter() {
|
|
|
152
152
|
inputValue: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.name,
|
|
153
153
|
selectedKey: key,
|
|
154
154
|
itemsList: (0, _filter["default"])(items).call(items, function (item) {
|
|
155
|
-
var
|
|
156
|
-
return startsWith(item.name, (
|
|
155
|
+
var _name;
|
|
156
|
+
return startsWith(item.name, (_name = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.name) !== null && _name !== void 0 ? _name : '');
|
|
157
157
|
})
|
|
158
158
|
});
|
|
159
159
|
};
|
|
@@ -180,7 +180,6 @@ var ComboBoxWithCustomFilter = function ComboBoxWithCustomFilter() {
|
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
return (0, _react3.jsx)(_index.OverlayProvider, null, (0, _react3.jsx)(_index.ComboBoxField, (0, _extends2["default"])({
|
|
183
|
-
label: "Example label",
|
|
184
183
|
items: fieldState.itemsList,
|
|
185
184
|
inputValue: fieldState.inputValue,
|
|
186
185
|
selectedKey: fieldState.selectedKey,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ComboBoxField';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { Key, ReactNode } from 'react';
|
|
2
|
+
import type { AriaButtonProps } from 'react-aria';
|
|
3
|
+
import type { MenuTriggerAction } from '@react-types/combobox';
|
|
4
|
+
import { ContainerProps, ControlProps } from '../hooks/useField/useField';
|
|
5
|
+
import { BoxProps } from './box';
|
|
6
|
+
import { Status } from './item';
|
|
7
|
+
import { loadingState } from './shared';
|
|
8
|
+
export interface ComboBoxInputProps extends Omit<BoxProps, 'children' | 'direction'> {
|
|
9
|
+
containerProps?: Omit<ContainerProps, 'sx'> & {
|
|
10
|
+
sx?: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
controlProps?: ControlProps;
|
|
13
|
+
hasAutoFocus?: boolean;
|
|
14
|
+
helperText?: ReactNode;
|
|
15
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
16
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
|
17
|
+
inputWrapperRef?: React.RefObject<HTMLDivElement>;
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
isOpen?: boolean;
|
|
20
|
+
isReadOnly?: boolean;
|
|
21
|
+
label?: ReactNode;
|
|
22
|
+
labelProps?: React.DOMAttributes<HTMLElement>;
|
|
23
|
+
loadingState?: loadingState;
|
|
24
|
+
menuTrigger?: MenuTriggerAction;
|
|
25
|
+
onInputChange?: (value: string) => void;
|
|
26
|
+
onLoadMore?: () => void;
|
|
27
|
+
onOpenChange?: (isOpen: boolean, menuTrigger?: MenuTriggerAction) => void;
|
|
28
|
+
onSelectionChange?(key: Key | null): void;
|
|
29
|
+
triggerProps?: AriaButtonProps;
|
|
30
|
+
triggerRef?: React.RefObject<HTMLButtonElement>;
|
|
31
|
+
wrapperProps?: Omit<BoxProps, 'sx'> & {
|
|
32
|
+
sx?: Record<string, unknown>;
|
|
33
|
+
};
|
|
34
|
+
/** Determines any status related styling. */
|
|
35
|
+
status?: Status;
|
|
36
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Key, ReactNode } from 'react';
|
|
2
|
+
import type { MenuTriggerAction } from '@react-types/combobox';
|
|
3
|
+
import type { CollectionChildren } from '@react-types/shared';
|
|
4
|
+
import { ControlProps } from '../hooks/useField/useField';
|
|
5
|
+
import { BoxProps } from './box';
|
|
6
|
+
import { Status } from './item';
|
|
7
|
+
import { ScrollBoxProps } from './scrollBox';
|
|
8
|
+
import { Axis, loadingState } from './shared';
|
|
9
|
+
export interface ComboBoxFieldProps<T extends object = object> extends Omit<BoxProps, 'children' | 'direction'> {
|
|
10
|
+
/** Whether or not adding new options to the list is enabled. */
|
|
11
|
+
hasAddOption?: boolean;
|
|
12
|
+
/** Whether the ComboBox allows a non-item matching input value to be set. */
|
|
13
|
+
hasCustomValue?: boolean;
|
|
14
|
+
/** Whether the collection allows empty selection. */
|
|
15
|
+
hasNoEmptySelection?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The item keys that are disabled. These items cannot be selected, focused, or otherwise
|
|
18
|
+
* interacted with.
|
|
19
|
+
*/
|
|
20
|
+
disabledKeys?: Iterable<Key>;
|
|
21
|
+
/** The interaction required to display the ComboBox menu. */
|
|
22
|
+
menuTrigger?: MenuTriggerAction;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the ComboBox menu is prevented from flipping directions when insufficient space is
|
|
25
|
+
* available for the given `direction` placement.
|
|
26
|
+
*/
|
|
27
|
+
isNotFlippable?: boolean;
|
|
28
|
+
/** Where the ComboBox menu opens relative to its trigger. */
|
|
29
|
+
direction?: Axis;
|
|
30
|
+
/** Text rendered below the input. */
|
|
31
|
+
helperText?: ReactNode;
|
|
32
|
+
/** The initial selected key in the collection (uncontrolled). */
|
|
33
|
+
defaultSelectedKey?: string;
|
|
34
|
+
/** The currently selected key in the collection (controlled). */
|
|
35
|
+
selectedKey?: Key | null;
|
|
36
|
+
/**
|
|
37
|
+
* Handler that is called when the selection changes.
|
|
38
|
+
*
|
|
39
|
+
* `(key: Key) => any`
|
|
40
|
+
*/
|
|
41
|
+
onSelectionChange?(key: Key | null): void;
|
|
42
|
+
/** The list of ComboBox items (uncontrolled). */
|
|
43
|
+
defaultItems?: Iterable<T>;
|
|
44
|
+
/** The list of ComboBox items (controlled). */
|
|
45
|
+
items?: Iterable<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Method that is called when the open state of the menu changes.
|
|
48
|
+
* Returns the new open state and the action that caused the opening of the menu.
|
|
49
|
+
*
|
|
50
|
+
* `(isOpen: boolean, menuTrigger: MenuTriggerAction) => void`
|
|
51
|
+
*/
|
|
52
|
+
onOpenChange?: (isOpen: boolean, menuTrigger?: MenuTriggerAction) => void;
|
|
53
|
+
loadingState?: loadingState;
|
|
54
|
+
onLoadMore?: () => void;
|
|
55
|
+
/** The default value of the ComboBox input (uncontrolled). */
|
|
56
|
+
defaultInputValue?: string;
|
|
57
|
+
/** The value of the ComboBox input (controlled). */
|
|
58
|
+
inputValue?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Handler that is called when the ComboBox input value changes.
|
|
61
|
+
*
|
|
62
|
+
* `(value: string) => void`
|
|
63
|
+
*/
|
|
64
|
+
onInputChange?: (value: string) => void;
|
|
65
|
+
/** Whether user input is required on the input before form submission. */
|
|
66
|
+
isRequired?: boolean;
|
|
67
|
+
/** Whether the input is disabled. */
|
|
68
|
+
isDisabled?: boolean;
|
|
69
|
+
/** Whether the input can be selected but not changed by the user. */
|
|
70
|
+
isReadOnly?: boolean;
|
|
71
|
+
/** The rendered label for the field. */
|
|
72
|
+
label?: ReactNode;
|
|
73
|
+
/** Temporary text that occupies the text input when it is empty. */
|
|
74
|
+
placeholder?: string;
|
|
75
|
+
/** Whether the element should receive focus on render. */
|
|
76
|
+
hasAutoFocus?: boolean;
|
|
77
|
+
/** Whether the field has a status indicator. */
|
|
78
|
+
hasNoStatusIndicator?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Handler that determines the default filtering for items. If undefined, `contains` from
|
|
81
|
+
* [useFilter](https://react-spectrum.adobe.com/react-aria/useFilter.html) is used.
|
|
82
|
+
*
|
|
83
|
+
* `(option: string, inputValue: string) => boolean`
|
|
84
|
+
*/
|
|
85
|
+
defaultFilter?: (textValue: string, inputValue: string) => boolean;
|
|
86
|
+
/** @ignore */
|
|
87
|
+
scrollBoxProps?: Omit<ScrollBoxProps, 'sx'> & {
|
|
88
|
+
sx?: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
/** Props object that is spread directly into the ComboBoxInput element. */
|
|
91
|
+
controlProps?: ControlProps;
|
|
92
|
+
/** Whether the collection allows an empty collection. */
|
|
93
|
+
allowsEmptyCollection?: boolean;
|
|
94
|
+
/** The function to render when the collection is empty. */
|
|
95
|
+
renderEmptyState?: () => ReactNode;
|
|
96
|
+
/** Determines any status related styling. */
|
|
97
|
+
status?: Status;
|
|
98
|
+
/** The collection items. */
|
|
99
|
+
children?: CollectionChildren<T>;
|
|
100
|
+
/** Whether the ComboBox menu is currently open (controlled). */
|
|
101
|
+
isOpen?: boolean;
|
|
102
|
+
/** Props object that is spread directly into the ComboBoxInput wrapper element. */
|
|
103
|
+
wrapperProps?: Omit<BoxProps, 'sx'> & {
|
|
104
|
+
sx?: Record<string, unknown>;
|
|
105
|
+
};
|
|
106
|
+
/** Props object that is spread directly into the input wrapper element. */
|
|
107
|
+
containerProps?: Omit<BoxProps, 'sx'> & {
|
|
108
|
+
sx?: Record<string, unknown>;
|
|
109
|
+
};
|
|
110
|
+
}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export * from './codeEditor';
|
|
|
19
19
|
export * from './codeView';
|
|
20
20
|
export * from './collapsiblePanel';
|
|
21
21
|
export * from './colorField';
|
|
22
|
+
export * from './ComboBox';
|
|
23
|
+
export * from './ComboBoxField';
|
|
22
24
|
export * from './copyText';
|
|
23
25
|
export * from './dataTable';
|
|
24
26
|
export * from './datePicker';
|