@pingux/astro 2.242.1-alpha.0 → 2.243.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/MultivaluesField/BadgeLabelTooltip.d.ts +3 -0
- package/lib/cjs/components/MultivaluesField/BadgeLabelTooltip.js +3 -3
- package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.d.ts +4 -0
- package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.js +24 -132
- package/lib/cjs/components/MultivaluesField/DefaultMultivaluesField.d.ts +4 -0
- package/lib/cjs/components/MultivaluesField/DefaultMultivaluesField.js +33 -139
- package/lib/cjs/components/MultivaluesField/MultivaluesField.d.ts +4 -0
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +6 -104
- package/lib/cjs/components/MultivaluesField/index.d.ts +1 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.js +1 -1
- package/lib/cjs/types/MultivaluesField.d.ts +212 -0
- package/lib/cjs/types/MultivaluesField.js +5 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +11 -0
- package/lib/components/MultivaluesField/BadgeLabelTooltip.js +3 -3
- package/lib/components/MultivaluesField/CondensedMultivaluesField.js +24 -132
- package/lib/components/MultivaluesField/DefaultMultivaluesField.js +33 -139
- package/lib/components/MultivaluesField/MultivaluesField.js +7 -105
- package/lib/components/RadioGroupField/RadioGroupField.js +1 -1
- package/lib/types/MultivaluesField.js +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +1 -1
|
@@ -7,121 +7,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var _isIterable = require("../../utils/devUtils/props/isIterable");
|
|
12
|
-
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
|
13
|
-
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
|
14
10
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
|
15
11
|
var _CondensedMultivaluesField = _interopRequireDefault(require("./CondensedMultivaluesField"));
|
|
16
12
|
var _DefaultMultivaluesField = _interopRequireDefault(require("./DefaultMultivaluesField"));
|
|
17
13
|
var _react2 = require("@emotion/react");
|
|
18
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (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 (const 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); }
|
|
15
|
+
const displayName = 'MultivaluesField';
|
|
16
|
+
|
|
17
|
+
// No cast on the forwardRef result: a type assertion makes the react-docgen
|
|
18
|
+
// analyzer fail to extract the props table, which breaks the Storybook docs
|
|
19
|
+
// controls (argTypes lose their types and options).
|
|
19
20
|
const MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
20
21
|
const Component = props.mode === 'condensed' ? _CondensedMultivaluesField.default : _DefaultMultivaluesField.default;
|
|
21
22
|
return (0, _react2.jsx)(Component, (0, _extends2.default)({
|
|
22
23
|
ref: ref
|
|
23
24
|
}, props));
|
|
24
25
|
});
|
|
25
|
-
MultivaluesField.propTypes = {
|
|
26
|
-
/** The initial selected keys in the collection (uncontrolled). */
|
|
27
|
-
defaultSelectedKeys: _isIterable.isIterableProp,
|
|
28
|
-
/** Where the menu opens relative to its trigger. */
|
|
29
|
-
direction: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left']),
|
|
30
|
-
/**
|
|
31
|
-
* The item keys that are disabled. These items cannot be selected.
|
|
32
|
-
*/
|
|
33
|
-
disabledKeys: _isIterable.isIterableProp,
|
|
34
|
-
/** Whether the element should receive focus on render. */
|
|
35
|
-
hasAutoFocus: _propTypes.default.bool,
|
|
36
|
-
/** Whether the field has a status indicator. */
|
|
37
|
-
hasNoStatusIndicator: _propTypes.default.bool,
|
|
38
|
-
/** Text rendered below the input. */
|
|
39
|
-
helperText: _propTypes.default.node,
|
|
40
|
-
/**
|
|
41
|
-
* Props that get passed as-is to the underlying TextField element
|
|
42
|
-
*/
|
|
43
|
-
inputProps: _propTypes.default.shape({}),
|
|
44
|
-
/** Whether the input is disabled. */
|
|
45
|
-
isDisabled: _propTypes.default.bool,
|
|
46
|
-
/**
|
|
47
|
-
* Whether the menu is prevented from flipping directions when insufficient space is
|
|
48
|
-
* available for the given `direction` placement.
|
|
49
|
-
*/
|
|
50
|
-
isNotFlippable: _propTypes.default.bool,
|
|
51
|
-
/** Whether the input can be selected but not changed by the user. */
|
|
52
|
-
isReadOnly: _propTypes.default.bool,
|
|
53
|
-
/** Whether user input is required on the input before form submission. */
|
|
54
|
-
isRequired: _propTypes.default.bool,
|
|
55
|
-
/** The list of items.
|
|
56
|
-
*
|
|
57
|
-
* **Note:** Every item needs to have key and name properties.
|
|
58
|
-
*
|
|
59
|
-
* `Array<{key: string, name: string}>`
|
|
60
|
-
*/
|
|
61
|
-
items: _isIterable.isIterableProp,
|
|
62
|
-
/** The rendered label for the field. */
|
|
63
|
-
label: _propTypes.default.string,
|
|
64
|
-
/** Whether the component allows to create new values or only choose from the selection list */
|
|
65
|
-
mode: _propTypes.default.oneOf(['restrictive', 'non-restrictive', 'condensed']),
|
|
66
|
-
/**
|
|
67
|
-
* Handler that is called when the element loses focus.
|
|
68
|
-
*
|
|
69
|
-
* `(e: FocusEvent) => void`
|
|
70
|
-
*/
|
|
71
|
-
onBlur: _propTypes.default.func,
|
|
72
|
-
/**
|
|
73
|
-
* Handler that is called when the element receives focus.
|
|
74
|
-
*
|
|
75
|
-
* `(e: FocusEvent) => void`
|
|
76
|
-
*/
|
|
77
|
-
onFocus: _propTypes.default.func,
|
|
78
|
-
/**
|
|
79
|
-
* Handler that is called when the input value changes.
|
|
80
|
-
*
|
|
81
|
-
* `(value: string) => void`
|
|
82
|
-
*/
|
|
83
|
-
onInputChange: _propTypes.default.func,
|
|
84
|
-
/**
|
|
85
|
-
* Handler that is called when a key is pressed.
|
|
86
|
-
*
|
|
87
|
-
* `(e: KeyboardEvent) => void`
|
|
88
|
-
*/
|
|
89
|
-
onKeyDown: _propTypes.default.func,
|
|
90
|
-
/**
|
|
91
|
-
* Handler that is called when a key is released.
|
|
92
|
-
*
|
|
93
|
-
* `(e: KeyboardEvent) => void`
|
|
94
|
-
*/
|
|
95
|
-
onKeyUp: _propTypes.default.func,
|
|
96
|
-
/**
|
|
97
|
-
* Method that is called when the open state of the menu changes.
|
|
98
|
-
*
|
|
99
|
-
* `(isOpen: boolean) => void`
|
|
100
|
-
*/
|
|
101
|
-
onOpenChange: _propTypes.default.func,
|
|
102
|
-
/**
|
|
103
|
-
* Handler that is called when the selection changes.
|
|
104
|
-
*
|
|
105
|
-
* `(keys: Iterable<Key>) => any`
|
|
106
|
-
*/
|
|
107
|
-
onSelectionChange: _propTypes.default.func,
|
|
108
|
-
/** Temporary text that occupies the text input when it is empty. */
|
|
109
|
-
placeholder: _propTypes.default.string,
|
|
110
|
-
/**
|
|
111
|
-
* The item keys that are readonly. These items cannot be changed or selected.
|
|
112
|
-
*/
|
|
113
|
-
readOnlyKeys: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
114
|
-
/** The currently selected keys in the collection (controlled). */
|
|
115
|
-
selectedKeys: _isIterable.isIterableProp,
|
|
116
|
-
// /** Props object that is spread directly into the ScrollBox element. */
|
|
117
|
-
/** @ignore */
|
|
118
|
-
scrollBoxProps: _propTypes.default.shape({
|
|
119
|
-
maxHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object, _propTypes.default.number])
|
|
120
|
-
}),
|
|
121
|
-
..._statusProp.statusPropTypes,
|
|
122
|
-
..._ariaAttributes.ariaAttributesBasePropTypes,
|
|
123
|
-
..._fieldAttributes.inputFieldAttributesBasePropTypes
|
|
124
|
-
};
|
|
125
26
|
MultivaluesField.defaultProps = {
|
|
126
27
|
direction: 'bottom',
|
|
127
28
|
isReadOnly: false,
|
|
@@ -130,4 +31,5 @@ MultivaluesField.defaultProps = {
|
|
|
130
31
|
},
|
|
131
32
|
..._statusProp.statusDefaultProp
|
|
132
33
|
};
|
|
34
|
+
MultivaluesField.displayName = displayName;
|
|
133
35
|
var _default = exports.default = MultivaluesField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './MultivaluesField';
|
|
@@ -49,7 +49,7 @@ const RadioGroupField = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
49
49
|
return (0, _react2.jsx)(_.Box, (0, _extends2.default)({
|
|
50
50
|
ref: ref,
|
|
51
51
|
className: classNames
|
|
52
|
-
}, (0, _pendoID.getPendoID)(displayName), unhandledAriaProps, radioGroupProps), (0, _react2.jsx)(_.Label, (0, _extends2.default)({
|
|
52
|
+
}, (0, _pendoID.getPendoID)(displayName), unhandledAriaProps, radioGroupProps), label && (0, _react2.jsx)(_.Label, (0, _extends2.default)({
|
|
53
53
|
isDisabled: isDisabled,
|
|
54
54
|
hintText: hintText,
|
|
55
55
|
isRequired: isRequired,
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { MutableRefObject, ReactNode } from 'react';
|
|
2
|
+
import type { Key, Node, PressEvent } from '@react-types/shared';
|
|
3
|
+
import { Status } from './item';
|
|
4
|
+
import { ScrollBoxProps } from './scrollBox';
|
|
5
|
+
import { Axis, loadingState } from './shared';
|
|
6
|
+
import { TextProps } from './text';
|
|
7
|
+
/** A selected value rendered as a badge, with optional sections in condensed mode. */
|
|
8
|
+
export interface MultivaluesFieldItem {
|
|
9
|
+
/** A unique identifier for the item. */
|
|
10
|
+
id?: string | number;
|
|
11
|
+
/** The key of the item. */
|
|
12
|
+
key?: Key;
|
|
13
|
+
/** The rendered label for the item. */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** Props object that is spread directly into the Badge element. */
|
|
16
|
+
badgeProps?: {
|
|
17
|
+
textProps?: TextProps;
|
|
18
|
+
} & Record<string, unknown>;
|
|
19
|
+
/** Props object that is spread directly into the delete IconButton element. */
|
|
20
|
+
buttonProps?: Record<string, unknown>;
|
|
21
|
+
/** Props object that is spread directly into the Badge slots. */
|
|
22
|
+
slots?: {
|
|
23
|
+
leftIcon?: ReactNode;
|
|
24
|
+
};
|
|
25
|
+
/** Child items, when the item is a section (condensed mode). */
|
|
26
|
+
children?: MultivaluesFieldItem[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Shared field/menu props for both MultivaluesField modes. Consumers should use
|
|
30
|
+
* `CondensedMultivaluesFieldProps`, `DefaultMultivaluesFieldProps`, or the
|
|
31
|
+
* dispatcher type `MultivaluesFieldProps` rather than this interface directly.
|
|
32
|
+
*/
|
|
33
|
+
interface MultivaluesFieldBaseProps {
|
|
34
|
+
/** Identifies the element (or elements) whose contents or presence
|
|
35
|
+
* are controlled by the current element. */
|
|
36
|
+
'aria-controls'?: string;
|
|
37
|
+
/** Identifies the element (or elements) that describes the object. */
|
|
38
|
+
'aria-describedby'?: string;
|
|
39
|
+
/** Identifies the element (or elements) that provide a detailed, extended description
|
|
40
|
+
* for the object. */
|
|
41
|
+
'aria-details'?: string;
|
|
42
|
+
/** Identifies the element that provides an error message for the object. */
|
|
43
|
+
'aria-errormessage'?: string;
|
|
44
|
+
/** Defines a string value that labels the current element. */
|
|
45
|
+
'aria-label'?: string;
|
|
46
|
+
/** Identifies the element (or elements) that labels the current element. */
|
|
47
|
+
'aria-labelledby'?: string;
|
|
48
|
+
/** Props object spread into the outer-most container. Wrapper and label will be children. */
|
|
49
|
+
containerProps?: Record<string, unknown>;
|
|
50
|
+
/** The initial selected keys in the collection (uncontrolled). */
|
|
51
|
+
defaultSelectedKeys?: Iterable<Key>;
|
|
52
|
+
/** Where the menu opens relative to its trigger. */
|
|
53
|
+
direction?: Axis;
|
|
54
|
+
/**
|
|
55
|
+
* The item keys that are disabled. These items cannot be selected.
|
|
56
|
+
*/
|
|
57
|
+
disabledKeys?: Key[];
|
|
58
|
+
/** A function that filters the items in the collection. If undefined, the
|
|
59
|
+
* component's default filtering is used. */
|
|
60
|
+
filter?: (nodes: Iterable<Node<object>>) => Iterable<Node<object>>;
|
|
61
|
+
/** Whether the element should receive focus on render. */
|
|
62
|
+
hasAutoFocus?: boolean;
|
|
63
|
+
/** Whether the field has a status indicator. */
|
|
64
|
+
hasNoStatusIndicator?: boolean;
|
|
65
|
+
/** Text rendered below the input. */
|
|
66
|
+
helperText?: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* Props that get passed as-is to the underlying TextField element
|
|
69
|
+
*/
|
|
70
|
+
inputProps?: Record<string, unknown>;
|
|
71
|
+
/** Whether the input is disabled. */
|
|
72
|
+
isDisabled?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the menu is prevented from flipping directions when insufficient space is
|
|
75
|
+
* available for the given `direction` placement.
|
|
76
|
+
*/
|
|
77
|
+
isNotFlippable?: boolean;
|
|
78
|
+
/** Whether the input can be selected but not changed by the user. */
|
|
79
|
+
isReadOnly?: boolean;
|
|
80
|
+
/** Whether user input is required on the input before form submission. */
|
|
81
|
+
isRequired?: boolean;
|
|
82
|
+
/** The list of items.
|
|
83
|
+
*
|
|
84
|
+
* **Note:** Every item needs to have key and name properties.
|
|
85
|
+
*/
|
|
86
|
+
items?: MultivaluesFieldItem[];
|
|
87
|
+
/** The rendered label for the field. */
|
|
88
|
+
label?: ReactNode;
|
|
89
|
+
/** The contents of the collection. Supports item render props (as children). */
|
|
90
|
+
children?: ReactNode | ((item: MultivaluesFieldItem) => ReactNode);
|
|
91
|
+
/** Whether the component allows to create new values or only choose from the selection list */
|
|
92
|
+
mode?: 'restrictive' | 'non-restrictive' | 'condensed';
|
|
93
|
+
/** Whether the items are currently loading. */
|
|
94
|
+
loadingState?: loadingState;
|
|
95
|
+
/**
|
|
96
|
+
* Handler that is called when the element loses focus.
|
|
97
|
+
*/
|
|
98
|
+
onBlur?: (e: FocusEvent) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Handler that is called when the element receives focus.
|
|
101
|
+
*/
|
|
102
|
+
onFocus?: (e: FocusEvent) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Handler that is called when the input value changes.
|
|
105
|
+
*/
|
|
106
|
+
onInputChange?: (value: string) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Handler that is called when a key is pressed.
|
|
109
|
+
*/
|
|
110
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Handler that is called when a key is released.
|
|
113
|
+
*/
|
|
114
|
+
onKeyUp?: (e: KeyboardEvent) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Handler that is called when more items should be loaded, e.g. while scrolling near the bottom.
|
|
117
|
+
*/
|
|
118
|
+
onLoadMore?: () => unknown;
|
|
119
|
+
/**
|
|
120
|
+
* Handler that is called when more items should be loaded, e.g. while scrolling near the top.
|
|
121
|
+
*/
|
|
122
|
+
onLoadPrev?: () => unknown;
|
|
123
|
+
/**
|
|
124
|
+
* Method that is called when the open state of the menu changes.
|
|
125
|
+
*/
|
|
126
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Handler that is called when the selection changes.
|
|
129
|
+
*/
|
|
130
|
+
onSelectionChange?: (keys: Iterable<Key>) => unknown;
|
|
131
|
+
/** Temporary text that occupies the text input when it is empty. */
|
|
132
|
+
placeholder?: string;
|
|
133
|
+
/** Props object that is spread directly into the input element. Will be a child
|
|
134
|
+
* of the Wrapper. */
|
|
135
|
+
controlProps?: Record<string, unknown>;
|
|
136
|
+
/** Props object spread to the field control wrapper, i.e. the immediate parent
|
|
137
|
+
* element for the control, sibling of the label, and child of the field container. */
|
|
138
|
+
controlWrapperProps?: Record<string, unknown>;
|
|
139
|
+
/** Props object spread to the field label, i.e. the visible text which labels the control. */
|
|
140
|
+
labelProps?: Record<string, unknown>;
|
|
141
|
+
/** The currently selected keys in the collection (controlled). */
|
|
142
|
+
selectedKeys?: Iterable<Key>;
|
|
143
|
+
/** @ignore Props object that is spread directly into the ScrollBox element. */
|
|
144
|
+
scrollBoxProps?: ScrollBoxProps;
|
|
145
|
+
/** Determines any status related styling. */
|
|
146
|
+
status?: Status;
|
|
147
|
+
}
|
|
148
|
+
/** Props for the MultivaluesField in `condensed` mode. */
|
|
149
|
+
export interface CondensedMultivaluesFieldProps extends MultivaluesFieldBaseProps {
|
|
150
|
+
/** Whether the component allows to create new values or only choose from the selection list */
|
|
151
|
+
mode?: 'condensed';
|
|
152
|
+
/** Whether the field has the select all button. */
|
|
153
|
+
hasNoSelectAll?: boolean;
|
|
154
|
+
/** Whether filtering of the options list is disabled. */
|
|
155
|
+
isFilteringDisabled?: boolean;
|
|
156
|
+
/** Text describing the currently selected options in place of the default count. */
|
|
157
|
+
selectedOptionText?: string;
|
|
158
|
+
}
|
|
159
|
+
/** Props for the MultivaluesField in `restrictive` or `non-restrictive` mode. */
|
|
160
|
+
export interface DefaultMultivaluesFieldProps extends MultivaluesFieldBaseProps {
|
|
161
|
+
/** Whether the component allows to create new values or only choose from the selection list */
|
|
162
|
+
mode?: 'restrictive' | 'non-restrictive';
|
|
163
|
+
/** Whether filtering of the options list is disabled. */
|
|
164
|
+
isFilteringDisabled?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* The item keys that are readonly. These items cannot be changed or selected.
|
|
167
|
+
*/
|
|
168
|
+
readOnlyKeys?: string[];
|
|
169
|
+
/** Props object spread into the outer-most container. */
|
|
170
|
+
multivaluesProps?: Record<string, unknown>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Mode-specific props that either mode may accept. The original dispatcher's
|
|
174
|
+
* PropTypes declared all of these on the parent component, so the dispatcher
|
|
175
|
+
* type exposes them as optional members regardless of the active `mode`.
|
|
176
|
+
*/
|
|
177
|
+
interface MultivaluesFieldModeProps {
|
|
178
|
+
/** Whether the field has the select all button (condensed mode). */
|
|
179
|
+
hasNoSelectAll?: boolean;
|
|
180
|
+
/** Whether filtering of the options list is disabled. */
|
|
181
|
+
isFilteringDisabled?: boolean;
|
|
182
|
+
/** Text describing the currently selected options in place of the default count. */
|
|
183
|
+
selectedOptionText?: string;
|
|
184
|
+
/** The item keys that are readonly. These items cannot be changed or selected. */
|
|
185
|
+
readOnlyKeys?: string[];
|
|
186
|
+
/** Props object spread into the outer-most container (default mode). */
|
|
187
|
+
multivaluesProps?: Record<string, unknown>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Props for the MultivaluesField dispatcher. Accepts the props of either mode.
|
|
191
|
+
*
|
|
192
|
+
* Note: this deliberately avoids `Omit`/intersection-based composition.
|
|
193
|
+
* react-docgen (used by Storybook to extract the props table) only resolves
|
|
194
|
+
* plain interface inheritance; an unresolved extends clause or an intersection
|
|
195
|
+
* type silently produces an empty props table in the docs.
|
|
196
|
+
*/
|
|
197
|
+
export interface MultivaluesFieldProps extends MultivaluesFieldBaseProps, MultivaluesFieldModeProps {
|
|
198
|
+
}
|
|
199
|
+
/** Props for the badge rendered for each selected item in the default mode. */
|
|
200
|
+
export interface BadgeLabelTooltipProps {
|
|
201
|
+
/** The selected item to render as a badge. */
|
|
202
|
+
item: MultivaluesFieldItem;
|
|
203
|
+
/** The index of the badge in the selected items list. */
|
|
204
|
+
index: number;
|
|
205
|
+
/**
|
|
206
|
+
* Handler that is called when the badge's delete button is pressed.
|
|
207
|
+
*/
|
|
208
|
+
deleteItem: (key: Key, e: PressEvent) => void;
|
|
209
|
+
/** Refs to the badge delete buttons, used to manage focus when badges are removed. */
|
|
210
|
+
closeBadgeRefs: MutableRefObject<(HTMLDivElement | HTMLButtonElement | null)[]>;
|
|
211
|
+
}
|
|
212
|
+
export {};
|
package/lib/cjs/types/index.d.ts
CHANGED
package/lib/cjs/types/index.js
CHANGED
|
@@ -608,6 +608,17 @@ Object.keys(_Modal).forEach(function (key) {
|
|
|
608
608
|
}
|
|
609
609
|
});
|
|
610
610
|
});
|
|
611
|
+
var _MultivaluesField = require("./MultivaluesField");
|
|
612
|
+
Object.keys(_MultivaluesField).forEach(function (key) {
|
|
613
|
+
if (key === "default" || key === "__esModule") return;
|
|
614
|
+
if (key in exports && exports[key] === _MultivaluesField[key]) return;
|
|
615
|
+
Object.defineProperty(exports, key, {
|
|
616
|
+
enumerable: true,
|
|
617
|
+
get: function () {
|
|
618
|
+
return _MultivaluesField[key];
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
});
|
|
611
622
|
var _navBar = require("./navBar");
|
|
612
623
|
Object.keys(_navBar).forEach(function (key) {
|
|
613
624
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -13,13 +13,13 @@ const BadgeLabelTooltip = ({
|
|
|
13
13
|
deleteItem,
|
|
14
14
|
closeBadgeRefs
|
|
15
15
|
}) => {
|
|
16
|
-
const isLong = item.name.length > BADGE_TOOLTIP_CHAR_THRESHOLD;
|
|
16
|
+
const isLong = (item.name || '').length > BADGE_TOOLTIP_CHAR_THRESHOLD;
|
|
17
17
|
const {
|
|
18
18
|
hoverProps,
|
|
19
19
|
isHovered
|
|
20
20
|
} = useHover({});
|
|
21
21
|
const textProps = mergeProps(item.badgeProps?.textProps || {}, hoverProps);
|
|
22
|
-
const badgeRef = useRef();
|
|
22
|
+
const badgeRef = useRef(null);
|
|
23
23
|
return ___EmotionJSX(Box, {
|
|
24
24
|
as: "li"
|
|
25
25
|
}, ___EmotionJSX(TooltipTrigger, {
|
|
@@ -39,7 +39,7 @@ const BadgeLabelTooltip = ({
|
|
|
39
39
|
}), ___EmotionJSX(IconButton, _extends({
|
|
40
40
|
"aria-label": `delete ${item.name}`,
|
|
41
41
|
"data-item": item.name,
|
|
42
|
-
onPress: e => deleteItem(item.key, e),
|
|
42
|
+
onPress: e => item.key !== undefined && deleteItem(item.key, e),
|
|
43
43
|
ref: el => closeBadgeRefs.current[index] = el // eslint-disable-line
|
|
44
44
|
,
|
|
45
45
|
variant: "badge.deleteButton",
|
|
@@ -6,23 +6,19 @@ import { useFocusWithin } from '@react-aria/interactions';
|
|
|
6
6
|
import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
|
|
7
7
|
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
8
8
|
import { useListState } from '@react-stately/list';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
9
|
import { Box, Button, Icon, Loader, ScrollBox, Text, TextField } from '../..';
|
|
11
10
|
import { MultivaluesContext } from '../../context/MultivaluesContext';
|
|
12
11
|
import { useGetTheme, useInputLoader, usePropWarning } from '../../hooks';
|
|
13
12
|
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
|
14
13
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
|
15
|
-
import
|
|
16
|
-
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
|
17
|
-
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
|
18
|
-
import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusProp';
|
|
14
|
+
import statuses from '../../utils/devUtils/constants/statuses';
|
|
19
15
|
import ListBox from '../ListBox';
|
|
20
16
|
import Popover from '../Popover/Popover';
|
|
21
17
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
22
18
|
const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
23
19
|
const {
|
|
24
20
|
defaultSelectedKeys,
|
|
25
|
-
direction,
|
|
21
|
+
direction = 'bottom',
|
|
26
22
|
disabledKeys = [],
|
|
27
23
|
containerProps,
|
|
28
24
|
filter,
|
|
@@ -34,7 +30,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
34
30
|
isDisabled,
|
|
35
31
|
isFilteringDisabled,
|
|
36
32
|
isNotFlippable,
|
|
37
|
-
isReadOnly,
|
|
33
|
+
isReadOnly = false,
|
|
38
34
|
isRequired,
|
|
39
35
|
items,
|
|
40
36
|
label,
|
|
@@ -52,8 +48,10 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
52
48
|
placeholder,
|
|
53
49
|
selectedKeys,
|
|
54
50
|
selectedOptionText: selectedOptionTextProp,
|
|
55
|
-
scrollBoxProps
|
|
56
|
-
|
|
51
|
+
scrollBoxProps = {
|
|
52
|
+
maxHeight: 300
|
|
53
|
+
},
|
|
54
|
+
status = statuses.DEFAULT,
|
|
57
55
|
...others
|
|
58
56
|
} = props;
|
|
59
57
|
usePropWarning(props, 'disabled', 'isDisabled');
|
|
@@ -61,9 +59,9 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
61
59
|
const [isOpen, setIsOpen] = useState(false);
|
|
62
60
|
const [hasFocusWithin, setFocusWithin] = useState(false);
|
|
63
61
|
const [activeDescendant, setActiveDescendant] = useState('');
|
|
64
|
-
const inputWrapperRef = useRef();
|
|
65
|
-
const inputRef = useRef();
|
|
66
|
-
const buttonRef = useRef();
|
|
62
|
+
const inputWrapperRef = useRef(null);
|
|
63
|
+
const inputRef = useRef(null);
|
|
64
|
+
const buttonRef = useRef(null);
|
|
67
65
|
const {
|
|
68
66
|
icons,
|
|
69
67
|
themeState: {
|
|
@@ -133,8 +131,8 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
133
131
|
useImperativeHandle(ref, () => inputWrapperRef.current);
|
|
134
132
|
/* istanbul ignore next */
|
|
135
133
|
useImperativeHandle(ref, () => inputRef.current);
|
|
136
|
-
const listBoxRef = useRef();
|
|
137
|
-
const popoverRef = useRef();
|
|
134
|
+
const listBoxRef = useRef(null);
|
|
135
|
+
const popoverRef = useRef(null);
|
|
138
136
|
|
|
139
137
|
// Measure the width of the input to inform the width of the menu (below).
|
|
140
138
|
const [menuWidth, setMenuWidth] = useState(null);
|
|
@@ -214,11 +212,15 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
214
212
|
setIsOpen(false);
|
|
215
213
|
};
|
|
216
214
|
const [selectionState, setSelectionState] = useState('Select All');
|
|
217
|
-
const arrayItems =
|
|
215
|
+
const arrayItems = items || [];
|
|
218
216
|
const itemCount = arrayItems.reduce((count, obj) => count + (obj.children ? obj.children.length : 1), 0);
|
|
219
217
|
const selectedKeysSize = selectionManager.selectedKeys.size;
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
|
|
219
|
+
// `selectionManager.state` is private in the react-stately typings but is
|
|
220
|
+
// read throughout this component; the access is kept via a cast.
|
|
221
|
+
const selectionManagerState = selectionManager.state;
|
|
222
|
+
const selectedOptionText = selectedOptionTextProp || `${itemCount === selectedKeysSize ? 'All' : selectionManagerState.selectedKeys?.size} Selected`;
|
|
223
|
+
const checkboxSelected = selectionManagerState.selectedKeys?.size !== 0 && ___EmotionJSX(Text, {
|
|
222
224
|
color: "text.secondary"
|
|
223
225
|
}, selectedOptionText);
|
|
224
226
|
useEffect(() => {
|
|
@@ -228,7 +230,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
228
230
|
}, [itemCount, selectedKeysSize]);
|
|
229
231
|
const handleSelection = () => {
|
|
230
232
|
if (selectedKeysSize < itemCount) {
|
|
231
|
-
const allItemNames = arrayItems.flatMap(obj => obj.children ? obj.children.map(child => child.key) : obj.key);
|
|
233
|
+
const allItemNames = arrayItems.flatMap(obj => obj.children ? obj.children.map(child => child.key) : obj.key).filter(key => key !== undefined);
|
|
232
234
|
selectionManager.setSelectedKeys(allItemNames);
|
|
233
235
|
setSelectionState('Deselect All');
|
|
234
236
|
} else if (selectionState === 'Deselect All') {
|
|
@@ -274,7 +276,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
274
276
|
id: "emptyKeysState"
|
|
275
277
|
}, "Nothing Selected");
|
|
276
278
|
};
|
|
277
|
-
const placeholderText =
|
|
279
|
+
const placeholderText = selectionManagerState.selectedKeys?.size === 0 ? placeholder || 'Select' : '';
|
|
278
280
|
const inputProps = {
|
|
279
281
|
...customInputProps,
|
|
280
282
|
controlProps: {
|
|
@@ -292,7 +294,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
292
294
|
isDisabled,
|
|
293
295
|
isReadOnly,
|
|
294
296
|
isRequired,
|
|
295
|
-
label,
|
|
297
|
+
label: label,
|
|
296
298
|
placeholder: placeholderText,
|
|
297
299
|
wrapperProps: {
|
|
298
300
|
ref: inputWrapperRef,
|
|
@@ -307,7 +309,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
307
309
|
const handleButtonPress = () => {
|
|
308
310
|
if (!isOpen) {
|
|
309
311
|
setIsOpen(true);
|
|
310
|
-
inputRef.current
|
|
312
|
+
inputRef.current?.focus();
|
|
311
313
|
} else {
|
|
312
314
|
setIsOpen(false);
|
|
313
315
|
}
|
|
@@ -367,7 +369,7 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
367
369
|
beforeInput: ___EmotionJSX(React.Fragment, null, checkboxSelected, selectionManager.selectedKeys.size > 0 && visuallyHidden)
|
|
368
370
|
},
|
|
369
371
|
value: filterString,
|
|
370
|
-
helperText
|
|
372
|
+
helperText,
|
|
371
373
|
"aria-invalid": status === 'error' && true
|
|
372
374
|
}, getPendoID('MultivaluesField'), others, inputProps)), ___EmotionJSX(Popover, {
|
|
373
375
|
hasNoArrow: true,
|
|
@@ -382,114 +384,4 @@ const CondensedMultivaluesField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
382
384
|
onBlur: e => handleBlur(e)
|
|
383
385
|
}, listbox), ___EmotionJSX(EmptyVisuallyHidden, null)));
|
|
384
386
|
});
|
|
385
|
-
CondensedMultivaluesField.propTypes = {
|
|
386
|
-
/** The initial selected keys in the collection (uncontrolled). */
|
|
387
|
-
defaultSelectedKeys: isIterableProp,
|
|
388
|
-
/** Where the menu opens relative to its trigger. */
|
|
389
|
-
direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
|
390
|
-
/**
|
|
391
|
-
* The item keys that are disabled. These items cannot be selected.
|
|
392
|
-
*/
|
|
393
|
-
disabledKeys: isIterableProp,
|
|
394
|
-
/** Whether the element should receive focus on render. */
|
|
395
|
-
hasAutoFocus: PropTypes.bool,
|
|
396
|
-
/** Whether the field has the select all button. */
|
|
397
|
-
hasNoSelectAll: PropTypes.bool,
|
|
398
|
-
/** Whether the field has a status indicator. */
|
|
399
|
-
hasNoStatusIndicator: PropTypes.bool,
|
|
400
|
-
/** Text rendered below the input. */
|
|
401
|
-
helperText: PropTypes.node,
|
|
402
|
-
/**
|
|
403
|
-
* Props that get passed as-is to the underlying TextField element
|
|
404
|
-
*/
|
|
405
|
-
inputProps: PropTypes.shape({}),
|
|
406
|
-
/** Whether the input is disabled. */
|
|
407
|
-
isDisabled: PropTypes.bool,
|
|
408
|
-
/**
|
|
409
|
-
* Whether the menu is prevented from flipping directions when insufficient space is
|
|
410
|
-
* available for the given `direction` placement.
|
|
411
|
-
*/
|
|
412
|
-
isNotFlippable: PropTypes.bool,
|
|
413
|
-
/** Whether the input can be selected but not changed by the user. */
|
|
414
|
-
isReadOnly: PropTypes.bool,
|
|
415
|
-
/** Whether user input is required on the input before form submission. */
|
|
416
|
-
isRequired: PropTypes.bool,
|
|
417
|
-
/** The list of items.
|
|
418
|
-
*
|
|
419
|
-
* **Note:** Every item needs to have key and name properties.
|
|
420
|
-
*
|
|
421
|
-
* `Array<{key: string, name: string}>`
|
|
422
|
-
*/
|
|
423
|
-
items: isIterableProp,
|
|
424
|
-
/** The rendered label for the field. */
|
|
425
|
-
label: PropTypes.string,
|
|
426
|
-
/** Whether the component allows to create new values or only choose from the selection list */
|
|
427
|
-
mode: PropTypes.oneOf(['restrictive', 'non-restrictive', 'condensed']),
|
|
428
|
-
/**
|
|
429
|
-
* Handler that is called when the element loses focus.
|
|
430
|
-
*
|
|
431
|
-
* `(e: FocusEvent) => void`
|
|
432
|
-
*/
|
|
433
|
-
onBlur: PropTypes.func,
|
|
434
|
-
/**
|
|
435
|
-
* Handler that is called when the element receives focus.
|
|
436
|
-
*
|
|
437
|
-
* `(e: FocusEvent) => void`
|
|
438
|
-
*/
|
|
439
|
-
onFocus: PropTypes.func,
|
|
440
|
-
/**
|
|
441
|
-
* Handler that is called when the input value changes.
|
|
442
|
-
*
|
|
443
|
-
* `(value: string) => void`
|
|
444
|
-
*/
|
|
445
|
-
onInputChange: PropTypes.func,
|
|
446
|
-
/**
|
|
447
|
-
* Handler that is called when a key is pressed.
|
|
448
|
-
*
|
|
449
|
-
* `(e: KeyboardEvent) => void`
|
|
450
|
-
*/
|
|
451
|
-
onKeyDown: PropTypes.func,
|
|
452
|
-
/**
|
|
453
|
-
* Handler that is called when a key is released.
|
|
454
|
-
*
|
|
455
|
-
* `(e: KeyboardEvent) => void`
|
|
456
|
-
*/
|
|
457
|
-
onKeyUp: PropTypes.func,
|
|
458
|
-
/**
|
|
459
|
-
* Method that is called when the open state of the menu changes.
|
|
460
|
-
*
|
|
461
|
-
* `(isOpen: boolean) => void`
|
|
462
|
-
*/
|
|
463
|
-
onOpenChange: PropTypes.func,
|
|
464
|
-
/**
|
|
465
|
-
* Handler that is called when the selection changes.
|
|
466
|
-
*
|
|
467
|
-
* `(keys: Iterable<Key>) => any`
|
|
468
|
-
*/
|
|
469
|
-
onSelectionChange: PropTypes.func,
|
|
470
|
-
/** Temporary text that occupies the text input when it is empty. */
|
|
471
|
-
placeholder: PropTypes.string,
|
|
472
|
-
/**
|
|
473
|
-
* The item keys that are readonly. These items cannot be changed or selected.
|
|
474
|
-
*/
|
|
475
|
-
readOnlyKeys: PropTypes.arrayOf(PropTypes.string),
|
|
476
|
-
/** The currently selected keys in the collection (controlled). */
|
|
477
|
-
selectedKeys: isIterableProp,
|
|
478
|
-
// /** Props object that is spread directly into the ScrollBox element. */
|
|
479
|
-
/** @ignore */
|
|
480
|
-
scrollBoxProps: PropTypes.shape({
|
|
481
|
-
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number])
|
|
482
|
-
}),
|
|
483
|
-
...statusPropTypes,
|
|
484
|
-
...ariaAttributesBasePropTypes,
|
|
485
|
-
...inputFieldAttributesBasePropTypes
|
|
486
|
-
};
|
|
487
|
-
CondensedMultivaluesField.defaultProps = {
|
|
488
|
-
direction: 'bottom',
|
|
489
|
-
isReadOnly: false,
|
|
490
|
-
scrollBoxProps: {
|
|
491
|
-
maxHeight: 300
|
|
492
|
-
},
|
|
493
|
-
...statusDefaultProp
|
|
494
|
-
};
|
|
495
387
|
export default CondensedMultivaluesField;
|