@linzjs/lui 21.34.1-3 → 21.34.1-5

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.
@@ -1,4 +1,4 @@
1
- import { FC, PropsWithChildren, ReactNode } from 'react';
1
+ import React, { PropsWithChildren } from 'react';
2
2
  import { LuiIconProps } from '../LuiIcon/LuiIcon';
3
3
  export declare type LuiModalV2Props = {
4
4
  key?: string;
@@ -11,7 +11,7 @@ export declare type LuiModalV2Props = {
11
11
  className?: string;
12
12
  /** If set to true, the modal will take the full screen width. Default `false` */
13
13
  maxWidth?: boolean;
14
- headingText?: ReactNode;
14
+ headingText?: string;
15
15
  headingIcon?: LuiIconProps;
16
16
  helpLink?: string | (() => void | Promise<void>);
17
17
  isLoading?: boolean;
@@ -22,14 +22,12 @@ export declare type LuiModalV2Props = {
22
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
23
  appendToElement?: () => HTMLElement;
24
24
  };
25
- export declare const LuiModalV2: FC<PropsWithChildren<LuiModalV2Props>>;
26
- declare type LuiModalV2ButtonsProps = {
27
- className?: string;
28
- };
29
- export declare const LuiModalV2Buttons: FC<PropsWithChildren<LuiModalV2ButtonsProps>>;
30
- declare type LuiModalV2HeadingTextProps = {
31
- className?: string;
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
+ }>>;
32
33
  };
33
- /** Allows injecting the modal header text */
34
- export declare const LuiModalV2HeadingText: FC<PropsWithChildren<LuiModalV2HeadingTextProps>>;
35
- export {};
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ 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, LuiModalV2HeadingText, type LuiModalV2Props, } from './components/LuiModal/LuiModalV2';
40
+ export { LuiModalV2, type LuiModalV2Props, } from './components/LuiModal/LuiModalV2';
41
41
  export { LuiAlertModalV2, type LuiAlertModalLevel, type LuiAlertModalV2Props, } from './components/LuiModal/LuiAlertModalV2';
42
42
  export { type ISearchInputProps, LuiSearchInput, } from './components/LuiSearchInput/LuiSearchInput';
43
43
  export { type ISearchGroupedResult, type ISearchResult, } from './components/LuiSearchInput/ResultsDisplay';
package/dist/index.js CHANGED
@@ -42358,7 +42358,7 @@ var LuiModalV2 = function (props) {
42358
42358
  modalRef.current = el;
42359
42359
  handleAutoFocus(el);
42360
42360
  }, className: clsx('lui-modal-v2 lui-box-shadow', props.maxWidth && 'lui-max-width', props.className) },
42361
- React__default["default"].createElement("div", { className: "lui-modal-v2-header", id: "lui-modal-v2-header" },
42361
+ React__default["default"].createElement("div", { className: "lui-modal-v2-header" },
42362
42362
  props.isLoading && (React__default["default"].createElement(LuiMiniSpinner, { size: 20, divProps: { className: 'lui-modal-v2-header-spinner' } })),
42363
42363
  showHeadingIcon && (React__default["default"].createElement("div", { className: "lui-modal-v2-header-icon" },
42364
42364
  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) })))),
@@ -42368,24 +42368,27 @@ var LuiModalV2 = function (props) {
42368
42368
  showCloseButton && React__default["default"].createElement(CloseButton, { onClose: props.onClose })))),
42369
42369
  React__default["default"].createElement("div", { className: "lui-modal-v2-contents" }, props.children))));
42370
42370
  };
42371
- var LuiModalV2Buttons = function (props) { return (React__default["default"].createElement("div", { className: clsx('lui-modal-v2-btn-row', props.className) }, props.children)); };
42371
+ var ButtonRow = function (props) { return (React__default["default"].createElement("div", { className: clsx('lui-modal-v2-btn-row', props.className) }, props.children)); };
42372
+ LuiModalV2.Buttons = ButtonRow;
42372
42373
  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'
42373
42374
  ? function () { return window.open(props.helpLink, '_blank'); }
42374
42375
  : props.helpLink },
42375
42376
  React__default["default"].createElement(LuiIcon, { name: "ic_help_outline", alt: "Help", size: "md" }))); };
42376
42377
  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 },
42377
42378
  React__default["default"].createElement(LuiIcon, { name: "ic_clear", alt: "Help", size: "md" }))); };
42378
- /** Allows injecting the modal header text */
42379
- var LuiModalV2HeadingText = function (props) {
42379
+ /** Allows injecting the modal header text. Useful when you can't use the `headingText` prop directly, or when you need to render styled content. */
42380
+ var HeaderTitle = function (props) {
42380
42381
  var _a = React.useState(), target = _a[0], setTarget = _a[1];
42381
- React.useEffect(function () {
42382
- var modalHeader = document.querySelector('#lui-modal-v2-header');
42383
- modalHeader && setTarget(modalHeader);
42384
- }, []);
42382
+ // on mount, find the parent modal and set it as the target
42385
42383
  if (!target)
42386
- return null;
42384
+ return (React__default["default"].createElement("div", { style: { display: 'none' }, ref: function (el) {
42385
+ var modal = el === null || el === void 0 ? void 0 : el.closest(".lui-modal-v2");
42386
+ var modalHeader = modal === null || modal === void 0 ? void 0 : modal.querySelector(':scope > .lui-modal-v2-header');
42387
+ modalHeader && setTarget(modalHeader);
42388
+ } }));
42387
42389
  return require$$1.createPortal(React__default["default"].createElement("h2", { className: clsx('lui-modal-v2-header-title lui-modal-v2-header-title-portal', props.className) }, props.children), target);
42388
- };
42390
+ };
42391
+ LuiModalV2.HeaderTitle = HeaderTitle;
42389
42392
 
42390
42393
  var LuiAlertModalV2 = function (props) {
42391
42394
  var level = props.level, className = props.className, children = props.children, rest = __rest(props, ["level", "className", "children"]);
@@ -42393,7 +42396,7 @@ var LuiAlertModalV2 = function (props) {
42393
42396
  var status = Object.keys(ICON_STATUS).includes(level)
42394
42397
  ? level
42395
42398
  : 'interactive';
42396
- return (React__default["default"].createElement(LuiModalV2, __assign({}, rest, { className: clsx("lui-modal-v2-".concat(level), className), headingIcon: {
42399
+ return (React__default["default"].createElement(LuiModalV2, __assign({}, rest, { className: clsx("lui-modal-v2-alert lui-modal-v2-".concat(level), className), headingIcon: {
42397
42400
  name: "ic_".concat(materialIcon),
42398
42401
  alt: "".concat(level, " status icon"),
42399
42402
  size: 'md',
@@ -59466,8 +59469,6 @@ exports.LuiMessagingContextProvider = LuiMessagingContextProvider;
59466
59469
  exports.LuiMiniSpinner = LuiMiniSpinner;
59467
59470
  exports.LuiModal = LuiModal;
59468
59471
  exports.LuiModalV2 = LuiModalV2;
59469
- exports.LuiModalV2Buttons = LuiModalV2Buttons;
59470
- exports.LuiModalV2HeadingText = LuiModalV2HeadingText;
59471
59472
  exports.LuiMoneyInput = LuiMoneyInput;
59472
59473
  exports.LuiMultiSwitch = LuiMultiSwitch;
59473
59474
  exports.LuiMultiSwitchYesNo = LuiMultiSwitchYesNo;