@luscii-healthtech/web-ui 35.10.1 → 35.12.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.
@@ -0,0 +1,74 @@
1
+ import React, { ComponentProps, FC } from "react";
2
+ import { Card } from "../Card/Card";
3
+ import { Box } from "../Box/Box";
4
+ import { Stack } from "../Stack/Stack";
5
+ import { TertiaryButton } from "../ButtonV2/TertiaryButton";
6
+ type Size = "s" | "m" | "l";
7
+ type Props = Omit<React.ComponentPropsWithoutRef<"dialog">, "open" | "onClose"> & {
8
+ /**
9
+ * Triggers `showModal` or `close` on the internal `<dialog />` element when set.
10
+ *
11
+ * Note: the user is able to close the modal outside of this props control. This means a two-way binding with the modal needs to be establised.
12
+ *
13
+ * This should be done by implementing the ModalDialog's onClose prop so it updates the `open` prop accordingly.
14
+ *
15
+ * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog#creating_a_modal_dialog
16
+ */
17
+ open: boolean;
18
+ /**
19
+ * Called when the internal dialog's `onClose` event is triggered.
20
+ *
21
+ * This callback is mandatory as the implementer should always take into account a `<dialog />` can be closed by the user.
22
+ *
23
+ * This callback should be used to update any application state (open) accordingly.
24
+ */
25
+ onClose: React.DialogHTMLAttributes<HTMLDialogElement>["onClose"];
26
+ /**
27
+ * Determines the max-width of the modal.
28
+ */
29
+ size?: Size;
30
+ };
31
+ type SubComponents = {
32
+ /**
33
+ * Represents the header of the ModalDialog. Applies consistent padding.
34
+ */
35
+ Header: typeof Header;
36
+ /**
37
+ * Default title presentation of the ModalDialog.
38
+ *
39
+ * To be placed inside of the ModalDialog's header.
40
+ */
41
+ Title: typeof Card.Title;
42
+ /**
43
+ * A control represeting the close button of the Dialog using a cross icon.
44
+ *
45
+ * To be placed inside of the ModalDialog's header.
46
+ */
47
+ CloseButton: typeof CloseButton;
48
+ /**
49
+ * Applies consistent padding and manages the scroll overflow of the ModalDialog's content,
50
+ * ensuring the Modal does not overflow the users' viewport vertically.
51
+ *
52
+ * To be placed inside of the ModalDialog's header.
53
+ */
54
+ Body: typeof Body;
55
+ /**
56
+ * Represents the footer of the ModalDialog.
57
+ * Applies consistent padding and a background color of type "background".
58
+ */
59
+ Footer: typeof Footer;
60
+ /**
61
+ * Groups together the primary actions of the Modal.
62
+ * These actions should be placed in the Footer of the Modal.
63
+ *
64
+ * To be placed inside of the ModalDialog's footer.
65
+ */
66
+ Actions: typeof Actions;
67
+ };
68
+ export declare const ModalDialog: FC<Props> & SubComponents;
69
+ export declare const Body: FC<ComponentProps<typeof Box>>;
70
+ export declare const Header: FC<ComponentProps<typeof Box>>;
71
+ export declare const Footer: FC<ComponentProps<typeof Stack>>;
72
+ export declare const CloseButton: FC<ComponentProps<typeof TertiaryButton>>;
73
+ export declare const Actions: FC<ComponentProps<typeof Stack>>;
74
+ export {};
package/dist/index.d.ts CHANGED
@@ -107,3 +107,4 @@ export { HoverIndicatorControl } from "./components/HoverIndicatorControl/HoverI
107
107
  export { Collapse } from "./components/Collapse/Collapse";
108
108
  export { Skeleton } from "./components/Skeleton/Skeleton";
109
109
  export { DetailsDisclosure } from "./components/DetailsDisclosure/DetailsDisclosure";
110
+ export { ModalDialog } from "./components/ModalDialog/ModalDialog";
@@ -5962,7 +5962,7 @@ function MenuDivider(props) {
5962
5962
  return React__namespace.default.createElement(Divider, Object.assign({ className: "ui-m-1 ui-my-xxs last:ui-border-b-1" }, props));
5963
5963
  }
5964
5964
 
