@luscii-healthtech/web-ui 0.6.0 → 0.7.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.
@@ -1,8 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { IconProps } from "../Icons/types/IconProps.type";
3
+ import { TextColor, TextHoverColor } from "../Text/Text";
3
4
  export interface BaseButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
4
5
  onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
5
6
  text?: string;
7
+ textColor?: TextColor;
8
+ textHoverColor?: TextHoverColor;
6
9
  icon?: React.FunctionComponent<IconProps>;
7
10
  isDisabled?: boolean;
8
11
  className?: string;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { ButtonProps } from "./ButtonProps.type";
3
- export declare const ButtonV2: ({ onClick, text, icon, isDisabled, isPending, className, ...otherAttributes }: ButtonProps) => JSX.Element;
3
+ export declare const ButtonV2: ({ onClick, text, textColor, textHoverColor, icon, isDisabled, isPending, className, ...otherAttributes }: ButtonProps) => JSX.Element;
@@ -1,7 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ListItemProps } from "./ListItem";
3
- export interface ListProps {
4
- items: ListItemProps[];
5
- }
6
- export declare const List: ({ items }: ListProps) => JSX.Element;
2
+ import { ListProps, ListItemProps, OnAssetLoadErrorPayload } from "./List.types";
3
+ export { ListProps, ListItemProps, OnAssetLoadErrorPayload };
4
+ export declare const List: ({ items, onAssetLoadError }: ListProps) => JSX.Element;
7
5
  export default List;
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from "../Icons/types/IconProps.type";
3
+ export interface ListItemProps {
4
+ itemId: string | number;
5
+ title: string;
6
+ subtitle?: string;
7
+ icon?: React.FunctionComponent<IconProps> | null | string;
8
+ accessories?: JSX.Element[];
9
+ handleItemClick?: () => void;
10
+ onAssetLoadError?: (payload: OnAssetLoadErrorPayload) => void;
11
+ tooltipId?: string;
12
+ }
13
+ export declare type OnAssetLoadErrorPayload = Pick<ListItemProps, "itemId" | "subtitle" | "title" | "icon">;
14
+ export interface ListProps {
15
+ items: ListItemProps[];
16
+ onAssetLoadError?: (payload: OnAssetLoadErrorPayload) => void;
17
+ }
@@ -1,13 +1,4 @@
1
- import React from "react";
2
- import { IconProps } from "../Icons/types/IconProps.type";
3
- export interface ListItemProps {
4
- itemId: string | number;
5
- title: string;
6
- subTitle?: string;
7
- icon?: React.FunctionComponent<IconProps> | null;
8
- accessories?: JSX.Element[];
9
- handleItemClick?: () => void;
10
- tooltipId?: string;
11
- }
12
- export declare const ListItem: ({ icon, subTitle, title, accessories, tooltipId, ...restProps }: ListItemProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { ListItemProps } from "./List.types";
3
+ export declare const ListItem: ({ icon, subtitle, title, accessories, tooltipId, onAssetLoadError, ...restProps }: ListItemProps) => JSX.Element;
13
4
  export default ListItem;
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export { Table, TableProps } from "./components/Table/Table";
21
21
  export { TableFieldConfig, TableFieldContent, TableFieldText, TableFieldAction, } from "./components/Table/Table.types";
22
22
  export { LoadingIndicator, LoadingIndicatorProps, } from "./components/LoadingIndicator/LoadingIndicator";
23
23
  export { default as Menu } from "./components/Menu/Menu";
24
- export { List } from "./components/List/List";
24
+ export { List, ListProps, ListItemProps, OnAssetLoadErrorPayload, } from "./components/List/List";
25
25
  export { MultiSelect } from "./components/MultiSelect/MultiSelect";
26
26
  export { NavLayout, NavMenuLayoutProps } from "./components/NavMenu/NavLayout";
27
27
  export { NavMenu, NavMenuElement } from "./components/NavMenu/NavMenu";
@@ -358,10 +358,12 @@ var Spinner = function Spinner(props) {
358
358
  }));
359
359
  };
360
360
 
