@linzjs/lui 22.7.0 → 22.9.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
+ # [22.9.0](https://github.com/linz/lui/compare/v22.8.0...v22.9.0) (2025-02-26)
2
+
3
+
4
+ ### Features
5
+
6
+ * Adding an accessible name to the modal via headingText making it easier to write tests for modals ([#1198](https://github.com/linz/lui/issues/1198)) ([d0a0441](https://github.com/linz/lui/commit/d0a04418f1915274cfddd7a3657d479c3b046bd5))
7
+
8
+ # [22.8.0](https://github.com/linz/lui/compare/v22.7.0...v22.8.0) (2025-02-25)
9
+
10
+
11
+ ### Features
12
+
13
+ * upgrade git hub actions ([#1182](https://github.com/linz/lui/issues/1182)) ([6ffefc2](https://github.com/linz/lui/commit/6ffefc2dbdcb84a4d07a42d087ceb59960f05f7f))
14
+
1
15
  # [22.7.0](https://github.com/linz/lui/compare/v22.6.0...v22.7.0) (2025-02-19)
2
16
 
3
17
 
@@ -14,3 +14,7 @@ export declare const useEscapeFunction: (onEscape: (e: KeyboardEvent) => void |
14
14
  * @return a react ref which can be bound to an html element
15
15
  */
16
16
  export declare const usePageClickFunction: <H extends Element>(onClickInsideArg: (event: MouseEvent) => void, onClickOutsideArg: (event: MouseEvent) => void) => import("react").RefObject<H>;
17
+ /**
18
+ * Provides a stable ID across renders, can be replaced in react 18+ by native implementation
19
+ */
20
+ export declare function useId(): string;
package/dist/index.js CHANGED
@@ -39925,7 +39925,17 @@ var usePageClickFunction = function (onClickInsideArg, onClickOutsideArg) {
39925
39925
  };
39926
39926
  }, [elementRef, onClickInside, onClickOutside]);
39927
39927
  return elementRef;
39928
- };
39928
+ };
39929
+ /**
39930
+ * Provides a stable ID across renders, can be replaced in react 18+ by native implementation
39931
+ */
39932
+ function useId() {
39933
+ var idRef = React.useRef('');
39934
+ if (idRef.current === '') {
39935
+ idRef.current = v4();
39936
+ }
39937
+ return idRef.current;
39938
+ }
39929
39939
 
39930
39940
  var sizes = ['xs', 'sm', 'md', 'lg', 'xl'];
39931
39941
  var buildHideClassDict = function (_a) {
@@ -42299,6 +42309,8 @@ var _a;
42299
42309
  var LuiModalV2 = function (props) {
42300
42310
  var _a;
42301
42311
  var modalRef = React.useRef(null);
42312
+ var rootId = useId();
42313
+ var headingTextId = "".concat(rootId, "_headingText");
42302
42314
  var handleClickOutside = React.useCallback(function () { var _a; return props.shouldCloseOnOverlayClick && ((_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props)); }, [props.shouldCloseOnEsc, props.onClose]);
42303
42315
  useClickedOutsideElement(modalRef, handleClickOutside);
42304
42316
  var handleEsc = React.useCallback(function (e) {
@@ -42325,7 +42337,7 @@ var LuiModalV2 = function (props) {
42325
42337
  // disble the `shouldClose` props as we handle them ourselves
42326
42338
  shouldCloseOnOverlayClick: false, shouldCloseOnEsc: false, overlayClassName: "modal", className: props.lowContrast ? 'lui-scrim-low-contrast' : 'lui-scrim', appElement: document.getElementById('root'),
42327
42339
  // required to prevent warnings that are not applicable in real usage
42328
- ariaHideApp: !isTest, parentSelector: props.appendToElement },
42340
+ ariaHideApp: !isTest, parentSelector: props.appendToElement, aria: { labelledby: props.headingText ? headingTextId : undefined } },
42329
42341
  React__default["default"].createElement("div", { ref: function (el) {
42330
42342
  modalRef.current = el;
42331
42343
  handleAutoFocus(el);
@@ -42334,7 +42346,7 @@ var LuiModalV2 = function (props) {
42334
42346
  props.isLoading && (React__default["default"].createElement(LuiMiniSpinner, { size: 20, divProps: { className: 'lui-modal-v2-header-spinner' } })),
42335
42347
  showHeadingIcon && (React__default["default"].createElement("div", { className: "lui-modal-v2-header-icon" },
42336
42348
  React__default["default"].createElement(LuiIcon, __assign({ size: "md", name: "", alt: "Help" }, props.headingIcon, { className: clsx('', (_a = props.headingIcon) === null || _a === void 0 ? void 0 : _a.className) })))),
42337
- props.headingText && (React__default["default"].createElement("h2", { className: "lui-modal-v2-header-title" }, props.headingText)),
42349
+ props.headingText && (React__default["default"].createElement("h2", { id: headingTextId, className: "lui-modal-v2-header-title" }, props.headingText)),
42338
42350
  showButtons && (React__default["default"].createElement("div", { className: "lui-modal-v2-header-buttons" },
42339
42351
  showHelpButton && React__default["default"].createElement(HelpButton, { helpLink: props.helpLink }),
42340
42352
  showCloseButton && React__default["default"].createElement(CloseButton, { onClose: props.onClose })))),