@canonical/react-components 3.0.1 → 3.1.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/dist/components/MultiSelect/MultiSelect.d.ts +1 -0
- package/dist/components/MultiSelect/MultiSelect.js +7 -4
- package/dist/components/MultiSelect/MultiSelect.stories.js +4 -2
- package/dist/esm/components/MultiSelect/MultiSelect.d.ts +1 -0
- package/dist/esm/components/MultiSelect/MultiSelect.js +7 -4
- package/dist/esm/components/MultiSelect/MultiSelect.stories.js +4 -2
- package/package.json +2 -2
|
@@ -28,6 +28,7 @@ export type MultiSelectProps = {
|
|
|
28
28
|
scrollOverflow?: boolean;
|
|
29
29
|
isSortedAlphabetically?: boolean;
|
|
30
30
|
hasSelectedItemsFirst?: boolean;
|
|
31
|
+
id?: string;
|
|
31
32
|
};
|
|
32
33
|
type GroupFn = (items: Parameters<typeof getGroupedItems>[0]) => ReturnType<typeof getGroupedItems>;
|
|
33
34
|
type SortFn = typeof sortAlphabetically;
|
|
@@ -178,7 +178,8 @@ const MultiSelect = _ref4 => {
|
|
|
178
178
|
variant = "search",
|
|
179
179
|
scrollOverflow = false,
|
|
180
180
|
isSortedAlphabetically = true,
|
|
181
|
-
hasSelectedItemsFirst = true
|
|
181
|
+
hasSelectedItemsFirst = true,
|
|
182
|
+
id
|
|
182
183
|
} = _ref4;
|
|
183
184
|
const buttonRef = (0, _react.useRef)(null);
|
|
184
185
|
const [isDropdownOpen, setIsDropdownOpen] = (0, _react.useState)(false);
|
|
@@ -229,7 +230,7 @@ const MultiSelect = _ref4 => {
|
|
|
229
230
|
externallyControlled: true,
|
|
230
231
|
"aria-controls": dropdownId,
|
|
231
232
|
"aria-expanded": isDropdownOpen,
|
|
232
|
-
id: inputId,
|
|
233
|
+
id: id !== null && id !== void 0 ? id : inputId,
|
|
233
234
|
role: "combobox",
|
|
234
235
|
"aria-label": label || placeholder || "Search",
|
|
235
236
|
disabled: disabled,
|
|
@@ -268,7 +269,8 @@ const MultiSelect = _ref4 => {
|
|
|
268
269
|
event.stopPropagation();
|
|
269
270
|
}
|
|
270
271
|
},
|
|
271
|
-
ref: buttonRef
|
|
272
|
+
ref: buttonRef,
|
|
273
|
+
id: id
|
|
272
274
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
273
275
|
className: "multi-select__condensed-text"
|
|
274
276
|
}, listSelected && selectedItems.length > 0 ? selectedItemsLabel : placeholder !== null && placeholder !== void 0 ? placeholder : "Select items")),
|
|
@@ -323,5 +325,6 @@ MultiSelect.propTypes = {
|
|
|
323
325
|
variant: _propTypes.default.oneOf(["condensed", "search"]),
|
|
324
326
|
scrollOverflow: _propTypes.default.bool,
|
|
325
327
|
isSortedAlphabetically: _propTypes.default.bool,
|
|
326
|
-
hasSelectedItemsFirst: _propTypes.default.bool
|
|
328
|
+
hasSelectedItemsFirst: _propTypes.default.bool,
|
|
329
|
+
id: _propTypes.default.string
|
|
327
330
|
};
|
|
@@ -53,7 +53,8 @@ const SearchExample = exports.SearchExample = {
|
|
|
53
53
|
items: [...CondensedExample.args.items.map((item, i) => ({
|
|
54
54
|
...item,
|
|
55
55
|
group: i % 2 === 0 ? "Group 1" : "Group 2"
|
|
56
|
-
}))]
|
|
56
|
+
}))],
|
|
57
|
+
id: "search-id"
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
const WithDisabledItems = exports.WithDisabledItems = {
|
|
@@ -104,6 +105,7 @@ const WithoutSorting = exports.WithoutSorting = {
|
|
|
104
105
|
}],
|
|
105
106
|
variant: "condensed",
|
|
106
107
|
isSortedAlphabetically: false,
|
|
107
|
-
hasSelectedItemsFirst: false
|
|
108
|
+
hasSelectedItemsFirst: false,
|
|
109
|
+
id: "external-id"
|
|
108
110
|
}
|
|
109
111
|
};
|
|
@@ -28,6 +28,7 @@ export type MultiSelectProps = {
|
|
|
28
28
|
scrollOverflow?: boolean;
|
|
29
29
|
isSortedAlphabetically?: boolean;
|
|
30
30
|
hasSelectedItemsFirst?: boolean;
|
|
31
|
+
id?: string;
|
|
31
32
|
};
|
|
32
33
|
type GroupFn = (items: Parameters<typeof getGroupedItems>[0]) => ReturnType<typeof getGroupedItems>;
|
|
33
34
|
type SortFn = typeof sortAlphabetically;
|
|
@@ -171,7 +171,8 @@ export var MultiSelect = _ref4 => {
|
|
|
171
171
|
variant = "search",
|
|
172
172
|
scrollOverflow = false,
|
|
173
173
|
isSortedAlphabetically = true,
|
|
174
|
-
hasSelectedItemsFirst = true
|
|
174
|
+
hasSelectedItemsFirst = true,
|
|
175
|
+
id
|
|
175
176
|
} = _ref4;
|
|
176
177
|
var buttonRef = useRef(null);
|
|
177
178
|
var [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
@@ -222,7 +223,7 @@ export var MultiSelect = _ref4 => {
|
|
|
222
223
|
externallyControlled: true,
|
|
223
224
|
"aria-controls": dropdownId,
|
|
224
225
|
"aria-expanded": isDropdownOpen,
|
|
225
|
-
id: inputId,
|
|
226
|
+
id: id !== null && id !== void 0 ? id : inputId,
|
|
226
227
|
role: "combobox",
|
|
227
228
|
"aria-label": label || placeholder || "Search",
|
|
228
229
|
disabled: disabled,
|
|
@@ -261,7 +262,8 @@ export var MultiSelect = _ref4 => {
|
|
|
261
262
|
event.stopPropagation();
|
|
262
263
|
}
|
|
263
264
|
},
|
|
264
|
-
ref: buttonRef
|
|
265
|
+
ref: buttonRef,
|
|
266
|
+
id: id
|
|
265
267
|
}, /*#__PURE__*/React.createElement("span", {
|
|
266
268
|
className: "multi-select__condensed-text"
|
|
267
269
|
}, listSelected && selectedItems.length > 0 ? selectedItemsLabel : placeholder !== null && placeholder !== void 0 ? placeholder : "Select items")),
|
|
@@ -315,5 +317,6 @@ MultiSelect.propTypes = {
|
|
|
315
317
|
variant: _pt.oneOf(["condensed", "search"]),
|
|
316
318
|
scrollOverflow: _pt.bool,
|
|
317
319
|
isSortedAlphabetically: _pt.bool,
|
|
318
|
-
hasSelectedItemsFirst: _pt.bool
|
|
320
|
+
hasSelectedItemsFirst: _pt.bool,
|
|
321
|
+
id: _pt.string
|
|
319
322
|
};
|
|
@@ -49,7 +49,8 @@ export var SearchExample = {
|
|
|
49
49
|
variant: "search",
|
|
50
50
|
items: [...CondensedExample.args.items.map((item, i) => _objectSpread(_objectSpread({}, item), {}, {
|
|
51
51
|
group: i % 2 === 0 ? "Group 1" : "Group 2"
|
|
52
|
-
}))]
|
|
52
|
+
}))],
|
|
53
|
+
id: "search-id"
|
|
53
54
|
})
|
|
54
55
|
};
|
|
55
56
|
export var WithDisabledItems = {
|
|
@@ -99,6 +100,7 @@ export var WithoutSorting = {
|
|
|
99
100
|
}],
|
|
100
101
|
variant: "condensed",
|
|
101
102
|
isSortedAlphabetically: false,
|
|
102
|
-
hasSelectedItemsFirst: false
|
|
103
|
+
hasSelectedItemsFirst: false,
|
|
104
|
+
id: "external-id"
|
|
103
105
|
}
|
|
104
106
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"tsc-alias": "1.8.10",
|
|
94
94
|
"typescript": "5.7.3",
|
|
95
95
|
"typescript-eslint": "8.24.1",
|
|
96
|
-
"vanilla-framework": "4.
|
|
96
|
+
"vanilla-framework": "4.34.1",
|
|
97
97
|
"wait-on": "8.0.2",
|
|
98
98
|
"webpack": "5.98.0"
|
|
99
99
|
},
|