@luscii-healthtech/web-ui 20.3.0 → 20.4.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,86 @@
1
+ import React from "react";
2
+ import { Text } from "../Text/Text";
3
+ import { Divider } from "../Divider/Divider";
4
+ type Props = React.ComponentPropsWithoutRef<"div"> & {
5
+ /**
6
+ * Renders above the menu items, but below the header.
7
+ */
8
+ title?: string | React.ReactNode;
9
+ /**
10
+ * Renders above everything else.
11
+ */
12
+ header?: React.ReactNode;
13
+ /**
14
+ * Renders below everything else.
15
+ */
16
+ footer?: React.ReactNode;
17
+ };
18
+ type StaticComponents = {
19
+ Divider: typeof MenuDivider;
20
+ Item: typeof MenuItem;
21
+ ItemLayout: typeof MenuItemLayout;
22
+ ItemText: typeof MenuItemText;
23
+ ItemPadding: typeof MenuItemPadding;
24
+ NotificationBubble: typeof MenuItemNotificationBubble;
25
+ };
26
+ export declare const VerticalMenu: React.FC<Props> & StaticComponents;
27
+ declare function MenuItemText(props: Readonly<React.ComponentPropsWithoutRef<typeof Text>>): React.JSX.Element;
28
+ type GetClassNameFunction = (args?: {
29
+ /**
30
+ * Whether the item should display as active.
31
+ */
32
+ isActive?: boolean;
33
+ /**
34
+ * Your own class name to add to the item.
35
+ */
36
+ classNameProp?: string;
37
+ }) => string;
38
+ type MenuItemProps = {
39
+ render: (props: {
40
+ /**
41
+ * Returns the "calculated" className for the item.
42
+ *
43
+ * The `VerticalMenu` component will decide which
44
+ * classes should be applied to a menu item to make
45
+ * it appear correctly in the menu. By placing the
46
+ * string of these classes on your own element/component,
47
+ * you allow the `VerticalMenu` component to style your
48
+ * element correctly.
49
+ */
50
+ getClassName: GetClassNameFunction;
51
+ }) => React.ReactNode;
52
+ children?: never;
53
+ paddingX?: never;
54
+ paddingY?: never;
55
+ } | {
56
+ render?: never;
57
+ children?: React.ReactNode;
58
+ paddingX?: boolean;
59
+ paddingY?: boolean;
60
+ };
61
+ declare function MenuItem(props: MenuItemProps): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
62
+ type MenuItemLayoutProps = {
63
+ icon?: React.ReactNode;
64
+ text?: React.ReactNode;
65
+ className?: string;
66
+ children?: React.ReactNode;
67
+ } & ({
68
+ aside?: React.ReactNode;
69
+ notificationBubbleText?: never;
70
+ } | {
71
+ aside?: never;
72
+ notificationBubbleText?: string;
73
+ });
74
+ declare function MenuItemLayout(props: MenuItemLayoutProps): React.JSX.Element;
75
+ declare function MenuItemPadding(props: Readonly<{
76
+ children?: React.ReactNode;
77
+ className?: string;
78
+ paddingX?: boolean;
79
+ paddingY?: boolean;
80
+ }>): React.JSX.Element;
81
+ declare function MenuItemNotificationBubble(props: Readonly<{
82
+ children?: React.ReactNode;
83
+ className?: string;
84
+ }>): React.JSX.Element;
85
+ declare function MenuDivider(props: React.ComponentPropsWithoutRef<typeof Divider>): React.JSX.Element;
86
+ export {};
package/dist/index.d.ts CHANGED
@@ -81,6 +81,7 @@ export type { IconProps, IconKey, } from "./components/Icons/types/IconProps.typ
81
81
  export * from "./components/Icons";
82
82
  export { Divider } from "./components/Divider/Divider";
83
83
  export { FullPageModal } from "./components/Modal/FullPageModal";
84
+ export { VerticalMenu } from "./components/VerticalMenu/VerticalMenu";
84
85
  export { Card, type Props as CardProps } from "./components/Card/Card";
85
86
  export { Dropzone, DropzoneProps } from "./components/Dropzone";
86
87
  export { FilterBar, FilterBarUtils } from "./components/FilterBar";
