@luscii-healthtech/web-ui 0.8.2 → 0.9.2

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
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { IconProps } from "../Icons/types/IconProps.type";
3
3
  import { TextColor, TextHoverColor } from "../Text/Text";
4
4
  /**
@@ -29,3 +29,10 @@ export interface ButtonProps extends BaseButtonProps, ButtonWithPendingStateProp
29
29
  textColor?: TextColor;
30
30
  textHoverColor?: TextHoverColor;
31
31
  }
32
+ /**
33
+ * Interface for defining a button
34
+ */
35
+ export interface ButtonDefinition<Props extends BaseButtonProps = BaseButtonProps> {
36
+ buttonType: React.FunctionComponent<Props>;
37
+ buttonProps: React.Attributes & Props;
38
+ }
@@ -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,30 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
+ import { ButtonDefinition } from "../ButtonV2/ButtonProps.type";
2
3
  import { IconProps } from "../Icons/types/IconProps.type";
4
+ import { PrimaryButtonProps } from "../../index";
3
5
  export interface ListItemProps {
4
6
  itemId: string | number;
5
7
  title: string;
6
8
  subtitle?: string;
7
- icon?: React.FunctionComponent<IconProps> | null | string;
9
+ icon?: React.FunctionComponent<IconProps> | string;
8
10
  accessories?: JSX.Element[];
9
11
  handleItemClick?: () => void;
10
12
  onAssetLoadError?: (payload: OnAssetLoadErrorPayload) => void;
11
13
  tooltipId?: string;
14
+ /**
15
+ *
16
+ * If the parent list component can have a header,
17
+ * the list items don't need to add a border radius on top of the first item.
18
+ *
19
+ * The header is an optional <li> on top that contains the title and accessories (buttons)
20
+ */
21
+ roundTop?: boolean;
12
22
  }
13
23
  export declare type OnAssetLoadErrorPayload = Pick<ListItemProps, "itemId" | "subtitle" | "title" | "icon">;
14
- export interface ListProps {
24
+ export declare type ListProps = {
25
+ title?: string;
26
+ headerButton?: ButtonDefinition<PrimaryButtonProps>;
27
+ headerTransparent?: boolean;
15
28
  items: ListItemProps[];
16
29
  onAssetLoadError?: (payload: OnAssetLoadErrorPayload) => void;
17
- }
30
+ };
@@ -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;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { default as Acknowledgement, ACKNOWLEDGEMENT_TYPE_OPTIONS, } from "./components/Acknowledgement/Acknowledgement";
2
2
  export { default as Avatar } from "./components/Avatar/Avatar";
3
3
  export { default as Badge } from "./components/Badge/Badge";
4
- export { BaseButtonProps as NonPrimaryButtonProps, ButtonWithPendingStateProps as PrimaryButtonProps, } from "./components/ButtonV2/ButtonProps.type";
4
+ export { BaseButtonProps as NonPrimaryButtonProps, ButtonWithPendingStateProps as PrimaryButtonProps, ButtonDefinition } from "./components/ButtonV2/ButtonProps.type";
5
5
  export { PrimaryButton } from "./components/ButtonV2/PrimaryButton";
6
6
  export { SecondaryButton } from "./components/ButtonV2/SecondaryButton";
7
7
  export { TertiaryButton } from "./components/ButtonV2/TertiaryButton";
@@ -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
  }
@@ -1324,6 +1349,10 @@ video {
1324
1349
  margin-left: auto;
1325
1350
  }
1326
1351
 
1352
+ .mb-px {
1353
+ margin-bottom: 1px;
1354
+ }
1355
+
1327
1356
  .mb-2\.5 {
1328
1357
  margin-bottom: 0.625rem;
1329
1358
  }
@@ -1332,6 +1361,10 @@ video {
1332
1361
  margin-left: 0.625rem;
1333
1362
  }
1334
1363
 
1364
+ .-mt-px {
1365
+ margin-top: -1px;
1366
+ }
1367
+
1335
1368
  .-ml-px {
1336
1369
  margin-left: -1px;
1337
1370
  }
@@ -1496,10 +1529,6 @@ video {
1496
1529
  padding-left: 0.25rem;
1497
1530
  }
1498
1531
 
1499
- .pt-3 {
1500
- padding-top: 0.75rem;
1501
- }
1502
-
1503
1532
  .pl-4 {
1504
1533
  padding-left: 1rem;
1505
1534
  }
@@ -1596,16 +1625,16 @@ video {
1596
1625
  left: 0;
1597
1626
  }
1598
1627
 