361
- var _excluded = ["onClick", "text", "icon", "isDisabled", "isPending", "className"];
361
+ var _excluded = ["onClick", "text", "textColor", "textHoverColor", "icon", "isDisabled", "isPending", "className"];
362
362
  var ButtonV2 = function ButtonV2(_ref) {
363
363
  var onClick = _ref.onClick,
364
364
  text = _ref.text,
365
+ textColor = _ref.textColor,
366
+ textHoverColor = _ref.textHoverColor,
365
367
  icon = _ref.icon,
366
368
  isDisabled = _ref.isDisabled,
367
369
  isPending = _ref.isPending,
@@ -373,7 +375,7 @@ var ButtonV2 = function ButtonV2(_ref) {
373
375
  return /*#__PURE__*/React__default.createElement("span", null, "Invalid props passed to this component.");
374
376
  }
375
377
 
376
- var buttonClassName = classNames(["h-11", "relative flex flex-row justify-center items-center", "border", "transition-outline transition-colors duration-300 ease-in-out", "rounded-full", "leading-none", "shadow-sm", "cursor-pointer", "focus:outline-primary"], {
378
+ var buttonClassName = classNames(["h-11", "relative flex flex-row justify-center items-center", "border", "transition-outline transition-colors duration-300 ease-in-out", "rounded-full", "leading-none", "shadow-sm", "cursor-pointer", "focus:outline-primary", "group"], {
377
379
  "w-11": !text && icon,
378
380
  "pl-4 pr-6": text && icon,
379
381
  "px-4": text && !icon
@@ -400,29 +402,38 @@ var ButtonV2 = function ButtonV2(_ref) {
400
402
  }
401
403
  }, /*#__PURE__*/React__default.createElement(Spinner, {
402
404
  className: "text-white"
403
- })), text && /*#__PURE__*/React__default.createElement("span", {
404
- className: classNames("text-sm font-medium", {
405
+ })), text && /*#__PURE__*/React__default.createElement(Text, {
406
+ className: classNames({
405
407
  invisible: isPending,
406
408
  "ml-1": icon
407
- })
408
- }, text));
409
+ }),
410
+ text: text,
411
+ color: textColor,
412
+ hoverColor: textHoverColor,
413
+ hoverInGroup: true
414
+ }));
409
415
  };
410
416
 
411
417
  var PrimaryButton = function PrimaryButton(props) {
412
418
  return /*#__PURE__*/React__default.createElement(ButtonV2, Object.assign({}, props, {
413
- className: classNames(["text-white", "bg-blue-800", "border-primary-transparent", "hover:bg-blue-900"], props.className)
419
+ className: classNames(["text-white", "bg-blue-800", "border-primary-transparent", "hover:bg-blue-900"], props.className),
420
+ textColor: "white"
414
421
  }));
415
422
  };
416
423
 
417
424
  var SecondaryButton = function SecondaryButton(props) {
418
425
  return /*#__PURE__*/React__default.createElement(ButtonV2, Object.assign({}, props, {
419
- className: classNames(["text-blue-800", "bg-white", "border-slate-300", "hover:text-blue-900", "hover:border-slate-400", "focus:border-blue-800"], props.className)
426
+ className: classNames(["text-blue-800", "bg-white", "border-slate-300", "hover:text-blue-900", "hover:border-slate-400", "focus:border-blue-800"], props.className),
427
+ textColor: "blue-800",
428
+ textHoverColor: "blue-900"
420
429
  }));
421
430
  };
422
431
 
423
432
  var TertiaryButton = function TertiaryButton(props) {
424
433
  return /*#__PURE__*/React__default.createElement(ButtonV2, Object.assign({}, props, {
425
- className: classNames(["text-blue-800", "bg-transparent", "border-transparent", "hover:text-blue-900", "focus:border-blue-800", "shadow-none"], props.className)
434
+ className: classNames(["text-blue-800", "bg-transparent", "border-transparent", "hover:text-blue-900", "focus:border-blue-800", "shadow-none"], props.className),
435
+ textColor: "blue-800",
436
+ textHoverColor: "blue-900"
426
437
  }));
427
438
  };
428
439
 