@@ -5409,6 +5409,95 @@ const FullPageModal = ({ children, dataTestId, isOpen = false, onCloseClick, pri
5409
5409
  FullPageModal.Actions = FullPageModalActions;
5410
5410
  FullPageModal.setAppElement = ReactModal__default.default.setAppElement;
5411
5411
 
5412
+ const VerticalMenu = (props) => {
5413
+ const { className, title, header, footer } = props, rest = __rest(props, ["className", "title", "header", "footer"]);
5414
+ return React__namespace.default.createElement(
5415
+ "div",
5416
+ 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),
5417
+ React__namespace.default.createElement("div", null, header),
5418
+ React__namespace.default.createElement(Text, { className: "ui-px-m ui-pb-m ui-pt-xs", variant: "lg-strong" }, title),
5419
+ React__namespace.default.createElement("div", null, props.children),
5420
+ React__namespace.default.createElement("div", { className: "ui-mt-auto" }, footer)
5421
+ );
5422
+ };
5423
+ VerticalMenu.Divider = MenuDivider;
5424
+ VerticalMenu.Item = MenuItem;
5425
+ VerticalMenu.ItemLayout = MenuItemLayout;
5426
+ VerticalMenu.ItemText = MenuItemText;
5427
+ VerticalMenu.ItemPadding = MenuItemPadding;
5428
+ VerticalMenu.NotificationBubble = MenuItemNotificationBubble;
5429
+ function MenuItemText(props) {
5430
+ return React__namespace.default.createElement(Text, Object.assign({ color: "current", variant: "strong" }, props, { className: classNames__default.default("ui-leading-[24px]", props.className) }));
5431
+ }
5432
+ const getClassName = ({ isActive = false, classNameProp = "" } = {}) => classNames__default.default(
5433
+ // Base
5434
+ "ui-block ui-w-full ui-px-m ui-py-xs ui-radius-xxs",
5435
+ // Transitions
5436
+ "ui-transition-[color,background,transform]",
5437
+ // States
5438
+ "hover:ui-bg-primary-background hover:ui-text-primary focus:ui-text-primary active:ui-scale-[0.98]",
5439
+ {
5440
+ "ui-bg-transparent ui-text-on-surface": !isActive,
5441
+ "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
5442
+ },
5443
+ classNameProp
5444
+ );
5445
+ function MenuItem(props) {
5446
+ var _a;
5447
+ const { children, paddingX = true, paddingY = true } = props;
5448
+ if (children) {
5449
+ return React__namespace.default.createElement("div", { className: classNames__default.default({
5450
+ "ui-px-m": paddingX,
5451
+ "ui-py-xs": paddingY
5452
+ }) }, children);
5453
+ }
5454
+ return (_a = props.render) === null || _a === void 0 ? void 0 : _a.call(props, { getClassName });
5455
+ }
5456
+ function MenuItemLayout(props) {
5457
+ const { icon, text, aside, notificationBubbleText, className, children } = props;
5458
+ if (children) {
5459
+ return React__namespace.default.createElement("div", null, children);
5460
+ }
5461
+ return React__namespace.default.createElement(
5462
+ "div",
5463
+ { className: classNames__default.default("ui-flex ui-items-start ui-gap-xxs", className) },
5464
+ icon && React__namespace.default.createElement("span", null, icon),
5465
+ text && React__namespace.default.createElement(MenuItemText, null, text),
5466
+ aside && React__namespace.default.createElement("span", { className: "ui-ml-auto" }, aside),
5467
+ notificationBubbleText && React__namespace.default.createElement(
5468
+ "span",
5469
+ { className: "ui-ml-auto" },
5470
+ React__namespace.default.createElement(MenuItemNotificationBubble, null, notificationBubbleText)
5471
+ )
5472
+ );
5473
+ }
5474
+ function MenuItemPadding(props) {
5475
+ const { children, className, paddingX = true, paddingY = true } = props;
5476
+ return React__namespace.default.createElement("div", { className: classNames__default.default({
5477
+ "ui-px-m": paddingX,
5478
+ "ui-py-xs": paddingY
5479
+ }, className) }, children);
5480
+ }
5481
+ function MenuItemNotificationBubble(props) {
5482
+ return React__namespace.default.createElement(
5483
+ "div",
5484
+ { className: classNames__default.default(
5485
+ /**
5486
+ * Spacing `l` is 24px, which is the line height for the
5487
+ * text size here. This makes the bubble a perfect circle when
5488
+ * there is too little text.
5489
+ */
5490
+ "ui-min-w-l",
5491
+ "ui-rounded-full ui-bg-red-500 ui-px-xxs ui-text-center",
5492
+ props.className
5493
+ ) },
5494
+ React__namespace.default.createElement(Text, { color: "white", inline: true, className: "ui-align-text-bottom" }, props.children)
5495
+ );
5496
+ }
5497
+ function MenuDivider(props) {
5498
+ return React__namespace.default.createElement(Divider, Object.assign({ className: "ui-m-1 ui-my-xxs last:ui-border-b-1" }, props));
5499
+ }
5500
+
5412
5501
  const Actions = (props) => {
5413
5502
  const { children, className } = props, rest = __rest(props, ["children", "className"]);
5414
5503
  return React__namespace.default.createElement("div", Object.assign({}, rest, { className: classNames__default.default(
@@ -5985,6 +6074,7 @@ exports.Toaster = Toaster;
5985
6074
  exports.TrashBinIcon = DeleteIcon;
5986
6075
  exports.UList = UnorderedList;
5987
6076
  exports.UnorderedList = UnorderedList;
6077
+ exports.VerticalMenu = VerticalMenu;
5988
6078
  exports.ViewItem = ViewItem;
5989
6079
  exports.WarningIcon = ExclamationMarkIcon;
5990
6080
  exports.WeekdaysPicker = WeekdaysPicker;