@luscii-healthtech/web-ui 0.2.0 → 0.3.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,19 +1,21 @@
1
1
  /// <reference types="react" />
2
2
  import { TextProps } from "../Text/Text";
3
3
  import { RestPropped } from "../../types/general.types";
4
- import { Localization, OnPaginationChange } from "../PaginationMenu/PaginationMenu.types";
4
+ import { Localization, OnPaginationChange, PageSize } from "../PaginationMenu/PaginationMenu.types";
5
5
  export declare type ListTableItem = RestPropped;
6
6
  export interface ListTableProps<ItemType extends ListTableItem, CellType> extends RestPropped {
7
7
  items?: ItemType[];
8
8
  configuration: ListTablePropsConfiguration<ItemType, CellType>;
9
9
  pageCount?: number;
10
10
  currentPage?: number;
11
- onRowClick?: (arg: ItemType) => void;
12
11
  onPaginationChange?: OnPaginationChange;
12
+ pageSize?: PageSize;
13
+ localization?: Localization;
14
+ resultCount?: number;
15
+ onRowClick?: (arg: ItemType) => void;
13
16
  isLoading?: boolean;
14
17
  showHeader?: boolean;
15
18
  className?: string;
16
- localization: Localization;
17
19
  }
18
20
  export interface ListTablePropsConfiguration<ItemType extends ListTableItem, CellType> {
19
21
  emptyValue?: string;
@@ -28,5 +30,5 @@ export interface ListTablePropsConfigurationField<ItemType extends ListTableItem
28
30
  field: (arg: ItemType) => string | CellType;
29
31
  textProps?: Omit<TextProps, "text">;
30
32
  }
31
- export declare function ListTable<ItemType extends ListTableItem, CellType>({ items, configuration, pageCount, currentPage, onPaginationChange, onRowClick, isLoading, showHeader, className, localization, ...restProps }: ListTableProps<ItemType, CellType>): JSX.Element;
33
+ export declare function ListTable<ItemType extends ListTableItem, CellType>({ items, configuration, pageCount, currentPage, onPaginationChange, pageSize, localization, resultCount, onRowClick, isLoading, showHeader, className, ...restProps }: ListTableProps<ItemType, CellType>): JSX.Element;
32
34
  export default ListTable;
@@ -7,4 +7,4 @@ export interface StepProps {
7
7
  step: string;
8
8
  };
9
9
  }
10
- export declare const Step: ({ title, stepNumber, active, localization }: StepProps) => JSX.Element;
10
+ export declare const Step: ({ title, stepNumber, active, localization, }: StepProps) => JSX.Element;
@@ -13,5 +13,5 @@ export interface TagProps {
13
13
  size?: TagSize;
14
14
  className?: string;
15
15
  }
16
- declare const Tag: ({ text, colorTheme, className, size }: TagProps) => JSX.Element;
16
+ declare const Tag: ({ text, colorTheme, className, size, }: TagProps) => JSX.Element;
17
17
  export default Tag;
@@ -1,14 +1,16 @@
1
1
  /// <reference types="react" />
2
2
  import { RestPropped } from "../../types/general.types";
3
3
  import "./Text.scss";