@@ -2457,12 +2468,12 @@ function Table(_ref) {
2457
2468
  var showEmptyView = !isPristine && !isLoading && !(items && items.length > 0);
2458
2469
  return /*#__PURE__*/React__default.createElement("table", Object.assign({
2459
2470
  className: classNames("w-full rounded-lg bg-white border-collapse table-auto", className)
2460
- }, otherAttributes), showHeader && /*#__PURE__*/React__default.createElement(TableHeader, {
2471
+ }, otherAttributes), showHeader ? /*#__PURE__*/React__default.createElement(TableHeader, {
2461
2472
  className: "border-b border-slate-100",
2462
2473
  fieldConfigurations: fieldConfigurations
2463
- }), /*#__PURE__*/React__default.createElement(TableBody, {
2474
+ }) : null, /*#__PURE__*/React__default.createElement(TableBody, {
2464
2475
  className: classNames({
2465
- "border-b border-slate-100": !showEmptyView && paginationMenuProps && paginationMenuProps.pageCount > 1
2476
+ "border-b border-slate-100": !showEmptyView && paginationMenuProps && paginationMenuProps.currentPageNumber > 0 && paginationMenuProps.pageCount > 0
2466
2477
  }),
2467
2478
  items: items,
2468
2479
  fieldConfigurations: fieldConfigurations,
@@ -2471,10 +2482,10 @@ function Table(_ref) {
2471
2482
  isLoading: isLoading,
2472
2483
  showEmptyView: showEmptyView,
2473
2484
  onRowClick: onRowClick
2474
- }), !showEmptyView && paginationMenuProps && paginationMenuProps.pageCount > 1 && /*#__PURE__*/React__default.createElement(TableFooter, {
2485
+ }), !showEmptyView && paginationMenuProps && paginationMenuProps.currentPageNumber > 0 && paginationMenuProps.pageCount > 0 ? /*#__PURE__*/React__default.createElement(TableFooter, {
2475
2486
  colSpan: fieldConfigurations.length,
2476
2487
  paginationMenuProps: paginationMenuProps
2477
- }));
2488
+ }) : null);
2478
2489
  }
2479
2490
 
2480
2491
  var css_248z$d = ".cweb-menu > .cweb-menu-content {\n min-width: 300px;\n border-radius: 4px;\n background-color: #ffffff;\n}\n\n.cweb-menu > .cweb-menu-button {\n display: flex;\n justify-content: flex-start;\n flex-direction: row;\n align-items: flex-start;\n width: 44px;\n height: 44px;\n background: url(\"data:image/svg+xml,%3Csvg width%3D%2244%22 height%3D%2244%22 viewBox%3D%220 0 44 44%22 fill%3D%22none%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect width%3D%2244%22 height%3D%2244%22 rx%3D%2222%22 fill%3D%22%23E5F5FC%22%2F%3E%3Ccircle cx%3D%2222%22 cy%3D%2215%22 r%3D%223%22 fill%3D%22%23009FE3%22%2F%3E%3Ccircle cx%3D%2222%22 cy%3D%2222%22 r%3D%223%22 fill%3D%22%23009FE3%22%2F%3E%3Ccircle cx%3D%2222%22 cy%3D%2230%22 r%3D%223%22 fill%3D%22%23009FE3%22%2F%3E%3C%2Fsvg%3E\") no-repeat center;\n transition: 0.2s ease;\n background-size: contain;\n}\n\n.cweb-menu > .cweb-menu-button:hover {\n width: 44px;\n height: 44px;\n background: url(\"data:image/svg+xml,%3Csvg width%3D%2244%22 height%3D%2244%22 viewBox%3D%220 0 44 44%22 fill%3D%22none%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect width%3D%2244%22 height%3D%2244%22 rx%3D%2222%22 fill%3D%22%23B3E3F7%22%2F%3E%3Ccircle cx%3D%2222%22 cy%3D%2215%22 r%3D%223%22 fill%3D%22%23009FE3%22%2F%3E%3Ccircle cx%3D%2222%22 cy%3D%2222%22 r%3D%223%22 fill%3D%22%23009FE3%22%2F%3E%3Ccircle cx%3D%2222%22 cy%3D%2230%22 r%3D%223%22 fill%3D%22%23009FE3%22%2F%3E%3C%2Fsvg%3E\") no-repeat center;\n transition: 0.2s ease;\n}\n";
