@linzjs/lui 21.35.0 → 21.35.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 +33 -0
- package/dist/components/common/Hooks.d.ts +1 -1
- package/dist/hooks/useClickedOutsideElement.d.ts +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +120 -38
- package/dist/index.js.map +1 -1
- package/dist/lui.css +95 -0
- package/dist/lui.css.map +1 -1
- package/dist/lui.esm.js +119 -39
- package/dist/lui.esm.js.map +1 -1
- package/dist/scss/Components/Modal/modal-v2.scss +121 -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,33 @@
|
|
|
1
|
+
import React, { 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`. This is kept from LuiModal "V1" for backwards compatibility. */
|
|
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: {
|
|
26
|
+
(props: PropsWithChildren<LuiModalV2Props>): JSX.Element;
|
|
27
|
+
Buttons: React.FC<React.PropsWithChildren<{
|
|
28
|
+
className?: string | undefined;
|
|
29
|
+
}>>;
|
|
30
|
+
HeaderTitle: React.FC<React.PropsWithChildren<{
|
|
31
|
+
className?: string | undefined;
|
|
32
|
+
}>>;
|
|
33
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @param onEscape the handler function
|
|
6
6
|
*/
|
|
7
|
-
export declare const useEscapeFunction: (onEscape: () => void) => void;
|
|
7
|
+
export declare const useEscapeFunction: (onEscape: (e: KeyboardEvent) => void | Promise<void>, trigger?: 'keyup' | 'keydown') => void;
|
|
8
8
|
/**
|
|
9
9
|
* A hook which allows handling of click event anywhere on the page.
|
|
10
10
|
* 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, 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
|
@@ -39830,17 +39830,12 @@ var motif = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0id
|
|
|
39830
39830
|
*
|
|
39831
39831
|
* @param onEscape the handler function
|
|
39832
39832
|
*/
|
|
39833
|
-
var useEscapeFunction = function (onEscape) {
|
|
39834
|
-
|
|
39835
|
-
|
|
39836
|
-
onEscape();
|
|
39837
|
-
}
|
|
39838
|
-
}, [onEscape]);
|
|
39833
|
+
var useEscapeFunction = function (onEscape, trigger) {
|
|
39834
|
+
if (trigger === void 0) { trigger = 'keydown'; }
|
|
39835
|
+
var escFunction = React.useCallback(function (event) { return event.key === 'Escape' && onEscape(event); }, [onEscape]);
|
|
39839
39836
|
React.useEffect(function () {
|
|
39840
|
-
document.addEventListener(
|
|
39841
|
-
return function () {
|
|
39842
|
-
document.removeEventListener('keydown', escFunction, false);
|
|
39843
|
-
};
|
|
39837
|
+
document.addEventListener(trigger, escFunction);
|
|
39838
|
+
return function () { return document.removeEventListener(trigger, escFunction); };
|
|
39844
39839
|
}, [escFunction]);
|
|
39845
39840
|
};
|
|
39846
39841
|
/**
|
|
@@ -42202,6 +42197,119 @@ var LuiModalHeader = function (props) {
|
|
|
42202
42197
|
React__default["default"].createElement(LuiIcon, { name: "ic_clear", alt: "Help", size: "lg" }))))))));
|
|
42203
42198
|
};
|
|
42204
42199
|
|
|
42200
|
+
/**
|
|
42201
|
+
* This hook will callback with handleClickOutside() when "mousedown" dom event occurs off the refElement
|
|
42202
|
+
* usage:
|
|
42203
|
+
```typescript
|
|
42204
|
+
const refElement = React.useRef<HTMLButtonElement>(null);
|
|
42205
|
+
const handleClickOutside = () => {
|
|
42206
|
+
console.log("hello world");
|
|
42207
|
+
};
|
|
42208
|
+
useClickedOutsideElement(refElement, handleClickOutside);
|
|
42209
|
+
return <button ref={refElement}>Click Me!</button>;
|
|
42210
|
+
```
|
|
42211
|
+
*/
|
|
42212
|
+
function useClickedOutsideElement(refElement, handleClickOutside) {
|
|
42213
|
+
React__default["default"].useEffect(function () {
|
|
42214
|
+
function onOutsideClicked(event) {
|
|
42215
|
+
var element = refElement.current;
|
|
42216
|
+
if (!(element === null || element === void 0 ? void 0 : element.contains(event.target))) {
|
|
42217
|
+
handleClickOutside();
|
|
42218
|
+
}
|
|
42219
|
+
}
|
|
42220
|
+
document.addEventListener('mousedown', onOutsideClicked);
|
|
42221
|
+
return function () {
|
|
42222
|
+
document.removeEventListener('mousedown', onOutsideClicked);
|
|
42223
|
+
};
|
|
42224
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42225
|
+
}, []);
|
|
42226
|
+
}
|
|
42227
|
+
|
|
42228
|
+
var _a;
|
|
42229
|
+
var LuiModalV2 = function (props) {
|
|
42230
|
+
var _a;
|
|
42231
|
+
var modalRef = React.useRef(null);
|
|
42232
|
+
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]);
|
|
42233
|
+
useClickedOutsideElement(modalRef, handleClickOutside);
|
|
42234
|
+
var handleEsc = React.useCallback(function (e) {
|
|
42235
|
+
var _a;
|
|
42236
|
+
if (props.shouldCloseOnEsc !== false) {
|
|
42237
|
+
e.stopPropagation();
|
|
42238
|
+
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
42239
|
+
}
|
|
42240
|
+
}, [props.shouldCloseOnEsc, props.onClose]);
|
|
42241
|
+
useEscapeFunction(handleEsc, props.shouldCloseOnEsc === 'use-keyup' ? 'keyup' : 'keydown');
|
|
42242
|
+
var handleAutoFocus = function (el) {
|
|
42243
|
+
if (props.preventAutoFocus)
|
|
42244
|
+
return;
|
|
42245
|
+
if (el && !el.contains(el.ownerDocument.activeElement)) {
|
|
42246
|
+
var firstFocusableElement = el.querySelector('input,button');
|
|
42247
|
+
firstFocusableElement === null || firstFocusableElement === void 0 ? void 0 : firstFocusableElement.focus();
|
|
42248
|
+
}
|
|
42249
|
+
};
|
|
42250
|
+
var showCloseButton = Boolean(props.showCloseButton && props.onClose);
|
|
42251
|
+
var showHelpButton = Boolean(props.helpLink);
|
|
42252
|
+
var showButtons = showCloseButton || showHelpButton;
|
|
42253
|
+
var showHeadingIcon = props.headingIcon && !props.isLoading;
|
|
42254
|
+
return (React__default["default"].createElement(Modal, { key: props.key, isOpen: true,
|
|
42255
|
+
// disble the `shouldClose` props as we handle them ourselves
|
|
42256
|
+
shouldCloseOnOverlayClick: false, shouldCloseOnEsc: false, overlayClassName: "modal", className: props.lowContrast ? 'lui-scrim-low-contrast' : 'lui-scrim',
|
|
42257
|
+
// required to prevent warnings that are not applicable in real usage
|
|
42258
|
+
ariaHideApp: !isTest, parentSelector: props.appendToElement },
|
|
42259
|
+
React__default["default"].createElement("div", { ref: function (el) {
|
|
42260
|
+
modalRef.current = el;
|
|
42261
|
+
handleAutoFocus(el);
|
|
42262
|
+
}, className: clsx('lui-modal-v2 lui-box-shadow', props.maxWidth && 'lui-max-width', props.className) },
|
|
42263
|
+
React__default["default"].createElement("div", { className: "lui-modal-v2-header" },
|
|
42264
|
+
props.isLoading && (React__default["default"].createElement(LuiMiniSpinner, { size: 20, divProps: { className: 'lui-modal-v2-header-spinner' } })),
|
|
42265
|
+
showHeadingIcon && (React__default["default"].createElement("div", { className: "lui-modal-v2-header-icon" },
|
|
42266
|
+
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) })))),
|
|
42267
|
+
props.headingText && (React__default["default"].createElement("h2", { className: "lui-modal-v2-header-title" }, props.headingText)),
|
|
42268
|
+
showButtons && (React__default["default"].createElement("div", { className: "lui-modal-v2-header-buttons" },
|
|
42269
|
+
showHelpButton && React__default["default"].createElement(HelpButton, { helpLink: props.helpLink }),
|
|
42270
|
+
showCloseButton && React__default["default"].createElement(CloseButton, { onClose: props.onClose })))),
|
|
42271
|
+
React__default["default"].createElement("div", { className: "lui-modal-v2-contents" }, props.children))));
|
|
42272
|
+
};
|
|
42273
|
+
var ButtonRow = function (props) { return (React__default["default"].createElement("div", { className: clsx('lui-modal-v2-btn-row', props.className) }, props.children)); };
|
|
42274
|
+
LuiModalV2.Buttons = ButtonRow;
|
|
42275
|
+
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'
|
|
42276
|
+
? function () { return window.open(props.helpLink, '_blank'); }
|
|
42277
|
+
: props.helpLink },
|
|
42278
|
+
React__default["default"].createElement(LuiIcon, { name: "ic_help_outline", alt: "Help", size: "md" }))); };
|
|
42279
|
+
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 },
|
|
42280
|
+
React__default["default"].createElement(LuiIcon, { name: "ic_clear", alt: "Help", size: "md" }))); };
|
|
42281
|
+
/** Allows injecting the modal header text. Useful when you can't use the `headingText` prop directly, or when you need to render styled content. */
|
|
42282
|
+
var HeaderTitle = function (props) {
|
|
42283
|
+
var _a = React.useState(), target = _a[0], setTarget = _a[1];
|
|
42284
|
+
// on mount, find the parent modal and set it as the target
|
|
42285
|
+
if (!target)
|
|
42286
|
+
return (React__default["default"].createElement("div", { style: { display: 'none' }, ref: function (el) {
|
|
42287
|
+
var modal = el === null || el === void 0 ? void 0 : el.closest(".lui-modal-v2");
|
|
42288
|
+
var modalHeader = modal === null || modal === void 0 ? void 0 : modal.querySelector(':scope > .lui-modal-v2-header');
|
|
42289
|
+
modalHeader && setTarget(modalHeader);
|
|
42290
|
+
} }));
|
|
42291
|
+
return ReactDOM.createPortal(React__default["default"].createElement("h2", { className: clsx('lui-modal-v2-header-title lui-modal-v2-header-title-portal', props.className) }, props.children), target);
|
|
42292
|
+
};
|
|
42293
|
+
LuiModalV2.HeaderTitle = HeaderTitle;
|
|
42294
|
+
// this is here for the tests
|
|
42295
|
+
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';
|
|
42296
|
+
if (!isTest)
|
|
42297
|
+
Modal.setAppElement('#root');
|
|
42298
|
+
|
|
42299
|
+
var LuiAlertModalV2 = function (props) {
|
|
42300
|
+
var level = props.level, className = props.className, children = props.children, rest = __rest(props, ["level", "className", "children"]);
|
|
42301
|
+
var materialIcon = getMaterialIconForLevel(level);
|
|
42302
|
+
var status = Object.keys(ICON_STATUS).includes(level)
|
|
42303
|
+
? level
|
|
42304
|
+
: 'interactive';
|
|
42305
|
+
return (React__default["default"].createElement(LuiModalV2, __assign({}, rest, { className: clsx("lui-modal-v2-alert lui-modal-v2-".concat(level), className), headingIcon: {
|
|
42306
|
+
name: "ic_".concat(materialIcon),
|
|
42307
|
+
alt: "".concat(level, " status icon"),
|
|
42308
|
+
size: 'md',
|
|
42309
|
+
status: status
|
|
42310
|
+
} }), children));
|
|
42311
|
+
};
|
|
42312
|
+
|
|
42205
42313
|
var css_248z$g = "@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";
|
|
42206
42314
|
styleInject(css_248z$g);
|
|
42207
42315
|
|
|
@@ -46800,34 +46908,6 @@ var LuiTooltip = function (props) {
|
|
|
46800
46908
|
return React__default["default"].createElement(Tippy, __assign({}, tippyProps), children);
|
|
46801
46909
|
};
|
|
46802
46910
|
|
|
46803
|
-
/**
|
|
46804
|
-
* This hook will callback with handleClickOutside() when "mousedown" dom event occurs off the refElement
|
|
46805
|
-
* usage:
|
|
46806
|
-
```typescript
|
|
46807
|
-
const refElement = React.useRef<HTMLButtonElement>(null);
|
|
46808
|
-
const handleClickOutside = () => {
|
|
46809
|
-
console.log("hello world");
|
|
46810
|
-
};
|
|
46811
|
-
useClickedOutsideElement(refElement, handleClickOutside);
|
|
46812
|
-
return <button ref={refElement}>Click Me!</button>;
|
|
46813
|
-
```
|
|
46814
|
-
*/
|
|
46815
|
-
function useClickedOutsideElement(refElement, handleClickOutside) {
|
|
46816
|
-
React__default["default"].useEffect(function () {
|
|
46817
|
-
function onOutsideClicked(event) {
|
|
46818
|
-
var element = refElement.current;
|
|
46819
|
-
if (!(element === null || element === void 0 ? void 0 : element.contains(event.target))) {
|
|
46820
|
-
handleClickOutside();
|
|
46821
|
-
}
|
|
46822
|
-
}
|
|
46823
|
-
document.addEventListener('mousedown', onOutsideClicked);
|
|
46824
|
-
return function () {
|
|
46825
|
-
document.removeEventListener('mousedown', onOutsideClicked);
|
|
46826
|
-
};
|
|
46827
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46828
|
-
}, []);
|
|
46829
|
-
}
|
|
46830
|
-
|
|
46831
46911
|
var getFillClassName = function (fillVariation, backgroundFill) {
|
|
46832
46912
|
if (backgroundFill) {
|
|
46833
46913
|
return 'LuiBadge--fill';
|
|
@@ -59696,6 +59776,7 @@ exports.LuiAccordicardStatic = LuiAccordicardStatic;
|
|
|
59696
59776
|
exports.LuiAccordion = LuiAccordion;
|
|
59697
59777
|
exports.LuiAlertModal = LuiAlertModal;
|
|
59698
59778
|
exports.LuiAlertModalButtons = LuiAlertModalButtons;
|
|
59779
|
+
exports.LuiAlertModalV2 = LuiAlertModalV2;
|
|
59699
59780
|
exports.LuiAppFooterSml = LuiAppFooterSml;
|
|
59700
59781
|
exports.LuiBadge = LuiBadge;
|
|
59701
59782
|
exports.LuiBanner = LuiBanner;
|
|
@@ -59749,6 +59830,7 @@ exports.LuiMenuCloseButtonV2 = LuiMenuCloseButtonV2;
|
|
|
59749
59830
|
exports.LuiMessagingContextProvider = LuiMessagingContextProvider;
|
|
59750
59831
|
exports.LuiMiniSpinner = LuiMiniSpinner;
|
|
59751
59832
|
exports.LuiModal = LuiModal;
|
|
59833
|
+
exports.LuiModalV2 = LuiModalV2;
|
|
59752
59834
|
exports.LuiMoneyInput = LuiMoneyInput;
|
|
59753
59835
|
exports.LuiMultiSwitch = LuiMultiSwitch;
|
|
59754
59836
|
exports.LuiMultiSwitchYesNo = LuiMultiSwitchYesNo;
|