4
- export declare type TextStyle = "sm" | "sm-strong" | "base" | "strong" | "lg" | "lg-strong" | "xl" | "xl-strong" | string;
5
- export declare type TextColor = "base" | "gray-500" | "gray-200" | "white" | "blue" | "red" | "green" | "amber" | "inherit";
4
+ export declare type TextStyle = "sm" | "sm-strong" | "base" | "strong" | "lg" | "lg-strong" | "xl" | "xl-strong";
5
+ export declare type TextColor = "base" | "slate-500" | "slate-200" | "white" | "blue-800" | "red" | "green" | "amber";
6
+ export declare type TextHoverColor = "blue-900" | "white";
6
7
  export interface TextProps extends RestPropped {
7
8
  text: string;
8
9
  type?: TextStyle;
9
10
  inline?: boolean;
10
11
  color?: TextColor;
11
- hoverColor?: TextColor;
12
+ hoverColor?: TextHoverColor;
13
+ hoverInGroup?: boolean;
12
14
  className?: string;
13
15
  containsDangerousHtml?: boolean;
14
16
  truncate?: boolean;
@@ -190,18 +190,6 @@
190
190
  .cweb-checkbox.type-switch.is-checked .cweb-checkbox-icon-container:after {
191
191
  left: 32px; }
192
192
 
193
- .vitals-confirmation-dialog {
194
- margin-top: 4rem !important; }
195
- .vitals-confirmation-dialog .vitals-confirmation-dialog-content {
196
- padding: 24px; }
197
- .vitals-confirmation-dialog .vitals-confirmation-dialog-content .vitals-confirmation-dialog-action-container {
198
- display: flex;
199
- justify-content: space-between;
200
- flex-direction: row;
201
- align-items: center;
202
- width: 100%;
203
- margin-top: 16px; }
204
-
205
193
  .cweb-box-shadow-default {
206
194
  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.24), 0 0 2px 0 rgba(0, 0, 0, 0.12); }
207
195
  @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
@@ -444,6 +432,18 @@
444
432
  .cweb-datepicker-calendar .react-datepicker__day.react-datepicker__day--outside-month {
445
433
  color: #cccccc; }
446
434
 
435
+ .vitals-confirmation-dialog {
436
+ margin-top: 4rem !important; }
437
+ .vitals-confirmation-dialog .vitals-confirmation-dialog-content {
438
+ padding: 24px; }
439
+ .vitals-confirmation-dialog .vitals-confirmation-dialog-content .vitals-confirmation-dialog-action-container {
440
+ display: flex;
441
+ justify-content: space-between;
442
+ flex-direction: row;
443
+ align-items: center;
444
+ width: 100%;
445
+ margin-top: 16px; }
446
+
447
447
  .cweb-box-shadow-default {
448
448
  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.24), 0 0 2px 0 rgba(0, 0, 0, 0.12); }
449
449
  @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
@@ -27,6 +27,33 @@ var htmlToDraft = _interopDefault(require('html-to-draftjs'));
27
27
  require('react-draft-wysiwyg/dist/react-draft-wysiwyg.css');
28
28
 