1599
- .top-3 {
1600
- top: 0.75rem;
1628
+ .top-6 {
1629
+ top: 1.5rem;
1601
1630
  }
1602
1631
 
1603
1632
  .-top-1 {
1604
1633
  top: -0.25rem;
1605
1634
  }
1606
1635
 
1607
- .-left-3 {
1608
- left: -0.75rem;
1636
+ .-left-2 {
1637
+ left: -0.5rem;
1609
1638
  }
1610
1639
 
1611
1640
  .-right-54 {
@@ -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,37 @@ 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 py-4 space-x-4", {
2678
+ "bg-white border-b border-slate-100 px-4": !headerTransparent,
2679
+ "mb-px": headerTransparent,
2680
+ "justify-between": title && headerButton,
2681
+ "justify-start": title && !headerButton,
2682
+ "justify-end": !title && headerButton
2683
+ })
2684
+ }, title && /*#__PURE__*/React__default.createElement(Title, {
2685
+ type: "sm",
2686
+ text: title
2687
+ }), !!headerButton && /*#__PURE__*/React__default.createElement("div", {
2688
+ className: "space-x-3"
2689
+ }, /*#__PURE__*/React__default.createElement(headerButton.buttonType, headerButton.buttonProps))), /*#__PURE__*/React__default.createElement("ul", {
2690
+ className: classNames("list-none")
2640
2691
  }, items.map(function (item) {
2641
2692
  return /*#__PURE__*/React__default.createElement(ListItem, Object.assign({}, item, {
2693
+ roundTop: !hasHeader || hasHeader && headerTransparent,
2642
2694
  key: item.itemId,
2643
2695
  onAssetLoadError: onAssetLoadError
2644
2696
  }));
2645
- }));
2697
+ })));
2646
2698
  };
2647
2699
 
2648
2700
  var TEXT_TYPE_OPTIONS = {
@@ -4188,30 +4240,6 @@ var TextEditorV2 = function TextEditorV2(_ref) {
4188
4240
  }));
4189
4241
  };
4190
4242
 
4191
- var SmallCircleIcon = function SmallCircleIcon(props) {
4192
- return /*#__PURE__*/React__default.createElement("svg", {
4193
- className: props.className,
4194
- onClick: props.onClick,
4195
- role: props.onClick ? "button" : undefined,
4196
- width: "24",
4197
- height: "24",
4198
- viewBox: "0 0 24 24",
4199
- fill: "none",
4200
- xmlns: "http://www.w3.org/2000/svg"
4201
- }, /*#__PURE__*/React__default.createElement("circle", {
4202
- cx: "12",
4203
- cy: "12",
4204
- r: "6",
4205
- fill: "currentColor"
4206
- }), /*#__PURE__*/React__default.createElement("circle", {
4207
- cx: "14.5",
4208
- cy: "9.5",
4209
- r: "1.5",
4210
- fill: "white",
4211
- fillOpacity: "0.1"
4212
- }));
4213
- };
4214
-
4215
4243
  var TimelineStep = function TimelineStep(_ref) {
4216
4244
  var _classNames;
4217
4245
 
@@ -4219,11 +4247,11 @@ var TimelineStep = function TimelineStep(_ref) {
4219
4247
  type = _ref.type;
4220
4248
  var isWideStep = type === "wide";
4221
4249
  var borderClassNames = "ml-4 pl-6 border-blue-800 border-l-2";
4222
- var containerClassNames = classNames("relative", (_classNames = {}, _classNames[borderClassNames] = !isWideStep, _classNames["pt-3"] = !isWideStep, _classNames["bg-white rounded-lg overflow-hidden"] = isWideStep, _classNames));
4250
+ var containerClassNames = classNames("relative", (_classNames = {}, _classNames[borderClassNames] = !isWideStep, _classNames["bg-white rounded-lg overflow-hidden"] = isWideStep, _classNames));
4223
4251
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
4224
4252
  className: containerClassNames
4225
- }, content, !isWideStep && /*#__PURE__*/React__default.createElement(SmallCircleIcon, {
4226
- className: "text-blue-800 absolute top-3 -left-3 -ml-px"
4253
+ }, content, !isWideStep && /*#__PURE__*/React__default.createElement("span", {
4254
+ className: "rounded-lg bg-blue-800 h-4 w-4 absolute top-6 -left-2 -ml-px -mt-px"
4227
4255
  })), /*#__PURE__*/React__default.createElement("div", {
4228
4256
  className: classNames(borderClassNames, "h-6 last:h-0")
4229
4257
  }));
@@ -4949,6 +4977,30 @@ var PinIcon = function PinIcon(props) {
4949
4977
  }));
4950
4978
  };
4951
4979
 
4980
+ var SmallCircleIcon = function SmallCircleIcon(props) {
4981
+ return /*#__PURE__*/React__default.createElement("svg", {
4982
+ className: props.className,
4983
+ onClick: props.onClick,
4984
+ role: props.onClick ? "button" : undefined,
4985
+ width: "24",
4986
+ height: "24",
4987
+ viewBox: "0 0 24 24",
4988
+ fill: "none",
4989
+ xmlns: "http://www.w3.org/2000/svg"
4990
+ }, /*#__PURE__*/React__default.createElement("circle", {
4991
+ cx: "12",
4992
+ cy: "12",
4993
+ r: "6",
4994
+ fill: "currentColor"
4995
+ }), /*#__PURE__*/React__default.createElement("circle", {
4996
+ cx: "14.5",
4997
+ cy: "9.5",
4998
+ r: "1.5",
4999
+ fill: "white",
5000
+ fillOpacity: "0.1"
5001
+ }));
5002
+ };
5003
+
4952
5004
  var SmallDiamondIcon = function SmallDiamondIcon(props) {
4953
5005
  return /*#__PURE__*/React__default.createElement("svg", {
4954
5006
  className: props.className,