5965
- const Actions = (props) => {
5965
+ const Actions$1 = (props) => {
5966
5966
  const { children, className } = props, rest = __rest(props, ["children", "className"]);
5967
5967
  return React__namespace.default.createElement("div", Object.assign({}, rest, { className: classNames__default.default(
5968
5968
  /**
@@ -5994,7 +5994,7 @@ function TopBar(props) {
5994
5994
  const { children } = props, rest = __rest(props, ["children"]);
5995
5995
  return React__namespace.default.createElement("div", Object.assign({}, rest, { className: classNames__default.default("ui-my-4", props.className) }), children);
5996
5996
  }
5997
- TopBar.Actions = Actions;
5997
+ TopBar.Actions = Actions$1;
5998
5998
 
5999
5999
  function Card(props) {
6000
6000
  const { actions: __, as: Element = "div", children, border, className, elevation, elevationOnHover, padding = true, title: _ } = props, rest = __rest(props, ["actions", "as", "children", "border", "className", "elevation", "elevationOnHover", "padding", "title"]);
@@ -6022,7 +6022,7 @@ Card.Title = (props) => React__namespace.default.createElement(Title, Object.ass
6022
6022
  Card.TopBar = TopBar;
6023
6023
  Card.Padding = Padding;
6024
6024
  Card.Section = Section;
6025
- Card.Actions = Actions;
6025
+ Card.Actions = Actions$1;
6026
6026
  function RenderTopBar(props) {
6027
6027
  const { title, actions } = props;
6028
6028
  if (title && actions) {
@@ -6033,7 +6033,7 @@ function RenderTopBar(props) {
6033
6033
  TopBar,
6034
6034
  { className: "ui-flex ui-flex-wrap ui-items-center ui-justify-between" },
6035
6035
  React__namespace.default.createElement(Title, { type: "sm" }, title),
6036
- React__namespace.default.createElement(Actions, null, actions)
6036
+ React__namespace.default.createElement(Actions$1, null, actions)
6037
6037
  )
6038
6038
  );
6039
6039
  }
@@ -6044,7 +6044,7 @@ function RenderTopBar(props) {
6044
6044
  React__namespace.default.createElement(
6045
6045
  TopBar,
6046
6046
  null,
6047
- React__namespace.default.createElement(Actions, null, actions)
6047
+ React__namespace.default.createElement(Actions$1, null, actions)
6048
6048
  )
6049
6049
  );
6050
6050
  }
@@ -6762,6 +6762,58 @@ const Summary = (_a) => {
6762
6762
  };
6763
6763
  DetailsDisclosure.Summary = Summary;
6764
6764
 
6765
+ const ModalDialog = (_a) => {
6766
+ var { open, className, size, onClose, children } = _a, rest = __rest(_a, ["open", "className", "size", "onClose", "children"]);
6767
+ const dialog = React.useRef(null);
6768
+ const classes = classNames__default.default(className, "ui-bg-transparent", "ui-max-w-[calc(100dvw-theme('spacing.xl'))]", {
6769
+ "md:ui-w-80": size === "s",
6770
+ "md:ui-w-132": size === "m",
6771
+ "md:ui-w-216": size === "l"
6772
+ });
6773
+ React.useEffect(() => {
6774
+ var _a2, _b;
6775
+ if (open) {
6776
+ (_a2 = dialog.current) === null || _a2 === void 0 ? void 0 : _a2.showModal();
6777
+ } else {
6778
+ (_b = dialog.current) === null || _b === void 0 ? void 0 : _b.close();
6779
+ }
6780
+ }, [open]);
6781
+ return React__namespace.default.createElement(
6782
+ "dialog",
6783
+ Object.assign({ ref: dialog, className: classes, onClose }, rest),
6784
+ React__namespace.default.createElement(
6785
+ Card,
6786
+ { padding: false },
6787
+ React__namespace.default.createElement(Stack, { width: "full", align: "stretch", className: "ui-max-h-[calc(100dvh-theme('spacing.xl'))]" }, children)
6788
+ )
6789
+ );
6790
+ };
6791
+ const Body = (_a) => {
6792
+ var { className } = _a, rest = __rest(_a, ["className"]);
6793
+ const classes = classNames__default.default(className, "ui-overflow-y-auto ui-flex-1");
6794
+ return React__namespace.default.createElement(Box, Object.assign({ className: classes, p: "m" }, rest));
6795
+ };
6796
+ const Header = (props) => {
6797
+ return React__namespace.default.createElement(Stack, Object.assign({ axis: "x", justify: "between", align: "center", gap: "m", p: "m" }, props));
6798
+ };
6799
+ const Footer = (props) => {
6800
+ return React__namespace.default.createElement(Stack, Object.assign({ p: "m", backgroundColor: "background" }, props));
6801
+ };
6802
+ const CloseButton = (props) => {
6803
+ return React__namespace.default.createElement(TertiaryButton, Object.assign({ leadingIcon: React__namespace.default.createElement(CrossIcon, null) }, props));
6804
+ };
6805
+ const Actions = (_a) => {
6806
+ var { className } = _a, rest = __rest(_a, ["className"]);
6807
+ const classes = classNames__default.default(className, "ui-self-end");
6808
+ return React__namespace.default.createElement(Stack, Object.assign({ axis: "x", gap: "xs", className: classes }, rest));
6809
+ };
6810
+ ModalDialog.Header = Header;
6811
+ ModalDialog.Title = Card.Title;
6812
+ ModalDialog.CloseButton = CloseButton;
6813
+ ModalDialog.Body = Body;
6814
+ ModalDialog.Footer = Footer;
6815
+ ModalDialog.Actions = Actions;
6816
+
6765
6817
  Object.defineProperty(exports, 'Toaster', {
6766
6818
  enumerable: true,
6767
6819
  get: function () { return sonner.Toaster; }
@@ -6892,6 +6944,7 @@ exports.MediaPicker = MediaPicker;
6892
6944
  exports.MessageWithArrowIcon = MessageWithArrowIcon;
6893
6945
  exports.MessagesIcon = MessageWithArrowIcon;
6894
6946
  exports.Modal = Modal;
6947
+ exports.ModalDialog = ModalDialog;
6895
6948
  exports.MoreIcon = MoreIcon;
6896
6949
  exports.MouseIcon = MouseIcon;
6897
6950
  exports.NavLayout = NavLayout;