29
29
  var Text = function Text(props) {
30
+ /**
31
+ * One might argue that we're duplicating strings in this file.
32
+ * That's how tailwind expects to detect used classes, so please do not make
33
+ * anything dynamic or try to string concat class names.
34
+ * https://v1.tailwindcss.com/docs/controlling-file-size
35
+ */
36
+ var allowedColors = {
37
+ base: "text-slate-700",
38
+ "slate-500": "text-slate-500",
39
+ "slate-200": "text-slate-200",
40
+ red: "text-red-700",
41
+ green: "text-green-700",
42
+ amber: "text-yellow-700",
43
+ white: "text-white",
44
+ "blue-800": "text-blue-800"
45
+ };
46
+ var allowedHoverColors = {
47
+ "blue-900": "hover:text-blue-900",
48
+ white: "hover:text-white"
49
+ }; // What is a group hover? https://v1.tailwindcss.com/docs/pseudo-class-variants#group-hover
50
+
51
+ var allowedGroupHoverColors = {
52
+ "blue-900": "group-hover:text-blue-900",
53
+ white: "group-hover:text-white"
54
+ };
55
+ var selectedHoverColor = props.hoverColor && !props.hoverInGroup && allowedHoverColors[props.hoverColor];
56
+ var selectedGroupHoverColor = props.hoverColor && props.hoverInGroup && allowedGroupHoverColors[props.hoverColor];
30
57
  var containerProps = {
31
58
  "data-test-id": props["data-test-id"],
32
59
  className: classNames( // apply different style classes
@@ -45,17 +72,7 @@ var Text = function Text(props) {
45
72
  inline: props.inline,
46
73
  // FIXME: this class doesn't do anything without a max-width
47
74
  truncate: props.truncate
48
- }, {
49
- "text-slate-700": props.color === "base",
50
- "text-slate-500": props.color === "gray-500",
51
- "text-slate-200": props.color === "gray-200",
52
- "text-red-700": props.color === "red",
53
- "text-green-700": props.color === "green",
54
- "text-yellow-700": props.color === "amber",
55
- "text-blue-700": props.color === "blue",
56
- "text-white": props.color === "white",
57
- "text-primary-dark": props.color === "blue"
58
- }, {
75
+ }, allowedColors[props.color || "base"], selectedHoverColor, selectedGroupHoverColor, {
59
76
  "in-html-link": props.containsDangerousHtml
60
77
  }, //can be used to overwrite other classes like the color
61
78
  props.className)
@@ -322,9 +339,8 @@ var ButtonV2 = function ButtonV2(_ref) {
322
339
 
323
340
  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"], {
324
341
  "w-11": !text && icon,
325
- "px-4": text,
326
- "py-2.5": text && icon,
327
- "py-3": text && !icon
342
+ "pl-4 pr-6": text && icon,
343
+ "px-4": text && !icon
328
344
  }, {
329
345
  "opacity-50": isDisabled,
330
346
  "pointer-events-none": isDisabled || isPending
@@ -957,13 +973,13 @@ var Checkbox = function Checkbox(_ref) {
957
973
  })), /*#__PURE__*/React__default.createElement("div", {
958
974
  className: "flex flex-col"
959
975
  }, text && /*#__PURE__*/React__default.createElement(Text, {
960
- className: "ml-2 select-none text-left",
976
+ className: "ml-2 text-left select-none",
961
977
  text: text,
962
978
  "data-test-id": "checkbox-text"
963
979
  }), explanation && /*#__PURE__*/React__default.createElement(Text, {
964
- className: "ml-2 select-none text-left",
980
+ className: "ml-2 text-left select-none",
965
981
  text: explanation,
966
- color: "gray-500",
982
+ color: "slate-500",
967
983
  "data-test-id": "checkbox-explanation"
968
984
  }))));
969
985
  };
