@luscii-healthtech/web-ui 37.5.4 → 37.5.6

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,5 +1,5 @@
1
- import React from "react";
2
- import { type Props as BoxProps } from "../Box/Box";
1
+ import React, { type ComponentProps } from "react";
2
+ import { Box } from "../Box/Box";
3
3
  import { type TitleProps } from "../Title/Title";
4
4
  type TitleAndMaybeActions = {
5
5
  title: string;
@@ -30,18 +30,9 @@ type TitleAndMaybeActions = {
30
30
  */
31
31
  actions?: never;
32
32
  };
33
- export type Props<C extends React.ElementType> = React.ComponentPropsWithoutRef<C> & {
34
- as?: C;
33
+ export type Props<C extends React.ElementType = "div"> = ComponentProps<typeof Box<C>> & {
35
34
  border?: boolean;
36
35
  children: React.ReactNode;
37
- /**
38
- * Adds a box-shadow to the element based on the design system
39
- */
40
- elevation?: BoxProps<C>["elevation"];
41
- /**
42
- * The elevation from the design system to apply when hovering over the card.
43
- */
44
- elevationOnHover?: BoxProps<C>["elevation"];
45
36
  /**
46
37
  * Whether or not to add the default padding to the card. Set this
47
38
  * to `false` if you want to render something full width inside of the
@@ -27,6 +27,18 @@ type Props = Omit<React.ComponentPropsWithoutRef<"dialog">, "open" | "onClose">
27
27
  * Determines the max-width of the modal.
28
28
  */
29
29
  size?: Size;
30
+ /**
31
+ * Determines the presentation of the modal
32
+ *
33
+ * - `"centered-dialog"`
34
+ * Presents a dialog centered on screen.
35
+ *
36
+ * - `"side-modal"`
37
+ * Presents a dialog on the right side of the screen stretching the full height of the viewport.
38
+ *
39
+ * @default "centered-dialog"
40
+ */
41
+ variant?: "centered-dialog" | "side-modal";
30
42
  };
31
43
  type SubComponents = {
32
44
  /**
@@ -1,6 +1,7 @@
1
- import React from "react";
1
+ import React, { type ReactNode } from "react";
2
2
  import { Text } from "../Text/Text";
3
3
  import { Divider } from "../Divider/Divider";
4
+ import { DetailsDisclosure } from "../DetailsDisclosure/DetailsDisclosure";
4
5
  type Props = React.ComponentPropsWithoutRef<"div"> & {
5
6
  /**
6
7
  * Renders above the menu items, but below the header.
@@ -14,6 +15,12 @@ type Props = React.ComponentPropsWithoutRef<"div"> & {
14
15
  * Renders below everything else.
15
16
  */
16
17
  footer?: React.ReactNode;
18
+ /**
19
+ * Presentation of the vertical menu.
20
+ *
21
+ * @default 'primary'
22
+ */
23
+ variant?: "primary" | "secondary";
17
24
  };
18
25
  type StaticComponents = {
19
26
  Divider: typeof MenuDivider;
@@ -22,6 +29,7 @@ type StaticComponents = {
22
29
  ItemText: typeof MenuItemText;
23
30
  ItemPadding: typeof MenuItemPadding;
24
31
  NotificationBubble: typeof MenuItemNotificationBubble;
32
+ ItemGroup: typeof MenuItemGroup;
25
33
  };
26
34
  export declare const VerticalMenu: React.FC<Props> & StaticComponents;
27
35
  declare function MenuItemText(props: Readonly<React.ComponentPropsWithoutRef<typeof Text>>): React.JSX.Element;
@@ -83,4 +91,7 @@ declare function MenuItemNotificationBubble(props: Readonly<{
83
91
  className?: string;
84
92
  }>): React.JSX.Element;
85
93
  declare function MenuDivider(props: React.ComponentPropsWithoutRef<typeof Divider>): React.JSX.Element;
94
+ declare function MenuItemGroup({ title, children, ...rest }: React.ComponentPropsWithoutRef<typeof DetailsDisclosure> & {
95
+ title: ReactNode;
96
+ }): React.JSX.Element;
86
97
  export {};
@@ -6326,15 +6326,77 @@ const FullPageModal = ({ children, dataTestId, isOpen = false, onCloseClick, pri
6326
6326
  FullPageModal.Actions = FullPageModalActions;
6327
6327
  FullPageModal.setAppElement = ReactModal__default.default.setAppElement;
6328
6328
 
6329
+ const context$1 = React.createContext({ isOpen: false });
6330
+ const DetailsDisclosure = (_a) => {
6331
+ var { children, onToggleDetails, name, onToggle, openByDefault, open } = _a, rest = __rest(_a, ["children", "onToggleDetails", "name", "onToggle", "openByDefault", "open"]);
6332
+ const [internalIsOpen, setInternalIsOpen] = React.useState(openByDefault !== null && openByDefault !== void 0 ? openByDefault : false);
6333
+ const isOpen = open !== null && open !== void 0 ? open : internalIsOpen;
6334
+ return React__namespace.default.createElement(
6335
+ context$1.Provider,
6336
+ { value: { isOpen } },
6337
+ React__namespace.default.createElement(Box, Object.assign({
6338
+ as: "details",
6339
+ /**
6340
+ * This "name" attribute triggers a type-error on "details" eventhough it should be valid
6341
+ * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#name
6342
+ // @ts-ignore*/
6343
+ name,
6344
+ onToggle: (e) => {
6345
+ const wasOpened = e.currentTarget.hasAttribute("open");
6346
+ onToggleDetails === null || onToggleDetails === void 0 ? void 0 : onToggleDetails(wasOpened);
6347
+ setInternalIsOpen(wasOpened);
6348
+ onToggle === null || onToggle === void 0 ? void 0 : onToggle(e);
6349
+ },
6350
+ open: isOpen
6351
+ }, rest), children)
6352
+ );
6353
+ };
6354
+ const DefaultOpenIndicator = ({ isOpen }) => {
6355
+ return React__namespace.default.createElement(ChevronRightIcon, { className: classNames__default.default("ui-shrink-0 ui-transition-transform", {
6356
+ "ui-rotate-90": isOpen
6357
+ }) });
6358
+ };
6359
+ const OpenIndicator = ({ component: Component = DefaultOpenIndicator }) => {
6360
+ const { isOpen } = React.useContext(context$1);
6361
+ return React__namespace.default.createElement(Component, { isOpen });
6362
+ };
6363
+ const Summary = (_a) => {
6364
+ var { children, omitOpenIndicator = false } = _a, rest = __rest(_a, ["children", "omitOpenIndicator"]);
6365
+ const { isOpen } = React.useContext(context$1);
6366
+ return React__namespace.default.createElement(
6367
+ Stack,
6368
+ Object.assign({ as: "summary", pl: "s", hoverBackgroundColor: "blue", cursor: "pointer" }, rest),
6369
+ React__namespace.default.createElement(
6370
+ Stack,
6371
+ { axis: "x", justify: "between", align: "center", width: "full" },
6372
+ React__namespace.default.createElement(
6373
+ Stack,
6374
+ { axis: "x", width: "full", align: "center", gap: "xxs" },
6375
+ !omitOpenIndicator && React__namespace.default.createElement(DefaultOpenIndicator, { isOpen }),
6376
+ React__namespace.default.createElement(Box, { width: "full" }, children)
6377
+ )
6378
+ )
6379
+ );
6380
+ };
6381
+ DetailsDisclosure.Summary = Summary;
6382
+ Summary.OpenIndicator = OpenIndicator;
6383
+
6384
+ const context = React.createContext({
6385
+ variant: "primary"
6386
+ });
6329
6387
  const VerticalMenu = (props) => {
6330
- const { className, title, header, footer } = props, rest = __rest(props, ["className", "title", "header", "footer"]);
6388
+ const { className, title, header, footer, variant = "primary" } = props, rest = __rest(props, ["className", "title", "header", "footer", "variant"]);
6331
6389
  return React__namespace.default.createElement(
6332
- "div",
6333
- Object.assign({ className: classNames__default.default("ui-flex ui-h-full ui-flex-col ui-px-xxs ui-py-m ui-text-slate-800", className) }, rest),
6334
- React__namespace.default.createElement("div", null, header),
6335
- React__namespace.default.createElement(Text, { className: "ui-px-m ui-pb-m ui-pt-xs", variant: "lg-strong" }, title),
6336
- React__namespace.default.createElement("div", null, props.children),
6337
- React__namespace.default.createElement("div", { className: "ui-mt-auto" }, footer)
6390
+ context.Provider,
6391
+ { value: { variant } },
6392
+ React__namespace.default.createElement(
6393
+ "div",
6394
+ Object.assign({ className: classNames__default.default("ui-flex ui-h-full ui-flex-col ui-px-xxs ui-py-m ui-text-slate-800", className) }, rest),
6395
+ header && React__namespace.default.createElement("div", null, header),
6396
+ title && React__namespace.default.createElement(Text, { className: "ui-px-m ui-pb-m ui-pt-xs", variant: "lg-strong" }, title),
6397
+ React__namespace.default.createElement("div", null, props.children),
6398
+ React__namespace.default.createElement("div", { className: "ui-mt-auto" }, footer)
6399
+ )
6338
6400
  );
6339
6401
  };
6340
6402
  VerticalMenu.Divider = MenuDivider;
@@ -6343,25 +6405,40 @@ VerticalMenu.ItemLayout = MenuItemLayout;
6343
6405
  VerticalMenu.ItemText = MenuItemText;
6344
6406
  VerticalMenu.ItemPadding = MenuItemPadding;
6345
6407
  VerticalMenu.NotificationBubble = MenuItemNotificationBubble;
6408
+ VerticalMenu.ItemGroup = MenuItemGroup;
6346
6409
  function MenuItemText(props) {
6347
- return React__namespace.default.createElement(Text, Object.assign({ color: "current", variant: "strong" }, props, { className: classNames__default.default("sm:ui-leading-[24px]", props.className) }));
6410
+ const { variant: menuVariant } = React.useContext(context);
6411
+ return React__namespace.default.createElement(Text, Object.assign({ inline: true, color: "current", variant: menuVariant === "primary" ? "strong" : props.variant }, props, { className: classNames__default.default("sm:ui-leading-[24px]", props.className) }));
6348
6412
  }
6349
- const getClassName = ({ isActive = false, classNameProp = "" } = {}) => classNames__default.default(
6350
- // Base
6351
- "ui-block ui-w-full ui-px-m ui-py-xs ui-radius-xxs",
6352
- // Transitions
6353
- "ui-transition-[color,background,transform]",
6354
- // States
6355
- "hover:ui-bg-primary-background hover:ui-text-primary focus:ui-text-primary active:ui-scale-[0.98]",
6356
- {
6357
- "ui-bg-transparent ui-text-on-surface": !isActive,
6358
- "ui-bg-gradient-to-r ui-from-blue-800 ui-to-blue-700 ui-text-white hover:ui-text-white focus:ui-text-white": isActive
6359
- },
6360
- classNameProp
6361
- );
6413
+ const useGetClassName = () => {
6414
+ const { variant } = React.useContext(context);
6415
+ return React.useCallback(({ isActive = false, classNameProp = "" } = {}) => {
6416
+ const base = "ui-block ui-w-full ui-px-m ui-py-xs ui-radius-xxs";
6417
+ switch (variant) {
6418
+ case "primary":
6419
+ return classNames__default.default(
6420
+ base,
6421
+ // Transitions
6422
+ "ui-transition-[color,background,transform]",
6423
+ // States
6424
+ "hover:ui-bg-primary-background hover:ui-text-primary focus:ui-text-primary active:ui-scale-[0.98]",
6425
+ {
6426
+ "ui-bg-transparent ui-text-on-surface": !isActive,
6427
+ "ui-bg-gradient-to-r ui-from-blue-800 ui-to-blue-700 ui-text-white hover:ui-text-white focus:ui-text-white": isActive
6428
+ },
6429
+ classNameProp
6430
+ );
6431
+ case "secondary":
6432
+ return classNames__default.default(base, "hover:ui-text-primary focus:ui-text-primary active:ui-scale-[0.98]", {
6433
+ ["[&_span]:ui-font-bold"]: isActive
6434
+ });
6435
+ }
6436
+ }, [variant]);
6437
+ };
6362
6438
  function MenuItem(props) {
6363
6439
  var _a;
6364
6440
  const { children, paddingX = true, paddingY = true } = props;
6441
+ const getClassName = useGetClassName();
6365
6442
  if (children) {
6366
6443
  return React__namespace.default.createElement("div", { className: classNames__default.default({
6367
6444
  "ui-px-m": paddingX,
@@ -6414,6 +6491,37 @@ function MenuItemNotificationBubble(props) {
6414
6491
  function MenuDivider(props) {
6415
6492
  return React__namespace.default.createElement(Divider, Object.assign({ className: "ui-m-1 ui-my-xxs last:ui-border-b-1" }, props));
6416
6493
  }
6494
+ function MenuItemGroupOpenIndicator({ isOpen }) {
6495
+ return React__namespace.default.createElement(ChevronDownIcon, { className: classNames__default.default("ui-shrink-0 ui-transition-transform", {
6496
+ "ui-rotate-180": isOpen
6497
+ }) });
6498
+ }
6499
+ function MenuItemGroup(_a) {
6500
+ var { title, children } = _a, rest = __rest(_a, ["title", "children"]);
6501
+ return React__namespace.default.createElement(
6502
+ DetailsDisclosure,
6503
+ Object.assign({}, rest),
6504
+ React__namespace.default.createElement(
6505
+ DetailsDisclosure.Summary,
6506
+ { hoverBackgroundColor: void 0, pl: void 0, omitOpenIndicator: true },
6507
+ React__namespace.default.createElement(
6508
+ MenuItemLayout,
6509
+ null,
6510
+ React__namespace.default.createElement(
6511
+ MenuItemPadding,
6512
+ { paddingX: false },
6513
+ React__namespace.default.createElement(
6514
+ Stack,
6515
+ { axis: "x", align: "center", justify: "between", gap: "m" },
6516
+ React__namespace.default.createElement(MenuItemText, { variant: "medium", color: "slate-500" }, title),
6517
+ React__namespace.default.createElement(DetailsDisclosure.Summary.OpenIndicator, { component: MenuItemGroupOpenIndicator })
6518
+ )
6519
+ )
6520
+ )
6521
+ ),
6522
+ children
6523
+ );
6524
+ }
6417
6525
 
6418
6526
  const Actions$1 = (props) => {
6419
6527
  const { children, className } = props, rest = __rest(props, ["children", "className"]);
@@ -6450,7 +6558,7 @@ function TopBar(props) {
6450
6558
  TopBar.Actions = Actions$1;
6451
6559
 
6452
6560
  function Card(props) {
6453
- 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"]);
6561
+ const { actions: __, as: Element = "div", children, border, className, elevation, elevationOnHover, padding = true, title: _, borderRadius = "m" } = props, rest = __rest(props, ["actions", "as", "children", "border", "className", "elevation", "elevationOnHover", "padding", "title", "borderRadius"]);
6454
6562
  const hasHoverEffect = !(elevation === elevationOnHover || elevationOnHover === void 0);
6455
6563
  const hoverShadowClassName = createShadowClassName(elevationOnHover, {
6456
6564
  modifier: "hover",
@@ -6462,7 +6570,7 @@ function Card(props) {
6462
6570
  });
6463
6571
  return React__namespace.default.createElement(
6464
6572
  Box,
6465
- Object.assign({ as: Element, elevation, borderRadius: "m" }, rest, { className: classes }),
6573
+ Object.assign({ as: Element, elevation, borderRadius }, rest, { className: classes }),
6466
6574
  React__namespace.default.createElement(
6467
6575
  Box,
6468
6576
  { className: "ui-bg-white" },
@@ -7215,68 +7323,20 @@ const Collapse = (props) => {
7215
7323
  );
7216
7324
  };
7217
7325
 
7218
- const context = React.createContext({ isOpen: false });
7219
- const DetailsDisclosure = (_a) => {
7220
- var { children, onToggleDetails, name, onToggle, openByDefault, open } = _a, rest = __rest(_a, ["children", "onToggleDetails", "name", "onToggle", "openByDefault", "open"]);
7221
- const [internalIsOpen, setInternalIsOpen] = React.useState(openByDefault !== null && openByDefault !== void 0 ? openByDefault : false);
7222
- const isOpen = open !== null && open !== void 0 ? open : internalIsOpen;
7223
- return React__namespace.default.createElement(
7224
- context.Provider,
7225
- { value: { isOpen } },
7226
- React__namespace.default.createElement(Box, Object.assign({
7227
- as: "details",
7228
- /**
7229
- * This "name" attribute triggers a type-error on "details" eventhough it should be valid
7230
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#name
7231
- // @ts-ignore*/
7232
- name,
7233
- onToggle: (e) => {
7234
- const wasOpened = e.currentTarget.hasAttribute("open");
7235
- onToggleDetails === null || onToggleDetails === void 0 ? void 0 : onToggleDetails(wasOpened);
7236
- setInternalIsOpen(wasOpened);
7237
- onToggle === null || onToggle === void 0 ? void 0 : onToggle(e);
7238
- },
7239
- open: isOpen
7240
- }, rest), children)
7241
- );
7242
- };
7243
- const DefaultOpenIndicator = ({ isOpen }) => {
7244
- return React__namespace.default.createElement(ChevronRightIcon, { className: classNames__default.default("ui-shrink-0 ui-transition-transform", {
7245
- "ui-rotate-90": isOpen
7246
- }) });
7247
- };
7248
- const OpenIndicator = ({ component: Component = DefaultOpenIndicator }) => {
7249
- const { isOpen } = React.useContext(context);
7250
- return React__namespace.default.createElement(Component, { isOpen });
7251
- };
7252
- const Summary = (_a) => {
7253
- var { children, omitOpenIndicator = false } = _a, rest = __rest(_a, ["children", "omitOpenIndicator"]);
7254
- const { isOpen } = React.useContext(context);
7255
- return React__namespace.default.createElement(
7256
- Stack,
7257
- Object.assign({ as: "summary", pl: "s", hoverBackgroundColor: "blue", cursor: "pointer" }, rest),
7258
- React__namespace.default.createElement(
7259
- Stack,
7260
- { axis: "x", justify: "between", align: "center", width: "full" },
7261
- React__namespace.default.createElement(
7262
- Stack,
7263
- { axis: "x", width: "full", align: "center", gap: "xxs" },
7264
- !omitOpenIndicator && React__namespace.default.createElement(DefaultOpenIndicator, { isOpen }),
7265
- React__namespace.default.createElement(Box, { width: "full" }, children)
7266
- )
7267
- )
7268
- );
7269
- };
7270
- DetailsDisclosure.Summary = Summary;
7271
- Summary.OpenIndicator = OpenIndicator;
7272
-
7273
7326
  const ModalDialog = (_a) => {
7274
- var { open, className, size, onClose, children } = _a, rest = __rest(_a, ["open", "className", "size", "onClose", "children"]);
7327
+ var { open, className, size, onClose, children, variant = "centered-dialog" } = _a, rest = __rest(_a, ["open", "className", "size", "onClose", "children", "variant"]);
7275
7328
  const dialog = React.useRef(null);
7276
- const classes = classNames__default.default(className, "ui-bg-transparent", "ui-max-w-[calc(100dvw-theme('spacing.xl'))]", "ui-my-xl", "ui-top-0", "ui-bottom-auto", {
7329
+ const classes = classNames__default.default(className, "ui-bg-transparent", "ui-max-w-[calc(100dvw-theme('spacing.xl'))]", {
7330
+ "ui-my-xl": variant === "centered-dialog"
7331
+ }, "ui-top-0", "ui-bottom-auto", {
7277
7332
  "md:ui-w-80": size === "s",
7278
7333
  "md:ui-w-132": size === "m",
7279
7334
  "md:ui-w-216": size === "l"
7335
+ }, {
7336
+ "ui-right-0": variant === "side-modal",
7337
+ "ui-left-auto": variant === "side-modal",
7338
+ "ui-bottom-0": variant === "side-modal",
7339
+ "ui-max-h-full": variant === "side-modal"
7280
7340
  });
7281
7341
  React.useEffect(() => {
7282
7342
  var _a2, _b;
@@ -7285,14 +7345,19 @@ const ModalDialog = (_a) => {
7285
7345
  } else {
7286
7346
  (_b = dialog.current) === null || _b === void 0 ? void 0 : _b.close();
7287
7347
  }
7288
- }, [open]);
7348
+ }, [open, variant]);
7289
7349
  return React__namespace.default.createElement(
7290
7350
  "dialog",
7291
7351
  Object.assign({ ref: dialog, className: classes, onClose }, rest),
7292
7352
  React__namespace.default.createElement(
7293
7353
  Card,
7294
- { padding: false },
7295
- React__namespace.default.createElement(Stack, { width: "full", align: "stretch", className: "ui-max-h-[calc(100dvh-theme('spacing.xl')*2)]" }, children)
7354
+ { padding: false, borderRadius: variant === "side-modal" ? "none" : "m", className: classNames__default.default({
7355
+ "ui-h-screen": variant === "side-modal"
7356
+ }) },
7357
+ React__namespace.default.createElement(Stack, { width: "full", align: "stretch", className: classNames__default.default({
7358
+ "ui-max-h-[calc(100dvh-theme('spacing.xl')*2)]": variant === "centered-dialog",
7359
+ "ui-h-screen": variant === "side-modal"
7360
+ }) }, children)
7296
7361
  )
7297
7362
  );
7298
7363
  };