@widergy/energy-ui 3.168.0 → 3.169.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.
@@ -17,6 +17,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
17
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
18
  const ListboxComponent = _ref => {
19
19
  let {
20
+ CustomRow,
20
21
  dataTestId,
21
22
  filteredOptions,
22
23
  handleSelectionChange,
@@ -38,6 +39,7 @@ const ListboxComponent = _ref => {
38
39
  maxHeight: maxHeightValid
39
40
  }
40
41
  }, /*#__PURE__*/_react.default.createElement(_UTCheckList.default, {
42
+ CustomRow: CustomRow,
41
43
  dataTestId: dataTestId,
42
44
  horizontalSpacing: horizontalSpacing,
43
45
  isSimple: !multiple,
@@ -53,6 +55,7 @@ const ListboxComponent = _ref => {
53
55
  }));
54
56
  };
55
57
  ListboxComponent.propTypes = {
58
+ CustomRow: _propTypes.elementType,
56
59
  dataTestId: _propTypes.string,
57
60
  filteredOptions: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
58
61
  name: _propTypes.string,
@@ -30,6 +30,7 @@ const UTSelect = _ref => {
30
30
  autocompleteProps = {},
31
31
  className,
32
32
  clearable = true,
33
+ CustomRow,
33
34
  dataTestId,
34
35
  disabled,
35
36
  disableFilterOptions = false,
@@ -172,6 +173,7 @@ const UTSelect = _ref => {
172
173
  variant: variant
173
174
  }), [alwaysShowPlaceholder, disabled, error, handleInputBlur, handleInputFocus, leftAdornments, placeholder, rightAdornments, searchTerm]);
174
175
  const listBoxProps = (0, _react.useMemo)(() => ({
176
+ CustomRow,
175
177
  dataTestId: listDataTestId,
176
178
  filteredOptions,
177
179
  handleSelectionChange,
@@ -180,7 +182,7 @@ const UTSelect = _ref => {
180
182
  noMatchesText,
181
183
  value,
182
184
  ...listProps
183
- }), [filteredOptions, handleSelectionChange, multiple, noMatchesText, value, listProps]);
185
+ }), [CustomRow, filteredOptions, handleSelectionChange, multiple, noMatchesText, value, listProps]);
184
186
  const noOptionsTextComponent = /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
185
187
  className: _stylesModule.default.noOptionsLabel,
186
188
  colorTheme: "gray"
@@ -227,6 +229,7 @@ UTSelect.propTypes = {
227
229
  autocompleteProps: _propTypes.object,
228
230
  className: _propTypes.string,
229
231
  clearable: _propTypes.bool,
232
+ CustomRow: _propTypes.elementType,
230
233
  dataTestId: _propTypes.string,
231
234
  disabled: _propTypes.bool,
232
235
  disableFilterOptions: _propTypes.bool,
@@ -14,6 +14,7 @@
14
14
  | autocompleteProps | object | {} | Additional props to pass to the underlying Material-UI Autocomplete component. |
15
15
  | className | string | | Additional CSS class name for the component container. |
16
16
  | clearable | bool | true | Determines whether a button to clear the current selection should be shown. |
17
+ | CustomRow | elementType | | Custom React component to render each option row. Receives `{ item, isChecked }` as props, where `item` is the option object and `isChecked` indicates if the option is selected. |
17
18
  | dataTestId | string | | Test ID for the main input component. |
18
19
  | disabled | bool | false | Disables the select input. |
19
20
  | disableFilterOptions | bool | false | Disables option filtering, showing all options even when typing in the search field. |
@@ -231,6 +232,40 @@ const ReadOnlyExample = () => {
231
232
  };
232
233
  ```
233
234
 
235
+ ### With Custom Row Renderer
236
+
237
+ ```jsx
238
+ import React, { useState } from 'react';
239
+ import UTSelect from './UTSelect';
240
+
241
+ const options = [
242
+ { name: 'Alice', value: '1', subtitle: 'Admin' },
243
+ { name: 'Bob', value: '2', subtitle: 'Editor' },
244
+ { name: 'Carol', value: '3', subtitle: 'Viewer' }
245
+ ];
246
+
247
+ const MyCustomRow = ({ item, isChecked }) => (
248
+ <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
249
+ <span style={{ fontWeight: isChecked ? 'bold' : 'normal' }}>{item.name}</span>
250
+ <span style={{ color: 'gray', fontSize: 12 }}>{item.subtitle}</span>
251
+ </div>
252
+ );
253
+
254
+ const CustomRowExample = () => {
255
+ const [value, setValue] = useState(null);
256
+
257
+ return (
258
+ <UTSelect
259
+ CustomRow={MyCustomRow}
260
+ onChange={setValue}
261
+ options={options}
262
+ placeholder="Select a user"
263
+ value={value}
264
+ />
265
+ );
266
+ };
267
+ ```
268
+
234
269
  ### With Search Term Handling
235
270
 
236
271
  ```jsx
@@ -0,0 +1,13 @@
1
+ import { ArgTypes, Canvas, Description, Meta, Title } from '@storybook/blocks';
2
+
3
+ import * as UTSelectV1Stories from './UTSelectV1.stories.js';
4
+
5
+ <Meta of={UTSelectV1Stories} />
6
+
7
+ <Title>UTSelect V1</Title>
8
+
9
+ <Description of={UTSelectV1Stories} />
10
+
11
+ <Canvas of={UTSelectV1Stories.Playground} withToolbar />
12
+
13
+ <ArgTypes exclude={['classes']} />