@@ -1438,7 +1454,7 @@ var Dropdown = /*#__PURE__*/function (_PureComponent) {
1438
1454
  "data-test-id": item.text,
1439
1455
  text: item.title,
1440
1456
  type: "sm",
1441
- color: "gray-500",
1457
+ color: "slate-500",
1442
1458
  truncate: true
1443
1459
  })), item.subItems.map(function (subItem) {
1444
1460
  return _this.renderIndividualItem(subItem);
@@ -1707,7 +1723,7 @@ var InfoField = function InfoField(props) {
1707
1723
  }, containerProps), /*#__PURE__*/React__default.createElement(Text, {
1708
1724
  text: props.label,
1709
1725
  type: "sm",
1710
- color: "gray-500",
1726
+ color: "slate-500",
1711
1727
  className: classNames({
1712
1728
  "break-words": props.supportsMultiline
1713
1729
  }, {
@@ -1913,7 +1929,7 @@ var PaginationMenuSmall = function PaginationMenuSmall(props) {
1913
1929
  className: "ml-4",
1914
1930
  text: props.currentPageNumber + " / " + props.pageCount,
1915
1931
  type: "sm",
1916
- color: "gray-500"
1932
+ color: "slate-500"
1917
1933
  }), /*#__PURE__*/React__default.createElement(TertiaryButton, {
1918
1934
  className: "ml-4",
1919
1935
  "data-test-id": "next-button",
@@ -2121,7 +2137,7 @@ var PaginationMenuLarge = function PaginationMenuLarge(props) {
2121
2137
  className: "ml-4 flex flex-row items-center"
2122
2138
  }, /*#__PURE__*/React__default.createElement(Text, {
2123
2139
  text: getSummaryText(props.pageCount, props.currentPageNumber, props.localization, props.pageSize, props.resultCount),
2124
- color: "gray-500"
2140
+ color: "slate-500"
2125
2141
  }), /*#__PURE__*/React__default.createElement(SecondaryButton, {
2126
2142
  "data-test-id": "prev-button",
2127
2143
  text: props.localization.previous,
@@ -2225,7 +2241,7 @@ function ListTableCell(_ref) {
2225
2241
  text: emptyValue
2226
2242
  }, textProps, {
2227
2243
  className: textClassName,
2228
- color: "gray-500"
2244
+ color: "slate-500"
2229
2245
  })), hasValue && isString(value) && /*#__PURE__*/React__default.createElement(Text, Object.assign({
2230
2246
  text: value
2231
2247
  }, textProps, {
@@ -2302,7 +2318,7 @@ function ListTableHeader(_ref) {
2302
2318
  })));
2303
2319
  }
2304
2320
 
2305
- var _excluded$9 = ["items", "configuration", "pageCount", "currentPage", "onPaginationChange", "onRowClick", "isLoading", "showHeader", "className", "localization"];
2321
+ var _excluded$9 = ["items", "configuration", "pageCount", "currentPage", "onPaginationChange", "pageSize", "localization", "resultCount", "onRowClick", "isLoading", "showHeader", "className"];
2306
2322
  function ListTable(_ref) {
2307
2323
  var _ref$items = _ref.items,
2308
2324
  items = _ref$items === void 0 ? [] : _ref$items,
@@ -2312,13 +2328,15 @@ function ListTable(_ref) {
2312
2328
  _ref$currentPage = _ref.currentPage,
2313
2329
  currentPage = _ref$currentPage === void 0 ? 1 : _ref$currentPage,
2314
2330
  onPaginationChange = _ref.onPaginationChange,
2331
+ pageSize = _ref.pageSize,
2332
+ localization = _ref.localization,
2333
+ resultCount = _ref.resultCount,
2315
2334
  onRowClick = _ref.onRowClick,
2316
2335
  _ref$isLoading = _ref.isLoading,
2317
2336
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
2318
2337
  _ref$showHeader = _ref.showHeader,
2319
2338
  showHeader = _ref$showHeader === void 0 ? true : _ref$showHeader,
2320
2339
  className = _ref.className,
2321
- localization = _ref.localization,
2322
2340
  restProps = _objectWithoutPropertiesLoose(_ref, _excluded$9);
2323
2341
 
2324
2342
  // For not displaying empty view at creation
@@ -2357,17 +2375,20 @@ function ListTable(_ref) {
2357
2375
  src: SearchNotFoundImage,
2358
2376
  alt: "no-image-found"
2359
2377
  }), /*#__PURE__*/React__default.createElement(Text, {
2360
- className: classNames("no-item-found-text", "w-56 text-base text-gray-600 text-center whitespace-pre-wrap"),
2378
+ className: classNames("no-item-found-text", "w-56 text-base text-center whitespace-pre-wrap"),
2379
+ color: "slate-500",
2361
2380
  text: configuration.emptyListText
2362
2381
  }))))), !showEmptyView && pageCount > 0 && onPaginationChange && /*#__PURE__*/React__default.createElement("tfoot", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", {
2363
2382
  colSpan: configuration.fields.length
2364
2383
  }, /*#__PURE__*/React__default.createElement("div", {
2365
2384
  className: classNames("cweb-list-table-footer", "flex justify-center flex-row items-center", "h-20 py-4 px-4")
2366
2385
  }, /*#__PURE__*/React__default.createElement(PaginationMenu, {
2367
- onChange: onPaginationChange,
2368
2386
  pageCount: pageCount,
2369
2387
  currentPageNumber: currentPage,
2370
- localization: localization
2388
+ onChange: onPaginationChange,
2389
+ pageSize: pageSize,
2390
+ localization: localization,
2391
+ resultCount: resultCount
2371
2392
  })))))));
2372
2393
  }
2373
2394
 
