@canonical/react-components 3.0.1 → 3.1.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.
@@ -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,9 @@ const MultiSelect = _ref4 => {
268
269
  event.stopPropagation();
269
270
  }
270
271
  },
271
- ref: buttonRef
272
+ ref: buttonRef,
273
+ id: id,
274
+ disabled: disabled
272
275
  }, /*#__PURE__*/_react.default.createElement("span", {
273
276
  className: "multi-select__condensed-text"
274
277
  }, listSelected && selectedItems.length > 0 ? selectedItemsLabel : placeholder !== null && placeholder !== void 0 ? placeholder : "Select items")),
@@ -323,5 +326,6 @@ MultiSelect.propTypes = {
323
326
  variant: _propTypes.default.oneOf(["condensed", "search"]),
324
327
  scrollOverflow: _propTypes.default.bool,
325
328
  isSortedAlphabetically: _propTypes.default.bool,
326
- hasSelectedItemsFirst: _propTypes.default.bool
329
+ hasSelectedItemsFirst: _propTypes.default.bool,
330
+ id: _propTypes.default.string
327
331
  };
@@ -149,4 +149,9 @@ $dropdown-max-height: 20rem;
149
149
  transform: translateY(-50%) rotate(0);
150
150
  }
151
151
  }
152
+
153
+ &[disabled],
154
+ &[disabled="disabled"] {
155
+ border-top: 0;
156
+ }
152
157
  }
@@ -7,3 +7,4 @@ export declare const CondensedExample: Story;
7
7
  export declare const SearchExample: Story;
8
8
  export declare const WithDisabledItems: Story;
9
9
  export declare const WithoutSorting: Story;
10
+ export declare const Disabled: Story;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.WithoutSorting = exports.WithDisabledItems = exports.SearchExample = exports.CondensedExample = void 0;
6
+ exports.default = exports.WithoutSorting = exports.WithDisabledItems = exports.SearchExample = exports.Disabled = exports.CondensedExample = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _MultiSelect = require("./MultiSelect");
9
9
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -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,13 @@ const WithoutSorting = exports.WithoutSorting = {
104
105
  }],
105
106
  variant: "condensed",
106
107
  isSortedAlphabetically: false,
107
- hasSelectedItemsFirst: false
108
+ hasSelectedItemsFirst: false,
109
+ id: "external-id"
110
+ }
111
+ };
112
+ const Disabled = exports.Disabled = {
113
+ args: {
114
+ ...CondensedExample.args,
115
+ disabled: true
108
116
  }
109
117
  };
@@ -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,9 @@ export var MultiSelect = _ref4 => {
261
262
  event.stopPropagation();
262
263
  }
263
264
  },
264
- ref: buttonRef
265
+ ref: buttonRef,
266
+ id: id,
267
+ disabled: disabled
265
268
  }, /*#__PURE__*/React.createElement("span", {
266
269
  className: "multi-select__condensed-text"
267
270
  }, listSelected && selectedItems.length > 0 ? selectedItemsLabel : placeholder !== null && placeholder !== void 0 ? placeholder : "Select items")),
@@ -315,5 +318,6 @@ MultiSelect.propTypes = {
315
318
  variant: _pt.oneOf(["condensed", "search"]),
316
319
  scrollOverflow: _pt.bool,
317
320
  isSortedAlphabetically: _pt.bool,
318
- hasSelectedItemsFirst: _pt.bool
321
+ hasSelectedItemsFirst: _pt.bool,
322
+ id: _pt.string
319
323
  };
@@ -149,4 +149,9 @@ $dropdown-max-height: 20rem;
149
149
  transform: translateY(-50%) rotate(0);
150
150
  }
151
151
  }
152
+
153
+ &[disabled],
154
+ &[disabled="disabled"] {
155
+ border-top: 0;
156
+ }
152
157
  }
@@ -7,3 +7,4 @@ export declare const CondensedExample: Story;
7
7
  export declare const SearchExample: Story;
8
8
  export declare const WithDisabledItems: Story;
9
9
  export declare const WithoutSorting: Story;
10
+ export declare const Disabled: Story;
@@ -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,12 @@ 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
  }
106
+ };
107
+ export var Disabled = {
108
+ args: _objectSpread(_objectSpread({}, CondensedExample.args), {}, {
109
+ disabled: true
110
+ })
104
111
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
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.33.0",
96
+ "vanilla-framework": "4.34.1",
97
97
  "wait-on": "8.0.2",
98
98
  "webpack": "5.98.0"
99
99
  },