@linzjs/lui 21.34.0 → 21.34.1-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/dist/components/LuiModal/LuiAlertModalV2.d.ts +7 -0
- package/dist/components/LuiModal/LuiModalV2.d.ts +26 -0
- package/dist/components/common/Hooks.d.ts +1 -0
- package/dist/hooks/useClickedOutsideElement.d.ts +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +114 -28
- package/dist/index.js.map +1 -1
- package/dist/lui.css +82 -0
- package/dist/lui.css.map +1 -1
- package/dist/lui.esm.js +112 -29
- package/dist/lui.esm.js.map +1 -1
- package/dist/scss/Components/Modal/modal-v2.scss +105 -0
- package/dist/scss/base.scss +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { LuiModalV2Props } from './LuiModalV2';
|
|
3
|
+
export declare type LuiAlertModalLevel = 'success' | 'info' | 'warning' | 'error';
|
|
4
|
+
export declare type LuiAlertModalV2Props = Omit<LuiModalV2Props, 'headingIcon'> & {
|
|
5
|
+
level: LuiAlertModalLevel;
|
|
6
|
+
};
|
|
7
|
+
export declare const LuiAlertModalV2: FC<PropsWithChildren<LuiAlertModalV2Props>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { LuiIconProps } from '../LuiIcon/LuiIcon';
|
|
3
|
+
export declare type LuiModalV2Props = {
|
|
4
|
+
key?: string;
|
|
5
|
+
/** Default `true` */
|
|
6
|
+
shouldCloseOnOverlayClick?: boolean;
|
|
7
|
+
/** Default `true` */
|
|
8
|
+
shouldCloseOnEsc?: boolean | 'use-keyup';
|
|
9
|
+
onClose?: () => void | Promise<void>;
|
|
10
|
+
showCloseButton?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
/** If set to true, the modal will take the full screen width. Default `false` */
|
|
13
|
+
maxWidth?: boolean;
|
|
14
|
+
headingText?: string;
|
|
15
|
+
headingIcon?: LuiIconProps;
|
|
16
|
+
helpLink?: string | (() => void | Promise<void>);
|
|
17
|
+
isLoading?: boolean;
|
|
18
|
+
/** Sets the overlay to white. This is only to be used for situations when the user is working in a component and there is benefit to hiding the surrounding page. An example is editing types of instruments in the Dealings flow in LOL. */
|
|
19
|
+
lowContrast?: boolean;
|
|
20
|
+
/** By default, the modal autofocuses the first `input` or `button` inside it. Set this prop to `true` to disable that behaviour. Default `false`. */
|
|
21
|
+
preventAutoFocus?: boolean;
|
|
22
|
+
/** By default, the modal portal will be appended to the document's body, but we might need to append it to another element. This is passed the React Modal `parentSelector` prop. */
|
|
23
|
+
appendToElement?: () => HTMLElement;
|
|
24
|
+
};
|
|
25
|
+
export declare const LuiModalV2: FC<PropsWithChildren<LuiModalV2Props>>;
|
|
26
|
+
export declare const LuiModalV2Buttons: FC<PropsWithChildren<unknown>>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param onEscape the handler function
|
|
6
6
|
*/
|
|
7
7
|
export declare const useEscapeFunction: (onEscape: () => void) => void;
|
|
8
|
+
export declare const useEscapeFunction2: (onEscape: (e: KeyboardEvent) => void | Promise<void>, trigger?: 'keyup' | 'keydown') => void;
|
|
8
9
|
/**
|
|
9
10
|
* A hook which allows handling of click event anywhere on the page.
|
|
10
11
|
* Provides a way of handling clicks done inside or outside the element bound to the returned react ref.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MutableRefObject, RefObject } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* This hook will callback with handleClickOutside() when "mousedown" dom event occurs off the refElement
|
|
4
4
|
* usage:
|
|
@@ -11,4 +11,4 @@ import React from 'react';
|
|
|
11
11
|
return <button ref={refElement}>Click Me!</button>;
|
|
12
12
|
```
|
|
13
13
|
*/
|
|
14
|
-
export declare function useClickedOutsideElement(refElement:
|
|
14
|
+
export declare function useClickedOutsideElement(refElement: RefObject<HTMLElement> | MutableRefObject<HTMLElement>, handleClickOutside: CallableFunction): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export * from './components/LuiHeaderMenu/LuiHeaderMenus';
|
|
|
37
37
|
export * from './components/LuiHeaderMenuV2/LuiHeaderMenusV2';
|
|
38
38
|
export { LuiUpdatesSplashModal } from './components/LuiUpdateSplashModal/LuiUpdatesSplashModal';
|
|
39
39
|
export { LuiModal, LuiAlertModal, LuiAlertModalButtons, } from './components/LuiModal/LuiModal';
|
|
40
|
+
export { LuiModalV2, LuiModalV2Buttons, type LuiModalV2Props, } from './components/LuiModal/LuiModalV2';
|
|
41
|
+
export { LuiAlertModalV2, type LuiAlertModalLevel, type LuiAlertModalV2Props, } from './components/LuiModal/LuiAlertModalV2';
|
|
40
42
|
export { type ISearchInputProps, LuiSearchInput, } from './components/LuiSearchInput/LuiSearchInput';
|
|
41
43
|
export { type ISearchGroupedResult, type ISearchResult, } from './components/LuiSearchInput/ResultsDisplay';
|
|
42
44
|
export { type ISearchMenuOption, type ILuiSearchBoxProps, LuiSearchBox, } from './components/LuiSearchBox/LuiSearchBox';
|
package/dist/index.js
CHANGED
|
@@ -39924,6 +39924,17 @@ var useEscapeFunction = function (onEscape) {
|
|
|
39924
39924
|
};
|
|
39925
39925
|
}, [escFunction]);
|
|
39926
39926
|
};
|
|
39927
|
+
var useEscapeFunction2 = function (onEscape, trigger) {
|
|
39928
|
+
if (trigger === void 0) { trigger = 'keydown'; }
|
|
39929
|
+
var escFunction = React.useCallback(function (event) {
|
|
39930
|
+
console.log(event.key, event, onEscape);
|
|
39931
|
+
event.key === 'Escape' && onEscape(event);
|
|
39932
|
+
}, [onEscape]);
|
|
39933
|
+
React.useEffect(function () {
|
|
39934
|
+
document.addEventListener(trigger, escFunction, false);
|
|
39935
|
+
return function () { return document.removeEventListener(trigger, escFunction, false); };
|
|
39936
|
+
}, [escFunction]);
|
|
39937
|
+
};
|
|
39927
39938
|
/**
|
|
39928
39939
|
* A hook which allows handling of click event anywhere on the page.
|
|
39929
39940
|
* Provides a way of handling clicks done inside or outside the element bound to the returned react ref.
|
|
@@ -42283,6 +42294,106 @@ var LuiModalHeader = function (props) {
|
|
|
42283
42294
|
React__default["default"].createElement(LuiIcon, { name: "ic_clear", alt: "Help", size: "lg" }))))))));
|
|
42284
42295
|
};
|
|
42285
42296
|
|
|
42297
|
+
/**
|
|
42298
|
+
* This hook will callback with handleClickOutside() when "mousedown" dom event occurs off the refElement
|
|
42299
|
+
* usage:
|
|
42300
|
+
```typescript
|
|
42301
|
+
const refElement = React.useRef<HTMLButtonElement>(null);
|
|
42302
|
+
const handleClickOutside = () => {
|
|
42303
|
+
console.log("hello world");
|
|
42304
|
+
};
|
|
42305
|
+
useClickedOutsideElement(refElement, handleClickOutside);
|
|
42306
|
+
return <button ref={refElement}>Click Me!</button>;
|
|
42307
|
+
```
|
|
42308
|
+
*/
|
|
42309
|
+
function useClickedOutsideElement(refElement, handleClickOutside) {
|
|
42310
|
+
React__default["default"].useEffect(function () {
|
|
42311
|
+
function onOutsideClicked(event) {
|
|
42312
|
+
var element = refElement.current;
|
|
42313
|
+
if (!(element === null || element === void 0 ? void 0 : element.contains(event.target))) {
|
|
42314
|
+
handleClickOutside();
|
|
42315
|
+
}
|
|
42316
|
+
}
|
|
42317
|
+
document.addEventListener('mousedown', onOutsideClicked);
|
|
42318
|
+
return function () {
|
|
42319
|
+
document.removeEventListener('mousedown', onOutsideClicked);
|
|
42320
|
+
};
|
|
42321
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42322
|
+
}, []);
|
|
42323
|
+
}
|
|
42324
|
+
|
|
42325
|
+
var _a;
|
|
42326
|
+
// this is here for the tests
|
|
42327
|
+
var isTest = typeof process !== 'undefined' && ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === 'test';
|
|
42328
|
+
if (!isTest)
|
|
42329
|
+
Modal.setAppElement('#root');
|
|
42330
|
+
var LuiModalV2 = function (props) {
|
|
42331
|
+
var _a;
|
|
42332
|
+
var modalRef = React.useRef(null);
|
|
42333
|
+
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]);
|
|
42334
|
+
useClickedOutsideElement(modalRef, handleClickOutside);
|
|
42335
|
+
var handleEsc = React.useCallback(function (e) {
|
|
42336
|
+
var _a;
|
|
42337
|
+
if (props.shouldCloseOnEsc !== false) {
|
|
42338
|
+
e.stopPropagation();
|
|
42339
|
+
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
42340
|
+
}
|
|
42341
|
+
}, [props.shouldCloseOnEsc, props.onClose]);
|
|
42342
|
+
useEscapeFunction2(handleEsc, props.shouldCloseOnEsc === 'use-keyup' ? 'keyup' : 'keydown');
|
|
42343
|
+
var handleAutoFocus = function (el) {
|
|
42344
|
+
if (props.preventAutoFocus)
|
|
42345
|
+
return;
|
|
42346
|
+
if (el && !el.contains(el.ownerDocument.activeElement)) {
|
|
42347
|
+
var firstFocusableElement = el.querySelector('input,button');
|
|
42348
|
+
firstFocusableElement === null || firstFocusableElement === void 0 ? void 0 : firstFocusableElement.focus();
|
|
42349
|
+
}
|
|
42350
|
+
};
|
|
42351
|
+
console.log({ props: props }, props.shouldCloseOnEsc && props.shouldCloseOnEsc !== 'use-keyup');
|
|
42352
|
+
var showCloseButton = Boolean(props.showCloseButton && props.onClose);
|
|
42353
|
+
var showHelpButton = Boolean(props.helpLink);
|
|
42354
|
+
var showButtons = showCloseButton || showHelpButton;
|
|
42355
|
+
var showHeadingIcon = props.headingIcon && !props.isLoading;
|
|
42356
|
+
return (React__default["default"].createElement(Modal, { key: props.key, isOpen: true,
|
|
42357
|
+
// disble the `shouldClose` props as we handle them ourselves
|
|
42358
|
+
shouldCloseOnOverlayClick: false, shouldCloseOnEsc: false, overlayClassName: "modal", className: props.lowContrast ? 'lui-scrim-low-contrast' : 'lui-scrim',
|
|
42359
|
+
// required to prevent warnings that are not applicable in real usage
|
|
42360
|
+
ariaHideApp: !isTest, parentSelector: props.appendToElement },
|
|
42361
|
+
React__default["default"].createElement("div", { ref: function (el) {
|
|
42362
|
+
modalRef.current = el;
|
|
42363
|
+
handleAutoFocus(el);
|
|
42364
|
+
}, className: clsx('lui-modal-v2 lui-box-shadow', props.maxWidth && 'lui-max-width', props.className) },
|
|
42365
|
+
React__default["default"].createElement("div", { className: "lui-modal-v2-header" },
|
|
42366
|
+
props.isLoading && (React__default["default"].createElement(LuiMiniSpinner, { size: 20, divProps: { className: 'lui-modal-v2-header-spinner' } })),
|
|
42367
|
+
showHeadingIcon && (React__default["default"].createElement("div", { className: "lui-modal-v2-header-icon" },
|
|
42368
|
+
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) })))),
|
|
42369
|
+
props.headingText && (React__default["default"].createElement("h2", { className: "lui-modal-v2-header-title" }, props.headingText)),
|
|
42370
|
+
showButtons && (React__default["default"].createElement("div", { className: "lui-modal-v2-header-buttons" },
|
|
42371
|
+
showHelpButton && React__default["default"].createElement(HelpButton, { helpLink: props.helpLink }),
|
|
42372
|
+
showCloseButton && React__default["default"].createElement(CloseButton, { onClose: props.onClose })))),
|
|
42373
|
+
React__default["default"].createElement("div", { className: "lui-modal-v2-contents" }, props.children))));
|
|
42374
|
+
};
|
|
42375
|
+
var LuiModalV2Buttons = function (props) { return (React__default["default"].createElement("div", { className: "lui-modal-v2-btn-row" }, props.children)); };
|
|
42376
|
+
var HelpButton = function (props) { return (React__default["default"].createElement("button", { "aria-label": "Modal Help", title: "Help", className: "lui-modal-v2-header-help-btn", onClick: typeof props.helpLink === 'string'
|
|
42377
|
+
? function () { return window.open(props.helpLink, '_blank'); }
|
|
42378
|
+
: props.helpLink },
|
|
42379
|
+
React__default["default"].createElement(LuiIcon, { name: "ic_help_outline", alt: "Help", size: "md" }))); };
|
|
42380
|
+
var CloseButton = function (props) { return (React__default["default"].createElement("button", { "aria-label": "Modal Close", title: "Close", className: "lui-modal-v2-header-close-btn", onClick: props.onClose },
|
|
42381
|
+
React__default["default"].createElement(LuiIcon, { name: "ic_clear", alt: "Help", size: "md" }))); };
|
|
42382
|
+
|
|
42383
|
+
var LuiAlertModalV2 = function (props) {
|
|
42384
|
+
var level = props.level, className = props.className, children = props.children, rest = __rest(props, ["level", "className", "children"]);
|
|
42385
|
+
var materialIcon = getMaterialIconForLevel(level);
|
|
42386
|
+
var status = Object.keys(ICON_STATUS).includes(level)
|
|
42387
|
+
? level
|
|
42388
|
+
: 'interactive';
|
|
42389
|
+
return (React__default["default"].createElement(LuiModalV2, __assign({}, rest, { className: clsx("lui-modal-v2-".concat(level), className), headingIcon: {
|
|
42390
|
+
name: "ic_".concat(materialIcon),
|
|
42391
|
+
alt: level,
|
|
42392
|
+
size: 'md',
|
|
42393
|
+
status: status
|
|
42394
|
+
} }), children));
|
|
42395
|
+
};
|
|
42396
|
+
|
|
42286
42397
|
var css_248z$e = "@keyframes react-loading-skeleton {\n 100% {\n transform: translateX(100%);\n }\n}\n\n.react-loading-skeleton {\n --base-color: #ebebeb;\n --highlight-color: #f5f5f5;\n --animation-duration: 1.5s;\n --animation-direction: normal;\n --pseudo-element-display: block; /* Enable animation */\n\n background-color: var(--base-color);\n\n width: 100%;\n border-radius: 0.25rem;\n display: inline-flex;\n line-height: 1;\n\n position: relative;\n user-select: none;\n overflow: hidden;\n z-index: 1; /* Necessary for overflow: hidden to work correctly in Safari */\n}\n\n.react-loading-skeleton::after {\n content: ' ';\n display: var(--pseudo-element-display);\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 100%;\n background-repeat: no-repeat;\n background-image: linear-gradient(\n 90deg,\n var(--base-color),\n var(--highlight-color),\n var(--base-color)\n );\n transform: translateX(-100%);\n\n animation-name: react-loading-skeleton;\n animation-direction: var(--animation-direction);\n animation-duration: var(--animation-duration);\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n}\n\n@media (prefers-reduced-motion) {\n .react-loading-skeleton {\n --pseudo-element-display: none; /* Disable animation */\n }\n}\n";
|
|
42287
42398
|
styleInject(css_248z$e);
|
|
42288
42399
|
|
|
@@ -46881,34 +46992,6 @@ var LuiTooltip = function (props) {
|
|
|
46881
46992
|
return React__default["default"].createElement(Tippy, __assign({}, tippyProps), children);
|
|
46882
46993
|
};
|
|
46883
46994
|
|
|
46884
|
-
/**
|
|
46885
|
-
* This hook will callback with handleClickOutside() when "mousedown" dom event occurs off the refElement
|
|
46886
|
-
* usage:
|
|
46887
|
-
```typescript
|
|
46888
|
-
const refElement = React.useRef<HTMLButtonElement>(null);
|
|
46889
|
-
const handleClickOutside = () => {
|
|
46890
|
-
console.log("hello world");
|
|
46891
|
-
};
|
|
46892
|
-
useClickedOutsideElement(refElement, handleClickOutside);
|
|
46893
|
-
return <button ref={refElement}>Click Me!</button>;
|
|
46894
|
-
```
|
|
46895
|
-
*/
|
|
46896
|
-
function useClickedOutsideElement(refElement, handleClickOutside) {
|
|
46897
|
-
React__default["default"].useEffect(function () {
|
|
46898
|
-
function onOutsideClicked(event) {
|
|
46899
|
-
var element = refElement.current;
|
|
46900
|
-
if (!(element === null || element === void 0 ? void 0 : element.contains(event.target))) {
|
|
46901
|
-
handleClickOutside();
|
|
46902
|
-
}
|
|
46903
|
-
}
|
|
46904
|
-
document.addEventListener('mousedown', onOutsideClicked);
|
|
46905
|
-
return function () {
|
|
46906
|
-
document.removeEventListener('mousedown', onOutsideClicked);
|
|
46907
|
-
};
|
|
46908
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46909
|
-
}, []);
|
|
46910
|
-
}
|
|
46911
|
-
|
|
46912
46995
|
var getFillClassName = function (fillVariation, backgroundFill) {
|
|
46913
46996
|
if (backgroundFill) {
|
|
46914
46997
|
return 'LuiBadge--fill';
|
|
@@ -59321,6 +59404,7 @@ exports.LuiAccordicardStatic = LuiAccordicardStatic;
|
|
|
59321
59404
|
exports.LuiAccordion = LuiAccordion;
|
|
59322
59405
|
exports.LuiAlertModal = LuiAlertModal;
|
|
59323
59406
|
exports.LuiAlertModalButtons = LuiAlertModalButtons;
|
|
59407
|
+
exports.LuiAlertModalV2 = LuiAlertModalV2;
|
|
59324
59408
|
exports.LuiAppFooterSml = LuiAppFooterSml;
|
|
59325
59409
|
exports.LuiBadge = LuiBadge;
|
|
59326
59410
|
exports.LuiBanner = LuiBanner;
|
|
@@ -59374,6 +59458,8 @@ exports.LuiMenuCloseButtonV2 = LuiMenuCloseButtonV2;
|
|
|
59374
59458
|
exports.LuiMessagingContextProvider = LuiMessagingContextProvider;
|
|
59375
59459
|
exports.LuiMiniSpinner = LuiMiniSpinner;
|
|
59376
59460
|
exports.LuiModal = LuiModal;
|
|
59461
|
+
exports.LuiModalV2 = LuiModalV2;
|
|
59462
|
+
exports.LuiModalV2Buttons = LuiModalV2Buttons;
|
|
59377
59463
|
exports.LuiMoneyInput = LuiMoneyInput;
|
|
59378
59464
|
exports.LuiMultiSwitch = LuiMultiSwitch;
|
|
59379
59465
|
exports.LuiMultiSwitchYesNo = LuiMultiSwitchYesNo;
|