@linzjs/lui 17.13.2 → 17.14.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [17.14.0](https://github.com/linz/lui/compare/v17.13.3...v17.14.0) (2022-09-13)
2
+
3
+
4
+ ### Features
5
+
6
+ * **LuiListBox:** Adding aria-label support to listbox items ([#756](https://github.com/linz/lui/issues/756)) ([4702258](https://github.com/linz/lui/commit/4702258110d1642b5b6db010cf355b8f44114bb1))
7
+
8
+ ## [17.13.3](https://github.com/linz/lui/compare/v17.13.2...v17.13.3) (2022-09-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Add child key to options of LuiRadioInput ([#753](https://github.com/linz/lui/issues/753)) ([33b5697](https://github.com/linz/lui/commit/33b5697420a53fdd8fd4da88815d5e34a7196ca7))
14
+
1
15
  ## [17.13.2](https://github.com/linz/lui/compare/v17.13.1...v17.13.2) (2022-09-07)
2
16
 
3
17
 
@@ -4,6 +4,7 @@ import { SelectionBehavior, SelectionMode } from '@react-types/shared';
4
4
  import { AriaListBoxOptions } from '@react-aria/listbox';
5
5
  export declare type KeyGetter<T> = (item: T) => Key;
6
6
  export declare type GroupGetter<T> = (item: T) => string | null;
7
+ export declare type LabelGetter<T> = (item: T) => string;
7
8
  export interface ILuiListItemNode<T> {
8
9
  key: Key;
9
10
  textValue: string;
@@ -38,7 +39,8 @@ export interface ILuiListBoxProps<T = ILuiListBoxItem> extends Omit<HTMLAttribut
38
39
  groupHeadingRenderer?: (props: IGroupHeadingRendererProps) => ReactNode;
39
40
  getKey?: KeyGetter<T>;
40
41
  getGroup?: GroupGetter<T>;
42
+ getLabel?: LabelGetter<T>;
41
43
  loadingIndicator?: () => ReactNode;
42
44
  emptyIndicator?: () => ReactNode;
43
45
  }
44
- export declare function LuiListBox<T extends object = ILuiListBoxItem>({ ariaLabel, ariaLabelledBy, itemRenderer, groupHeadingRenderer, loadingIndicator, emptyIndicator, selectionMode, selectionBehavior, disabled, items, value, onChange, getKey, getGroup, ariaProps, className, ...ulProps }: ILuiListBoxProps<T>): JSX.Element;
46
+ export declare function LuiListBox<T extends object = ILuiListBoxItem>({ ariaLabel, ariaLabelledBy, itemRenderer, groupHeadingRenderer, loadingIndicator, emptyIndicator, selectionMode, selectionBehavior, disabled, items, value, onChange, getKey, getGroup, getLabel, ariaProps, className, ...ulProps }: ILuiListBoxProps<T>): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import { ListProps } from '@react-stately/list';
2
2
  import { ILuiListBoxProps, ILuiListItemNode } from './LuiListBox';
3
- export declare function useLuiListBox<T extends object>({ selectionMode, selectionBehavior, items, value, onChange, ariaProps, getGroup, getKey, }: ILuiListBoxProps<T>): ListProps<ILuiListItemNode<T>>;
3
+ export declare function useLuiListBox<T extends object>({ selectionMode, selectionBehavior, items, value, onChange, ariaProps, getGroup, getKey, getLabel, }: ILuiListBoxProps<T>): ListProps<ILuiListItemNode<T>>;
@@ -3,6 +3,7 @@ export declare const LuiUpdatesSplashModal: React.FC<{
3
3
  bigImage: string;
4
4
  smallImage: string;
5
5
  header: string;
6
+ wrapperClass: string;
6
7
  onClose: () => void;
7
8
  id: string;
8
9
  }>;
package/dist/index.js CHANGED
@@ -1199,12 +1199,12 @@ var LuiRadioInput = function (props) {
1199
1199
  var isSelected = props.selectedValue === option;
1200
1200
  var isDisabled = props.isOptionDisabled && props.isOptionDisabled(index);
1201
1201
  var hasWarning = props.optionHasWarning && props.optionHasWarning(index);
1202
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
1202
+ return (React__default["default"].createElement(React.Fragment, { key: radioId },
1203
1203
  React__default["default"].createElement("label", { htmlFor: radioId, className: clsx('LuiRadioInput-label', {
1204
1204
  'LuiRadioInput-label--isDisabled': isDisabled,
1205
1205
  'LuiRadioInput-label--hasWarning': hasWarning && isSelected,
1206
1206
  'LuiRadioInput-label--isSelected': isSelected
1207
- }), key: radioId },
1207
+ }) },
1208
1208
  React__default["default"].createElement("input", __assign({ disabled: isDisabled, className: "LuiRadioInput-input", type: "radio", id: radioId, name: option, value: option, checked: isSelected, onChange: props.onChange }, props.inputProps)),
1209
1209
  props.renderLabelFor ? props.renderLabelFor(option) : option),
1210
1210
  hasWarning && isSelected && (React__default["default"].createElement("div", { className: "LuiRadioInput-warningOnIndividualMsg" },
@@ -28159,11 +28159,12 @@ var LuiUpdatesSplashModal = function (props) {
28159
28159
  Modal.setAppElement('#root');
28160
28160
  }
28161
28161
  return (React__default["default"].createElement(Modal, { key: props.id, isOpen: true, shouldCloseOnOverlayClick: true, onRequestClose: props.onClose, contentLabel: "Recent updates", className: "lui-scrim", style: { overlay: { backgroundColor: 'transparent' } } },
28162
- React__default["default"].createElement("div", { ref: node, className: "lui-large-feature-notification" },
28163
- React__default["default"].createElement("div", { className: "lui-feature-img" },
28162
+ React__default["default"].createElement("div", { ref: node, className: clsx('lui-large-feature-notification', props.wrapperClass) },
28163
+ React__default["default"].createElement("div", { className: "lui-feature-header" },
28164
28164
  React__default["default"].createElement("h1", null, props.header),
28165
28165
  React__default["default"].createElement("button", { "aria-label": "Close dialog", onClick: props.onClose },
28166
- React__default["default"].createElement("i", { className: "material-icons-round" }, "close")),
28166
+ React__default["default"].createElement("i", { className: "material-icons-round" }, "close"))),
28167
+ React__default["default"].createElement("div", { className: "lui-feature-img" },
28167
28168
  React__default["default"].createElement("img", { className: "lui-hide-xs lui-hide-sm", alt: "What's new", src: props.bigImage }),
28168
28169
  React__default["default"].createElement("img", { className: "lui-hide-md lui-hide-lg lui-hide-xl", alt: "What's new", src: props.smallImage })),
28169
28170
  React__default["default"].createElement("div", { className: 'lui-feature-text' }, props.children))));
@@ -40825,7 +40826,7 @@ function $453cc9f0df89c0a5$export$77d5aafae4e095b2(collection) {
40825
40826
  }
40826
40827
 
40827
40828
  function useLuiListBox(_a) {
40828
- var selectionMode = _a.selectionMode, selectionBehavior = _a.selectionBehavior, _b = _a.items, items = _b === void 0 ? [] : _b, value = _a.value, onChange = _a.onChange, ariaProps = _a.ariaProps, _c = _a.getGroup, getGroup = _c === void 0 ? defaultGroupGetter : _c, _d = _a.getKey, getKey = _d === void 0 ? defaultKeyGetter : _d;
40829
+ var selectionMode = _a.selectionMode, selectionBehavior = _a.selectionBehavior, _b = _a.items, items = _b === void 0 ? [] : _b, value = _a.value, onChange = _a.onChange, ariaProps = _a.ariaProps, _c = _a.getGroup, getGroup = _c === void 0 ? defaultGroupGetter : _c, _d = _a.getKey, getKey = _d === void 0 ? defaultKeyGetter : _d, _e = _a.getLabel, getLabel = _e === void 0 ? defaultLabelGetter : _e;
40829
40830
  var children = React.useCallback(function (item) {
40830
40831
  return item.childNodes ? (React__default["default"].createElement($9fc4852771d079eb$export$6e2c8f0811a474ce, { key: item.key, items: item.childNodes, title: item.textValue }, function (item) { return React__default["default"].createElement($c1d7fb2ec91bae71$export$6d08773d2e66f8f2, null, String(item.key)); })) : (React__default["default"].createElement($c1d7fb2ec91bae71$export$6d08773d2e66f8f2, null, String(item.key)));
40831
40832
  }, []);
@@ -40835,26 +40836,20 @@ function useLuiListBox(_a) {
40835
40836
  }
40836
40837
  onChange(keys === 'all' ? items.map(function (item) { return getKey(item); }) : Array.from(keys), keys === 'all' ? items : items.filter(function (item) { return keys.has(getKey(item)); }));
40837
40838
  }, [items, onChange, getKey]);
40838
- var nodes = React.useMemo(function () { return mapItemsToNodes(items, getKey, getGroup); }, [
40839
- items,
40840
- getKey,
40841
- getGroup,
40842
- ]);
40839
+ var nodes = React.useMemo(function () { return mapItemsToNodes(items, getKey, getGroup, getLabel); }, [items, getKey, getGroup, getLabel]);
40843
40840
  return __assign(__assign({}, ariaProps), { items: nodes, selectionMode: selectionMode, selectionBehavior: selectionBehavior, selectedKeys: (Array.isArray(value) ? value : [value]).filter(Boolean), children: children, onSelectionChange: onSelectionChange });
40844
40841
  }
40845
- function mapItemsToNodes(items, getKey, getGroup) {
40842
+ function mapItemsToNodes(items, getKey, getGroup, getLabel) {
40846
40843
  var rootNodes = new Map();
40847
40844
  for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
40848
40845
  var item = items_1[_i];
40849
40846
  var groupName = getGroup(item);
40850
40847
  var key = getKey(item);
40848
+ var textValue = getLabel(item);
40849
+ var node = { key: key, textValue: textValue, value: item };
40851
40850
  // Is an item without a group
40852
40851
  if (!groupName) {
40853
- rootNodes.set(key, {
40854
- key: key,
40855
- textValue: String(key),
40856
- value: item
40857
- });
40852
+ rootNodes.set(key, node);
40858
40853
  }
40859
40854
  // is an item with a group that has not been encountered yet.
40860
40855
  if (groupName && !rootNodes.get(groupName)) {
@@ -40865,11 +40860,7 @@ function mapItemsToNodes(items, getKey, getGroup) {
40865
40860
  });
40866
40861
  }
40867
40862
  if (groupName) {
40868
- rootNodes.get(groupName).childNodes.push({
40869
- key: key,
40870
- textValue: String(key),
40871
- value: item
40872
- });
40863
+ rootNodes.get(groupName).childNodes.push(node);
40873
40864
  }
40874
40865
  }
40875
40866
  return Array.from(rootNodes.values());
@@ -40882,6 +40873,12 @@ function defaultKeyGetter(item) {
40882
40873
  }
40883
40874
  function defaultGroupGetter(item) {
40884
40875
  return item.group || null;
40876
+ }
40877
+ function defaultLabelGetter(item) {
40878
+ if (!item.hasOwnProperty('key')) {
40879
+ throw Error('Could not find `label` property on item, please provide a custom `getLabel` function');
40880
+ }
40881
+ return item.label;
40885
40882
  }
40886
40883
 
40887
40884
  function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value1, defaultValue, onChange) {
@@ -43500,7 +43497,7 @@ function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
43500
43497
  function LuiListBoxItem(_a) {
43501
43498
  var node = _a.node, state = _a.state, renderer = _a.renderer;
43502
43499
  var ref = React.useRef(null);
43503
- var _b = $293f70390ea03370$export$497855f14858aa34({ key: node.key }, state, ref), optionProps = _b.optionProps, isSelected = _b.isSelected, isDisabled = _b.isDisabled;
43500
+ var _b = $293f70390ea03370$export$497855f14858aa34({ key: node.key, 'aria-label': node.textValue }, state, ref), optionProps = _b.optionProps, isSelected = _b.isSelected, isDisabled = _b.isDisabled;
43504
43501
  var _c = $f7dceffc5ad7768b$export$4e328f61c538687f(), isFocusVisible = _c.isFocusVisible, focusProps = _c.focusProps;
43505
43502
  return (React__default["default"].createElement("li", __assign({ ref: ref }, $3ef42575df84b30b$export$9d1611c77c2fe928(optionProps, focusProps), { className: clsx('LuiListBoxItem', isSelected && 'LuiListBoxItem-selected', isDisabled && 'LuiListBoxItem-disabled') }), renderer({
43506
43503
  item: node.value,
@@ -43991,7 +43988,7 @@ function LuiListBoxGroup(_a) {
43991
43988
  }
43992
43989
 
43993
43990
  function LuiListBox(_a) {
43994
- var ariaLabel = _a.ariaLabel, ariaLabelledBy = _a.ariaLabelledBy, _b = _a.itemRenderer, itemRenderer = _b === void 0 ? DefaultItemRenderer : _b, _c = _a.groupHeadingRenderer, groupHeadingRenderer = _c === void 0 ? DefaultGroupHeadingRenderer : _c, _d = _a.loadingIndicator, loadingIndicator = _d === void 0 ? DefaultLoadingIndicator : _d, _e = _a.emptyIndicator, emptyIndicator = _e === void 0 ? DefaultEmptyIndicator : _e, _f = _a.selectionMode, selectionMode = _f === void 0 ? 'single' : _f, _g = _a.selectionBehavior, selectionBehavior = _g === void 0 ? 'toggle' : _g, _h = _a.disabled, disabled = _h === void 0 ? false : _h, items = _a.items, value = _a.value, onChange = _a.onChange, getKey = _a.getKey, getGroup = _a.getGroup, ariaProps = _a.ariaProps, className = _a.className, ulProps = __rest(_a, ["ariaLabel", "ariaLabelledBy", "itemRenderer", "groupHeadingRenderer", "loadingIndicator", "emptyIndicator", "selectionMode", "selectionBehavior", "disabled", "items", "value", "onChange", "getKey", "getGroup", "ariaProps", "className"]);
43991
+ var ariaLabel = _a.ariaLabel, ariaLabelledBy = _a.ariaLabelledBy, _b = _a.itemRenderer, itemRenderer = _b === void 0 ? DefaultItemRenderer : _b, _c = _a.groupHeadingRenderer, groupHeadingRenderer = _c === void 0 ? DefaultGroupHeadingRenderer : _c, _d = _a.loadingIndicator, loadingIndicator = _d === void 0 ? DefaultLoadingIndicator : _d, _e = _a.emptyIndicator, emptyIndicator = _e === void 0 ? DefaultEmptyIndicator : _e, _f = _a.selectionMode, selectionMode = _f === void 0 ? 'single' : _f, _g = _a.selectionBehavior, selectionBehavior = _g === void 0 ? 'toggle' : _g, _h = _a.disabled, disabled = _h === void 0 ? false : _h, items = _a.items, value = _a.value, onChange = _a.onChange, getKey = _a.getKey, getGroup = _a.getGroup, getLabel = _a.getLabel, ariaProps = _a.ariaProps, className = _a.className, ulProps = __rest(_a, ["ariaLabel", "ariaLabelledBy", "itemRenderer", "groupHeadingRenderer", "loadingIndicator", "emptyIndicator", "selectionMode", "selectionBehavior", "disabled", "items", "value", "onChange", "getKey", "getGroup", "getLabel", "ariaProps", "className"]);
43995
43992
  var listProps = useLuiListBox({
43996
43993
  selectionMode: selectionMode,
43997
43994
  selectionBehavior: selectionBehavior,
@@ -44000,6 +43997,7 @@ function LuiListBox(_a) {
44000
43997
  onChange: onChange,
44001
43998
  getKey: getKey,
44002
43999
  getGroup: getGroup,
44000
+ getLabel: getLabel,
44003
44001
  ariaProps: ariaProps,
44004
44002
  disabled: disabled
44005
44003
  });
@@ -44051,7 +44049,7 @@ styleInject(css_248z);
44051
44049
 
44052
44050
  function CheckboxItemRenderer(_a) {
44053
44051
  var item = _a.item, isSelected = _a.isSelected;
44054
- return (React__default["default"].createElement("div", { className: "CheckboxRenderer ".concat(isSelected ? 'LuiCheckboxInput--isChecked' : ''), style: {} },
44052
+ return (React__default["default"].createElement("div", { className: "CheckboxRenderer ".concat(isSelected ? 'LuiCheckboxInput--isChecked' : '') },
44055
44053
  React__default["default"].createElement(LuiIcon, { size: "md", name: isSelected ? 'ic_check' : 'ic_zoom_out', alt: isSelected ? 'Checked' : 'Indeterminate Check', className: "LuiCheckboxInput-labelCheck ".concat(isSelected ? 'LuiCheckboxInput--isChecked' : '') }),
44056
44054
  item.label));
44057
44055
  }