@@ -2560,32 +2571,54 @@ Menu.propTypes = {
2560
2571
  children: PropTypes.node.isRequired
2561
2572
  };
2562
2573
 
2563
- var _excluded$9 = ["icon", "subTitle", "title", "accessories", "tooltipId"];
2574
+ var _excluded$9 = ["icon", "subtitle", "title", "accessories", "tooltipId", "onAssetLoadError"];
2564
2575
  var ListItem = function ListItem(_ref) {
2565
2576
  var icon = _ref.icon,
2566
- subTitle = _ref.subTitle,
2577
+ subtitle = _ref.subtitle,
2567
2578
  title = _ref.title,
2568
2579
  accessories = _ref.accessories,
2569
2580
  tooltipId = _ref.tooltipId,
2581
+ onAssetLoadError = _ref.onAssetLoadError,
2570
2582
  restProps = _objectWithoutPropertiesLoose(_ref, _excluded$9);
2571
2583
 
2584
+ function onListItemIconLoadError() {
2585
+ console.error({
2586
+ message: "Url from icon failed to load, please check the props passed to `ListItem`.",
2587
+ icon: icon,
2588
+ title: title,
2589
+ subtitle: subtitle
2590
+ });
2591
+ onAssetLoadError == null ? void 0 : onAssetLoadError({
2592
+ title: title,
2593
+ subtitle: subtitle,
2594
+ itemId: restProps.itemId,
2595
+ icon: icon
2596
+ });
2597
+ }
2598
+
2572
2599
  return /*#__PURE__*/React__default.createElement("li", {
2573
- className: classNames("flex flex-row items-center space-x-4", "p-4 border-b last:border-b-0 border-slate-200", {
2574
- "cursor-pointer": restProps.handleItemClick
2600
+ className: classNames("flex flex-row items-center space-x-4 bg-white", "p-4 border-b last:border-b-0 border-slate-200", {
2601
+ "cursor-pointer": restProps.handleItemClick,
2602
+ "hover:bg-blue-50 transition-colors ease-in-out duration-300": restProps.handleItemClick
2575
2603
  }),
2576
2604
  onClick: restProps.handleItemClick,
2577
2605
  "data-tip": restProps.itemId,
2578
2606
  "data-for": tooltipId
2579
- }, icon && /*#__PURE__*/React__default.createElement(icon, {
2607
+ }, icon && typeof icon === "function" && /*#__PURE__*/React__default.createElement(icon, {
2580
2608
  className: "w-6 h-6"
2609
+ }), icon && typeof icon === "string" && /*#__PURE__*/React__default.createElement("img", {
2610
+ src: icon,
2611
+ alt: "list-item-icon",
2612
+ className: "w-6 h-6 text-sm",
2613
+ onError: onListItemIconLoadError
2581
2614
  }), /*#__PURE__*/React__default.createElement("div", {
2582
2615
  className: classNames({
2583
2616
  "pl-10": icon === null
2584
2617
  })
2585
2618
  }, /*#__PURE__*/React__default.createElement(Text, {
2586
2619
  text: title
2587
- }), subTitle && /*#__PURE__*/React__default.createElement(Text, {
2588
- text: subTitle,
2620
+ }), subtitle && /*#__PURE__*/React__default.createElement(Text, {
2621
+ text: subtitle,
2589
2622
  type: "sm"
2590
2623
  })), /*#__PURE__*/React__default.createElement("div", {
2591
2624
  className: "flex-grow"
@@ -2593,12 +2626,14 @@ var ListItem = function ListItem(_ref) {
2593
2626
  };
2594
2627
 
2595
2628
  var List = function List(_ref) {
2596
- var items = _ref.items;
2629
+ var items = _ref.items,
2630
+ onAssetLoadError = _ref.onAssetLoadError;
2597
2631
  return /*#__PURE__*/React__default.createElement("ul", {
2598
- className: classNames("list-none")
2632
+ className: classNames("list-none bg-white")
2599
2633
  }, items.map(function (item) {
2600
2634
  return /*#__PURE__*/React__default.createElement(ListItem, Object.assign({}, item, {
2601
- key: item.itemId
2635
+ key: item.itemId,
2636
+ onAssetLoadError: onAssetLoadError
2602
2637
  }));
2603
2638
  }));
2604
2639
  };