@luscii-healthtech/web-ui 0.8.2 → 0.9.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.
package/README.md CHANGED
@@ -25,6 +25,12 @@ Run the script below in your terminal, _in the parent folder of the repositories
25
25
  cp -a web-ui/dist/. cVitals-Web/node_modules/@luscii-healthtech/web-ui/dist
26
26
  ```
27
27
 
28
+ Or use the shortcut:
29
+
30
+ ```
31
+ yarn test-copy-build
32
+ ```
33
+
28
34
  When you run cVitals again, it should contain your latest updates in the component library. Use this to make sure your changes are solid before merging a pull request.
29
35
 
30
36
  ## Contributing
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from "./types/IconProps.type";
3
+ export declare const EmptyIcon: (props: IconProps) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { ListProps, ListItemProps, OnAssetLoadErrorPayload } from "./List.types";
3
3
  export { ListProps, ListItemProps, OnAssetLoadErrorPayload };
4
- export declare const List: ({ items, onAssetLoadError }: ListProps) => JSX.Element;
4
+ export declare const List: ({ title, headerButton, headerTransparent, items, onAssetLoadError, }: ListProps) => JSX.Element;
5
5
  export default List;
@@ -1,17 +1,32 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
+ import { ButtonProps } from "../ButtonV2/ButtonProps.type";
2
3
  import { IconProps } from "../Icons/types/IconProps.type";
3
4
  export interface ListItemProps {
4
5
  itemId: string | number;
5
6
  title: string;
6
7
  subtitle?: string;
7
- icon?: React.FunctionComponent<IconProps> | null | string;
8
+ icon?: React.FunctionComponent<IconProps> | string;
8
9
  accessories?: JSX.Element[];
9
10
  handleItemClick?: () => void;
10
11
  onAssetLoadError?: (payload: OnAssetLoadErrorPayload) => void;
11
12
  tooltipId?: string;
13
+ /**
14
+ *
15
+ * If the parent list component can have a header,
16
+ * the list items don't need to add a border radius on top of the first item.
17
+ *
18
+ * The header is an optional <li> on top that contains the title and accessories (buttons)
19
+ */
20
+ roundTop?: boolean;
12
21
  }
13
22
  export declare type OnAssetLoadErrorPayload = Pick<ListItemProps, "itemId" | "subtitle" | "title" | "icon">;
14
- export interface ListProps {
23
+ export declare type ListProps = {
24
+ title?: string;
25
+ headerButton?: {
26
+ buttonType: React.FunctionComponent<ButtonProps>;
27
+ buttonProps: ButtonProps;
28
+ };
29
+ headerTransparent?: boolean;
15
30
  items: ListItemProps[];
16
31
  onAssetLoadError?: (payload: OnAssetLoadErrorPayload) => void;
17
- }
32
+ };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ListItemProps } from "./List.types";
3
- export declare const ListItem: ({ icon, subtitle, title, accessories, tooltipId, onAssetLoadError, ...restProps }: ListItemProps) => JSX.Element;
3
+ export declare const ListItem: ({ icon, subtitle, title, accessories, tooltipId, onAssetLoadError, roundTop, ...restProps }: ListItemProps) => JSX.Element;
4
4
  export default ListItem;
@@ -947,6 +947,11 @@ video {
947
947
  border-radius: 9999px;
948
948
  }
949
949
 
950
+ .rounded-t {
951
+ border-top-left-radius: 0.25rem;
952
+ border-top-right-radius: 0.25rem;
953
+ }
954
+
950
955
  .rounded-r {
951
956
  border-top-right-radius: 0.25rem;
952
957
  border-bottom-right-radius: 0.25rem;
@@ -962,6 +967,26 @@ video {
962
967
  border-bottom-left-radius: 0.5rem;
963
968
  }
964
969
 
970
+ .first\:rounded-t:first-child {
971
+ border-top-left-radius: 0.25rem;
972
+ border-top-right-radius: 0.25rem;
973
+ }
974
+
975
+ .first\:rounded-l-xl:first-child {
976
+ border-top-left-radius: 0.75rem;
977
+ border-bottom-left-radius: 0.75rem;
978
+ }
979
+
980
+ .last\:rounded-b:last-child {
981
+ border-bottom-right-radius: 0.25rem;
982
+ border-bottom-left-radius: 0.25rem;
983
+ }
984
+
985
+ .last\:rounded-r-xl:last-child {
986
+ border-top-right-radius: 0.75rem;
987
+ border-bottom-right-radius: 0.75rem;
988
+ }
989
+
965
990
  .border-solid {
966
991
  border-style: solid;
967
992
  }
@@ -2578,7 +2578,28 @@ Menu.propTypes = {
2578
2578
  children: PropTypes.node.isRequired
2579
2579
  };
2580
2580
 
2581
- var _excluded$9 = ["icon", "subtitle", "title", "accessories", "tooltipId", "onAssetLoadError"];
2581
+ var EmptyIcon = function EmptyIcon(props) {
2582
+ return /*#__PURE__*/React__default.createElement("svg", {
2583
+ width: "28",
2584
+ height: "28",
2585
+ viewBox: "0 0 28 28",
2586
+ fill: "none",
2587
+ xmlns: "http://www.w3.org/2000/svg",
2588
+ className: props.className,
2589
+ onClick: props.onClick,
2590
+ role: props.onClick ? "button" : undefined
2591
+ }, /*#__PURE__*/React__default.createElement("path", {
2592
+ fillRule: "evenodd",
2593
+ clipRule: "evenodd",
2594
+ d: "M14 22C18.4183 22 22 18.4183 22 14C22 9.58172 18.4183 6 14 6C9.58172 6 6 9.58172 6 14C6 18.4183 9.58172 22 14 22ZM14 25C20.0751 25 25 20.0751 25 14C25 7.92487 20.0751 3 14 3C7.92487 3 3 7.92487 3 14C3 20.0751 7.92487 25 14 25Z",
2595
+ fill: "currentColor"
2596
+ }), /*#__PURE__*/React__default.createElement("path", {
2597
+ d: "M3.4144 24.4144C2.63335 23.6334 2.63335 22.367 3.4144 21.586L21.1485 3.8519C21.9295 3.07085 23.1959 3.07085 23.9769 3.8519C24.7579 4.63295 24.7579 5.89928 23.9769 6.68033L6.24283 24.4144C5.46178 25.1954 4.19545 25.1954 3.4144 24.4144Z",
2598
+ fill: "currentColor"
2599
+ }));
2600
+ };
2601
+
2602
+ var _excluded$9 = ["icon", "subtitle", "title", "accessories", "tooltipId", "onAssetLoadError", "roundTop"];
2582
2603
  var ListItem = function ListItem(_ref) {
2583
2604
  var icon = _ref.icon,
2584
2605
  subtitle = _ref.subtitle,
@@ -2586,8 +2607,13 @@ var ListItem = function ListItem(_ref) {
2586
2607
  accessories = _ref.accessories,
2587
2608
  tooltipId = _ref.tooltipId,
2588
2609
  onAssetLoadError = _ref.onAssetLoadError,
2610
+ roundTop = _ref.roundTop,
2589
2611
  restProps = _objectWithoutPropertiesLoose(_ref, _excluded$9);
2590
2612
 
2613
+ var _useState = React.useState(false),
2614
+ loadIconError = _useState[0],
2615
+ setLoadIconError = _useState[1];
2616
+
2591
2617
  function onListItemIconLoadError() {
2592
2618
  console.error({
2593
2619
  message: "Url from icon failed to load, please check the props passed to `ListItem`.",
@@ -2595,6 +2621,7 @@ var ListItem = function ListItem(_ref) {
2595
2621
  title: title,
2596
2622
  subtitle: subtitle
2597
2623
  });
2624
+ setLoadIconError(true);
2598
2625
  onAssetLoadError == null ? void 0 : onAssetLoadError({
2599
2626
  title: title,
2600
2627
  subtitle: subtitle,
@@ -2603,8 +2630,13 @@ var ListItem = function ListItem(_ref) {
2603
2630
  });
2604
2631
  }
2605
2632
 
2633
+ function onListItemIconLoad() {
2634
+ setLoadIconError(false);
2635
+ }
2636
+
2606
2637
  return /*#__PURE__*/React__default.createElement("li", {
2607
- className: classNames("flex flex-row items-center space-x-4 bg-white", "p-4 border-b last:border-b-0 border-slate-200", {
2638
+ className: classNames("flex last:rounded-b flex-row items-center space-x-4 bg-white", "p-4 border-b last:border-b-0 border-slate-100", {
2639
+ "first:rounded-t": roundTop,
2608
2640
  "cursor-pointer": restProps.handleItemClick,
2609
2641
  "hover:bg-blue-50 transition-colors ease-in-out duration-300": restProps.handleItemClick
2610
2642
  }),
@@ -2613,16 +2645,15 @@ var ListItem = function ListItem(_ref) {
2613
2645
  "data-for": tooltipId
2614
2646
  }, icon && typeof icon === "function" && /*#__PURE__*/React__default.createElement(icon, {
2615
2647
  className: "w-6 h-6"
2616
- }), icon && typeof icon === "string" && /*#__PURE__*/React__default.createElement("img", {
2648
+ }), !loadIconError && icon && typeof icon === "string" && /*#__PURE__*/React__default.createElement("img", {
2617
2649
  src: icon,
2618
2650
  alt: "list-item-icon",
2619
2651
  className: "w-6 h-6 text-sm",
2652
+ onLoad: onListItemIconLoad,
2620
2653
  onError: onListItemIconLoadError
2621
- }), /*#__PURE__*/React__default.createElement("div", {
2622
- className: classNames({
2623
- "pl-10": icon === null
2624
- })
2625
- }, /*#__PURE__*/React__default.createElement(Text, {
2654
+ }), loadIconError && /*#__PURE__*/React__default.createElement(EmptyIcon, {
2655
+ className: "text-slate-300"
2656
+ }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Text, {
2626
2657
  text: title
2627
2658
  }), subtitle && /*#__PURE__*/React__default.createElement(Text, {
2628
2659
  text: subtitle,
@@ -2633,16 +2664,36 @@ var ListItem = function ListItem(_ref) {
2633
2664
  };
2634
2665
 
2635
2666
  var List = function List(_ref) {
2636
- var items = _ref.items,
2667
+ var title = _ref.title,
2668
+ headerButton = _ref.headerButton,
2669
+ headerTransparent = _ref.headerTransparent,
2670
+ items = _ref.items,
2637
2671
  onAssetLoadError = _ref.onAssetLoadError;
2638
- return /*#__PURE__*/React__default.createElement("ul", {
2639
- className: classNames("list-none bg-white")
2672
+ var hasHeader = !!(title || headerButton);
2673
+ return /*#__PURE__*/React__default.createElement("div", {
2674
+ "data-test-id": "list-component"
2675
+ }, (title || headerButton) && /*#__PURE__*/React__default.createElement("div", {
2676
+ "data-test-id": "list-header",
2677
+ className: classNames("flex rounded-t flex-row items-center p-4 space-x-4", {
2678
+ "bg-white border-b border-slate-100": !headerTransparent,
2679
+ "justify-between": title && headerButton,
2680
+ "justify-start": title && !headerButton,
2681
+ "justify-end": !title && headerButton
2682
+ })
2683
+ }, title && /*#__PURE__*/React__default.createElement(Title, {
2684
+ type: "sm",
2685
+ text: title
2686
+ }), !!headerButton && /*#__PURE__*/React__default.createElement("div", {
2687
+ className: "space-x-3"
2688
+ }, /*#__PURE__*/React__default.createElement(headerButton.buttonType, headerButton.buttonProps))), /*#__PURE__*/React__default.createElement("ul", {
2689
+ className: classNames("list-none")
2640
2690
  }, items.map(function (item) {
2641
2691
  return /*#__PURE__*/React__default.createElement(ListItem, Object.assign({}, item, {
2692
+ roundTop: !hasHeader || hasHeader && headerTransparent,
2642
2693
  key: item.itemId,
2643
2694
  onAssetLoadError: onAssetLoadError
2644
2695
  }));
2645
- }));
2696
+ })));
2646
2697
  };
2647
2698
 
2648
2699
  var TEXT_TYPE_OPTIONS = {