@@ -2688,11 +2709,7 @@ var NavMenuItem = function NavMenuItem(props) {
2688
2709
  currentImg = _useState[0],
2689
2710
  setCurrentImg = _useState[1];
2690
2711
 
2691
- var _useState2 = React.useState(props.isSelected ? "white" : "gray-200"),
2692
- textColor = _useState2[0],
2693
- setTextColor = _useState2[1];
2694
-
2695
- var classes = classNames(["flex", "flex-row", "items-center", "w-auto", "rounded", "px-2", "py-1", "my-2", "mx-2", "hover:bg-gray-600", "transition", "ease-in", "duration-150", "lg:last:pb-2", "focus:outline-primary"], {
2712
+ var classes = classNames(["flex", "flex-row", "items-center", "w-auto", "rounded", "px-2", "py-1", "my-2", "mx-2", "hover:bg-gray-600", "transition", "ease-in", "duration-150", "lg:last:pb-2", "focus:outline-primary", "group"], {
2696
2713
  "bg-nav-menu": !props.isSelected,
2697
2714
  "bg-gray-600": props.isSelected
2698
2715
  });
@@ -2700,14 +2717,12 @@ var NavMenuItem = function NavMenuItem(props) {
2700
2717
  var handleOnMouseOver = function handleOnMouseOver() {
2701
2718
  if (!props.isSelected) {
2702
2719
  setCurrentImg(props.imgOnHover);
2703
- setTextColor("white");
2704
2720
  }
2705
2721
  };
2706
2722
 
2707
2723
  var handleOnMouseOut = function handleOnMouseOut() {
2708
2724
  if (!props.isSelected) {
2709
2725
  setCurrentImg(props.img);
2710
- setTextColor("gray-200");
2711
2726
  }
2712
2727
  };
2713
2728
 
@@ -2724,7 +2739,9 @@ var NavMenuItem = function NavMenuItem(props) {
2724
2739
  }), /*#__PURE__*/React.createElement(Text, {
2725
2740
  type: "strong",
2726
2741
  text: props.title,
2727
- color: textColor
2742
+ hoverInGroup: true,
2743
+ color: "slate-200",
2744
+ hoverColor: "white"
2728
2745
  }));
2729
2746
 
2730
2747
  function handleMenuClick(event) {
@@ -2817,18 +2834,26 @@ var TextLink = function TextLink(props) {
2817
2834
 
2818
2835
  var NotificationBanner = function NotificationBanner(props) {
2819
2836
  var classes = classNames("w-full px-6 py-2 flex flex-row items-center border border-solid rounded", props.className, {
2820
- "bg-slate-100 border-slate-700": props.color === "base",
2821
- "bg-blue-100 border-blue-700": props.color === "blue",
2822
- "bg-red-100 border-red-700": props.color === "red",
2823
- "bg-green-100 border-green-700": props.color === "green",
2824
- "bg-yellow-100 border-yellow-700": props.color === "amber"
2837
+ "bg-slate-50 border-slate-700": props.color === "base",
2838
+ "bg-blue-50 border-blue-700": props.color === "blue",
2839
+ "bg-red-50 border-red-700": props.color === "red",
2840
+ "bg-green-50 border-green-700": props.color === "green",
2841
+ "bg-yellow-50 border-yellow-700": props.color === "amber"
2825
2842
  });
2843
+ var textColor = {
2844
+ red: "red",
2845
+ amber: "amber",
2846
+ green: "green",
2847
+ base: "base",
2848
+ // Blue must be 800 here to pass the contrast test
2849
+ blue: "blue-800"
2850
+ };
2826
2851
  return /*#__PURE__*/React__default.createElement("div", {
2827
2852
  className: classes
2828
2853
  }, props.icon, /*#__PURE__*/React__default.createElement(Text, {
2829
- className: "first:ml-0 ml-4",
2854
+ className: "ml-4 first:ml-0",
2830
2855
  text: props.text,
2831
- color: props.color
2856
+ color: props.color ? textColor[props.color] : "base"
2832
2857
  }), props.linkProps && /*#__PURE__*/React__default.createElement(TextLink, {
2833
2858
  className: "ml-4",
2834
2859
  text: props.linkProps.text,
@@ -2995,7 +3020,7 @@ var Step = function Step(_ref) {
2995
3020
  }), /*#__PURE__*/React__default.createElement(Text, {
2996
3021
  text: localization.step + " " + stepNumber,
2997
3022
  type: "strong",
2998
- color: active ? "blue" : "gray-500"
3023
+ color: active ? "blue-800" : "slate-500"
2999
3024
  }), /*#__PURE__*/React__default.createElement(Text, {
3000
3025
  text: title,
3001
3026
  type: "strong"
@@ -3787,24 +3812,26 @@ var TagColorTheme;
3787
3812
  })(TagColorTheme || (TagColorTheme = {}));
3788
3813
 
3789
3814
  var Tag = function Tag(_ref) {
3815
+ var _textColor;
3816
+
3790
3817
  var text = _ref.text,
3791
3818
  _ref$colorTheme = _ref.colorTheme,
3792
3819
  colorTheme = _ref$colorTheme === void 0 ? TagColorTheme.Gray : _ref$colorTheme,
3793
3820
  className = _ref.className,
3794
3821
  _ref$size = _ref.size,
3795
3822
  size = _ref$size === void 0 ? TagSize.base : _ref$size;
3796
- var containerClassName = classNames("inline py-1 px-2 rounded-lg", className, {
3797
- "bg-red-100 text-red-700": colorTheme === TagColorTheme.Red,
3798
- "bg-orange-100 text-amber-700": colorTheme === TagColorTheme.Amber,
3799
- "bg-green-100 text-green-800": colorTheme === TagColorTheme.Green,
3800
- "bg-slate-100 text-slate-600": colorTheme === TagColorTheme.Gray,
3801
- "bg-blue-50 text-blue-800": colorTheme === TagColorTheme.Blue
3802
- });
3823
+ var textColor = (_textColor = {}, _textColor[TagColorTheme.Red] = "red", _textColor[TagColorTheme.Amber] = "amber", _textColor[TagColorTheme.Green] = "green", _textColor[TagColorTheme.Gray] = "base", _textColor[TagColorTheme.Blue] = "blue-800", _textColor);
3803
3824
  return /*#__PURE__*/React__default.createElement("div", {
3804
- className: containerClassName
3825
+ className: classNames("inline py-1 px-2 rounded-lg", className, {
3826
+ "bg-red-50": colorTheme === TagColorTheme.Red,
3827
+ "bg-orange-50": colorTheme === TagColorTheme.Amber,
3828
+ "bg-green-50": colorTheme === TagColorTheme.Green,
3829
+ "bg-slate-50": colorTheme === TagColorTheme.Gray,
3830
+ "bg-blue-50": colorTheme === TagColorTheme.Blue
3831
+ })
3805
3832
  }, /*#__PURE__*/React__default.createElement(Text, {
3806
3833
  inline: true,
3807
- color: "inherit",
3834
+ color: textColor[colorTheme],
3808
3835
  text: text,
3809
3836
  type: size === TagSize.small ? "sm" : "base"
3810
3837
  }));
@@ -4056,7 +4083,7 @@ function ViewItem(_ref) {
4056
4083
  className: "vitals-view-item-title-line flex justify-start flex-row items-start"
4057
4084
  }, titlePropsMerged && /*#__PURE__*/React__default.createElement(Text, Object.assign({
4058
4085
  className: classNames(titlePropsMerged.className, "vitals-view-item-title mb-1 mr-2"),
4059
- color: "gray-500"
4086
+ color: "slate-500"
4060
4087
  }, titlePropsMerged)), titleAccessory), contentPropsMerged && (contentPropsMerged == null ? void 0 : contentPropsMerged.map(function (textProps) {
4061
4088
  return /*#__PURE__*/React__default.createElement(Text, Object.assign({}, textProps, {
4062
4089
  key: textProps.key || textProps.text