@linzjs/lui 21.26.3 → 21.28.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
+ # [21.28.0](https://github.com/linz/lui/compare/v21.27.0...v21.28.0) (2024-05-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * Make change to trigger deploy to npm of LuiModal shouldCloseOnEsc key-up ([#1115](https://github.com/linz/lui/issues/1115)) ([f7a1215](https://github.com/linz/lui/commit/f7a1215d7ee8ec6a63180498f1a127f5cebd0fc7))
7
+
8
+ # [21.27.0](https://github.com/linz/lui/compare/v21.26.3...v21.27.0) (2024-04-24)
9
+
10
+
11
+ ### Features
12
+
13
+ * adds optional dataTestId to LuiLoadingSpinner ([#1113](https://github.com/linz/lui/issues/1113)) ([dbad239](https://github.com/linz/lui/commit/dbad239e66b27300220c08b9cd8d094564724ed1))
14
+
1
15
  ## [21.26.3](https://github.com/linz/lui/compare/v21.26.2...v21.26.3) (2024-04-22)
2
16
 
3
17
 
@@ -8,6 +8,8 @@ interface LuiMiniSpinnerProps {
8
8
  divProps?: any;
9
9
  }
10
10
  export declare const LuiMiniSpinner: (props: LuiMiniSpinnerProps) => JSX.Element;
11
- export declare const LuiLoadingSpinner: () => JSX.Element;
11
+ export declare const LuiLoadingSpinner: (props: {
12
+ dataTestId?: string;
13
+ }) => JSX.Element;
12
14
  export declare function isChromatic(): boolean;
13
15
  export {};
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  interface ILuiModal {
3
3
  key?: string;
4
4
  shouldCloseOnOverlayClick?: boolean;
5
- shouldCloseOnEsc?: boolean;
5
+ shouldCloseOnEsc?: boolean | 'use-keyup';
6
6
  onClose?: () => void;
7
7
  className?: string;
8
8
  maxWidth?: boolean;
package/dist/index.js CHANGED
@@ -31491,7 +31491,11 @@ var renderSettings = {
31491
31491
  preserveAspectRatio: 'xMidYMid slice'
31492
31492
  };
31493
31493
  var LuiLoadingSpinnerBase = function (props) {
31494
- return (React__default["default"].createElement("div", { className: "LuiLoadingSpinnerBase", "data-testid": "loading-spinner" },
31494
+ var testId = 'loading-spinner';
31495
+ if (props.dataTestId) {
31496
+ testId += "-".concat(props.dataTestId);
31497
+ }
31498
+ return (React__default["default"].createElement("div", { className: "LuiLoadingSpinnerBase", "data-testid": testId },
31495
31499
  React__default["default"].createElement(LuiLottieLight, { animationData: props.animationData, loop: true, autoplay: autoplay, rendererSettings: renderSettings, style: style })));
31496
31500
  };
31497
31501
  /**
@@ -31509,8 +31513,8 @@ var LuiMiniSpinner = function (props) {
31509
31513
  preserveAspectRatio: 'xMidYMid slice'
31510
31514
  }, style: { height: props.size, width: props.size } })));
31511
31515
  };
31512
- var LuiLoadingSpinner = function () {
31513
- return React__default["default"].createElement(LuiLoadingSpinnerBase, { animationData: loaderData });
31516
+ var LuiLoadingSpinner = function (props) {
31517
+ return (React__default["default"].createElement(LuiLoadingSpinnerBase, { animationData: loaderData, dataTestId: props.dataTestId }));
31514
31518
  };
31515
31519
  // this function was extracted from chromatic/isChromatic. It was causing TS issues for the consumer
31516
31520
  function isChromatic() {
@@ -42178,7 +42182,7 @@ var FeatureIFrame = function (_a) {
42178
42182
  };
42179
42183
 
42180
42184
  var LuiModal = function (props) {
42181
- var _a, _b;
42185
+ var _a;
42182
42186
  var node = React.useRef(null);
42183
42187
  var handleClickOutside = React.useCallback(function (e) {
42184
42188
  // current DOES have a contains!
@@ -42205,7 +42209,20 @@ var LuiModal = function (props) {
42205
42209
  Modal.setAppElement('#root');
42206
42210
  }
42207
42211
  }
42208
- return (React__default["default"].createElement(Modal, __assign({ key: props.key, isOpen: true, shouldCloseOnOverlayClick: props.shouldCloseOnOverlayClick, shouldCloseOnEsc: (_b = props.shouldCloseOnEsc) !== null && _b !== void 0 ? _b : true, onRequestClose: props.onClose, overlayClassName: "modal", className: props.lowContrast ? 'lui-scrim-low-contrast' : 'lui-scrim', ariaHideApp: !isTest }, (props.appendToElement && {
42212
+ React.useEffect(function () {
42213
+ var handleKeyUp = function (e) {
42214
+ var _a;
42215
+ if (props.shouldCloseOnEsc === 'use-keyup' && e.key === 'Escape') {
42216
+ e.stopPropagation();
42217
+ (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
42218
+ }
42219
+ };
42220
+ document.addEventListener('keyup', handleKeyUp);
42221
+ return function () {
42222
+ document.removeEventListener('keyup', handleKeyUp);
42223
+ };
42224
+ }, [props.shouldCloseOnEsc, props.onClose]);
42225
+ return (React__default["default"].createElement(Modal, __assign({ key: props.key, isOpen: true, shouldCloseOnOverlayClick: props.shouldCloseOnOverlayClick, shouldCloseOnEsc: props.shouldCloseOnEsc === true || props.shouldCloseOnEsc === undefined, onRequestClose: props.onClose, overlayClassName: "modal", className: props.lowContrast ? 'lui-scrim-low-contrast' : 'lui-scrim', ariaHideApp: !isTest }, (props.appendToElement && {
42209
42226
  parentSelector: props.appendToElement
42210
42227
  })),
42211
42228
  React__default["default"].createElement("div", { ref: node, className: clsx('lui-modal lui-box-shadow', props.maxWidth && 'lui-max-width', props.headingText && 'lui-modal-no-padding', props.className) },