@luscii-healthtech/web-ui 0.6.1 → 0.7.1

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,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";
@@ -370,6 +370,11 @@ var ButtonV2 = function ButtonV2(_ref) {
370
370
  className = _ref.className,
371
371
  otherAttributes = _objectWithoutPropertiesLoose(_ref, _excluded);
372
372
 
373
+ function handleClick(event) {
374
+ event.stopPropagation();
375
+ onClick == null ? void 0 : onClick(event);
376
+ }
377
+
373
378
  if (!text && !icon) {
374
379
  console.error("A text or an icon is required to use this component, please make sure to pass at least one of them as a prop.");
375
380
  return /*#__PURE__*/React__default.createElement("span", null, "Invalid props passed to this component.");
@@ -386,7 +391,7 @@ var ButtonV2 = function ButtonV2(_ref) {
386
391
  return /*#__PURE__*/React__default.createElement("button", Object.assign({}, otherAttributes, {
387
392
  className: buttonClassName,
388
393
  type: "button",
389
- onClick: onClick,
394
+ onClick: handleClick,
390
395
  disabled: isDisabled,
391
396
  "aria-disabled": isDisabled
392
397
  }), icon && /*#__PURE__*/React__default.createElement(icon, {
@@ -2093,7 +2098,7 @@ function TableBodyRowDataCell(props) {
2093
2098
  text: content.tag.text,
2094
2099
  colorTheme: content.tag.color
2095
2100
  })), /*#__PURE__*/React__default.createElement(Text, {
2096
- className: "py-4 text-left leading-5 break-all",
2101
+ className: "py-4 leading-5 text-left break-all",
2097
2102
  text: content.text === "" ? emptyFieldContentText : content.text,
2098
2103
  type: "base"
2099
2104
  })), isTableFieldAction(content) && /*#__PURE__*/React__default.createElement("div", {
@@ -2106,8 +2111,7 @@ function TableBodyRowDataCell(props) {
2106
2111
  className: "ml-2 first:ml-0",
2107
2112
  key: action.key,
2108
2113
  icon: action.icon,
2109
- onClick: function onClick(event) {
2110
- event.stopPropagation();
2114
+ onClick: function onClick() {
2111
2115
  action.handleClick(props.item);
2112
2116
  }
2113
2117
  });
@@ -2468,12 +2472,12 @@ function Table(_ref) {
2468
2472
  var showEmptyView = !isPristine && !isLoading && !(items && items.length > 0);
2469
2473
  return /*#__PURE__*/React__default.createElement("table", Object.assign({
2470
2474
  className: classNames("w-full rounded-lg bg-white border-collapse table-auto", className)
2471
- }, otherAttributes), showHeader && /*#__PURE__*/React__default.createElement(TableHeader, {
2475
+ }, otherAttributes), showHeader ? /*#__PURE__*/React__default.createElement(TableHeader, {
2472
2476
  className: "border-b border-slate-100",
2473
2477
  fieldConfigurations: fieldConfigurations
2474
- }), /*#__PURE__*/React__default.createElement(TableBody, {
2478
+ }) : null, /*#__PURE__*/React__default.createElement(TableBody, {
2475
2479
  className: classNames({
2476
- "border-b border-slate-100": !showEmptyView && paginationMenuProps && paginationMenuProps.pageCount > 1
2480
+ "border-b border-slate-100": !showEmptyView && paginationMenuProps && paginationMenuProps.currentPageNumber > 0 && paginationMenuProps.pageCount > 0
2477
2481
  }),
2478
2482
  items: items,
2479
2483
  fieldConfigurations: fieldConfigurations,
@@ -2482,10 +2486,10 @@ function Table(_ref) {
2482
2486
  isLoading: isLoading,
2483
2487
  showEmptyView: showEmptyView,
2484
2488
  onRowClick: onRowClick
2485
- }), !showEmptyView && paginationMenuProps && paginationMenuProps.pageCount > 1 && /*#__PURE__*/React__default.createElement(TableFooter, {
2489
+ }), !showEmptyView && paginationMenuProps && paginationMenuProps.currentPageNumber > 0 && paginationMenuProps.pageCount > 0 ? /*#__PURE__*/React__default.createElement(TableFooter, {
2486
2490
  colSpan: fieldConfigurations.length,
2487
2491
  paginationMenuProps: paginationMenuProps
2488
- }));
2492
+ }) : null);
2489
2493
  }
2490
2494
 
2491
2495
  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";
@@ -2571,32 +2575,54 @@ Menu.propTypes = {
2571
2575
  children: PropTypes.node.isRequired
2572
2576
  };
2573
2577
 
2574
- var _excluded$9 = ["icon", "subTitle", "title", "accessories", "tooltipId"];
2578
+ var _excluded$9 = ["icon", "subtitle", "title", "accessories", "tooltipId", "onAssetLoadError"];
2575
2579
  var ListItem = function ListItem(_ref) {
2576
2580
  var icon = _ref.icon,
2577
- subTitle = _ref.subTitle,
2581
+ subtitle = _ref.subtitle,
2578
2582
  title = _ref.title,
2579
2583
  accessories = _ref.accessories,
2580
2584
  tooltipId = _ref.tooltipId,
2585
+ onAssetLoadError = _ref.onAssetLoadError,
2581
2586
  restProps = _objectWithoutPropertiesLoose(_ref, _excluded$9);
2582
2587
 
2588
+ function onListItemIconLoadError() {
2589
+ console.error({
2590
+ message: "Url from icon failed to load, please check the props passed to `ListItem`.",
2591
+ icon: icon,
2592
+ title: title,
2593
+ subtitle: subtitle
2594
+ });
2595
+ onAssetLoadError == null ? void 0 : onAssetLoadError({
2596
+ title: title,
2597
+ subtitle: subtitle,
2598
+ itemId: restProps.itemId,
2599
+ icon: icon
2600
+ });
2601
+ }
2602
+
2583
2603
  return /*#__PURE__*/React__default.createElement("li", {
2584
- className: classNames("flex flex-row items-center space-x-4", "p-4 border-b last:border-b-0 border-slate-200", {
2585
- "cursor-pointer": restProps.handleItemClick
2604
+ className: classNames("flex flex-row items-center space-x-4 bg-white", "p-4 border-b last:border-b-0 border-slate-200", {
2605
+ "cursor-pointer": restProps.handleItemClick,
2606
+ "hover:bg-blue-50 transition-colors ease-in-out duration-300": restProps.handleItemClick
2586
2607
  }),
2587
2608
  onClick: restProps.handleItemClick,
2588
2609
  "data-tip": restProps.itemId,
2589
2610
  "data-for": tooltipId
2590
- }, icon && /*#__PURE__*/React__default.createElement(icon, {
2611
+ }, icon && typeof icon === "function" && /*#__PURE__*/React__default.createElement(icon, {
2591
2612
  className: "w-6 h-6"
2613
+ }), icon && typeof icon === "string" && /*#__PURE__*/React__default.createElement("img", {
2614
+ src: icon,
2615
+ alt: "list-item-icon",
2616
+ className: "w-6 h-6 text-sm",
2617
+ onError: onListItemIconLoadError
2592
2618
  }), /*#__PURE__*/React__default.createElement("div", {
2593
2619
  className: classNames({
2594
2620
  "pl-10": icon === null
2595
2621
  })
2596
2622
  }, /*#__PURE__*/React__default.createElement(Text, {
2597
2623
  text: title
2598
- }), subTitle && /*#__PURE__*/React__default.createElement(Text, {
2599
- text: subTitle,
2624
+ }), subtitle && /*#__PURE__*/React__default.createElement(Text, {
2625
+ text: subtitle,
2600
2626
  type: "sm"
2601
2627
  })), /*#__PURE__*/React__default.createElement("div", {
2602
2628
  className: "flex-grow"
@@ -2604,12 +2630,14 @@ var ListItem = function ListItem(_ref) {
2604
2630
  };
2605
2631
 
2606
2632
  var List = function List(_ref) {
2607
- var items = _ref.items;
2633
+ var items = _ref.items,
2634
+ onAssetLoadError = _ref.onAssetLoadError;
2608
2635
  return /*#__PURE__*/React__default.createElement("ul", {
2609
- className: classNames("list-none")
2636
+ className: classNames("list-none bg-white")
2610
2637
  }, items.map(function (item) {
2611
2638
  return /*#__PURE__*/React__default.createElement(ListItem, Object.assign({}, item, {
2612
- key: item.itemId
2639
+ key: item.itemId,
2640
+ onAssetLoadError: onAssetLoadError
2613
2641
  }));
2614
2642
  }));
2615
2643
  };