@vitality-ds/components 5.6.3 → 5.7.0-alpha.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.
@@ -10,7 +10,7 @@ var _default = exports["default"] = (0, _system.css)({
10
10
  opacity: 1,
11
11
  display: "flex",
12
12
  gap: "$sm",
13
- alignItems: "baseline",
13
+ alignItems: "anchor-center",
14
14
  variants: {
15
15
  isLoading: {
16
16
  "true": {
@@ -11,6 +11,7 @@ function DropdownMenuItemIconContainer(_ref) {
11
11
  var icon = _ref.icon;
12
12
  var Component = icon && icon.type;
13
13
  return /*#__PURE__*/_react["default"].createElement(_styled.BaseDropdownMenuItemIcon, null, /*#__PURE__*/_react["default"].createElement(Component, {
14
+ size: "sm",
14
15
  color: "inherit"
15
16
  }));
16
17
  }
@@ -4,14 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.PLACEHOLDER_SAFE_CELL_TYPES = exports.DEFAULT_EMPTY_PLACEHOLDER = exports.CELL_TYPES = void 0;
7
+ exports.DEFAULT_EMPTY_PLACEHOLDER = exports.CELL_TYPES = void 0;
8
8
  var _Cells = require("../Cells");
9
9
  var _Custom = _interopRequireDefault(require("../Cells/Custom"));
10
10
  var _SearchSelectInput = _interopRequireDefault(require("../Cells/SearchSelectInput"));
11
11
  var DEFAULT_EMPTY_PLACEHOLDER = exports.DEFAULT_EMPTY_PLACEHOLDER = "-";
12
-
13
- // Cell types that can safely render a placeholder with only `children`
14
- var PLACEHOLDER_SAFE_CELL_TYPES = exports.PLACEHOLDER_SAFE_CELL_TYPES = ["text", "number"];
15
12
  var errorGetCellProps = function errorGetCellProps(componentName) {
16
13
  // eslint-disable-next-line no-console
17
14
  console.error("[Vitality] You're trying to render a ".concat(componentName, " cell. But no getCellProps function was given to the column as a result nothing could be rendered. Please refer to https://vitalitydesignsystem.com/components/table for an implementation."));
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _Cells = require("../Cells");
9
10
  var _constants = require("./constants");
10
11
  function isCellContentsEmpty(rowData, colId, computedCellProps) {
11
12
  return rowData[colId] !== 0 && !rowData[colId] && !computedCellProps;
@@ -15,16 +16,14 @@ function getCellType(cellType, _ref, rowData, emptyPlaceholderText) {
15
16
  getCellProps = _ref.getCellProps;
16
17
  var computedCellProps = typeof getCellProps === "function" && getCellProps(colId, rowData);
17
18
  if (isCellContentsEmpty(rowData, colId, computedCellProps)) {
18
- var _ref2 = _constants.PLACEHOLDER_SAFE_CELL_TYPES.includes(cellType) ? _constants.CELL_TYPES[cellType] : _constants.CELL_TYPES.text,
19
- EmptyComponent = _ref2.component;
20
19
  return {
21
- as: EmptyComponent,
20
+ as: _Cells.TextCell,
22
21
  children: emptyPlaceholderText || _constants.DEFAULT_EMPTY_PLACEHOLDER
23
22
  };
24
23
  }
25
- var _ref3 = _constants.CELL_TYPES[cellType] || _constants.CELL_TYPES.text,
26
- Component = _ref3.component,
27
- defaultGetCellProps = _ref3.getCellProps;
24
+ var _ref2 = _constants.CELL_TYPES[cellType] || _constants.CELL_TYPES.text,
25
+ Component = _ref2.component,
26
+ defaultGetCellProps = _ref2.getCellProps;
28
27
  var getCellPropsFn = getCellProps || defaultGetCellProps;
29
28
  return (0, _extends2["default"])({}, getCellPropsFn(colId, rowData), {
30
29
  as: Component
@@ -71,30 +71,6 @@ describe("getCellType function", function () {
71
71
  expect(data.as).toEqual(_index.NumberCell);
72
72
  expect(data.children).toEqual("12");
73
73
  });
74
- it("Should return a NumberCell with placeholder when number cell is empty", function () {
75
- rowData.number = "";
76
- var data = (0, _logic["default"])("number", {
77
- colId: "number"
78
- }, rowData, null);
79
- expect(data.as).toEqual(_index.NumberCell);
80
- expect(data.children).toEqual("-");
81
- });
82
- it("Should fall back to TextCell with placeholder when link cell is empty", function () {
83
- rowData.link = "";
84
- var data = (0, _logic["default"])("link", {
85
- colId: "link"
86
- }, rowData, null);
87
- expect(data.as).toEqual(_index.TextCell);
88
- expect(data.children).toEqual("-");
89
- });
90
- it("Should fall back to TextCell with placeholder when icon cell is empty", function () {
91
- rowData.icon = "";
92
- var data = (0, _logic["default"])("icon", {
93
- colId: "icon"
94
- }, rowData, null);
95
- expect(data.as).toEqual(_index.TextCell);
96
- expect(data.children).toEqual("-");
97
- });
98
74
  it("Should return an statusBadge with a console error", function () {
99
75
  var logSpy = jest.spyOn(global.console, "error");
100
76
  var data = (0, _logic["default"])("statusBadge", {
@@ -4,7 +4,6 @@ import { NumberCellProps } from "../Cells/Number/types";
4
4
  import SearchSelectInputCell from "../Cells/SearchSelectInput";
5
5
  import { TextCellProps } from "../Cells/Text/types";
6
6
  export declare const DEFAULT_EMPTY_PLACEHOLDER = "-";
7
- export declare const PLACEHOLDER_SAFE_CELL_TYPES: string[];
8
7
  export declare const CELL_TYPES: {
9
8
  text: {
10
9
  component: typeof TextCell;
@@ -4,7 +4,7 @@ export default css({
4
4
  opacity: 1,
5
5
  display: "flex",
6
6
  gap: "$sm",
7
- alignItems: "baseline",
7
+ alignItems: "anchor-center",
8
8
  variants: {
9
9
  isLoading: {
10
10
  "true": {
@@ -4,6 +4,7 @@ export default function DropdownMenuItemIconContainer(_ref) {
4
4
  var icon = _ref.icon;
5
5
  var Component = icon && icon.type;
6
6
  return /*#__PURE__*/React.createElement(BaseDropdownMenuItemIcon, null, /*#__PURE__*/React.createElement(Component, {
7
+ size: "sm",
7
8
  color: "inherit"
8
9
  }));
9
10
  }
@@ -2,9 +2,6 @@ import { AsyncSelectCell, ButtonCell, CreatableSelectCell, CurrencyInputCell, Da
2
2
  import CustomCell from "../Cells/Custom";
3
3
  import SearchSelectInputCell from "../Cells/SearchSelectInput";
4
4
  export var DEFAULT_EMPTY_PLACEHOLDER = "-";
5
-
6
- // Cell types that can safely render a placeholder with only `children`
7
- export var PLACEHOLDER_SAFE_CELL_TYPES = ["text", "number"];
8
5
  var errorGetCellProps = function errorGetCellProps(componentName) {
9
6
  // eslint-disable-next-line no-console
10
7
  console.error("[Vitality] You're trying to render a ".concat(componentName, " cell. But no getCellProps function was given to the column as a result nothing could be rendered. Please refer to https://vitalitydesignsystem.com/components/table for an implementation."));
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { CELL_TYPES, DEFAULT_EMPTY_PLACEHOLDER, PLACEHOLDER_SAFE_CELL_TYPES } from "./constants";
2
+ import { TextCell } from "../Cells";
3
+ import { CELL_TYPES, DEFAULT_EMPTY_PLACEHOLDER } from "./constants";
3
4
  function isCellContentsEmpty(rowData, colId, computedCellProps) {
4
5
  return rowData[colId] !== 0 && !rowData[colId] && !computedCellProps;
5
6
  }
@@ -8,16 +9,14 @@ function getCellType(cellType, _ref, rowData, emptyPlaceholderText) {
8
9
  getCellProps = _ref.getCellProps;
9
10
  var computedCellProps = typeof getCellProps === "function" && getCellProps(colId, rowData);
10
11
  if (isCellContentsEmpty(rowData, colId, computedCellProps)) {
11
- var _ref2 = PLACEHOLDER_SAFE_CELL_TYPES.includes(cellType) ? CELL_TYPES[cellType] : CELL_TYPES.text,
12
- EmptyComponent = _ref2.component;
13
12
  return {
14
- as: EmptyComponent,
13
+ as: TextCell,
15
14
  children: emptyPlaceholderText || DEFAULT_EMPTY_PLACEHOLDER
16
15
  };
17
16
  }
18
- var _ref3 = CELL_TYPES[cellType] || CELL_TYPES.text,
19
- Component = _ref3.component,
20
- defaultGetCellProps = _ref3.getCellProps;
17
+ var _ref2 = CELL_TYPES[cellType] || CELL_TYPES.text,
18
+ Component = _ref2.component,
19
+ defaultGetCellProps = _ref2.getCellProps;
21
20
  var getCellPropsFn = getCellProps || defaultGetCellProps;
22
21
  return _extends({}, getCellPropsFn(colId, rowData), {
23
22
  as: Component
@@ -68,30 +68,6 @@ describe("getCellType function", function () {
68
68
  expect(data.as).toEqual(NumberCell);
69
69
  expect(data.children).toEqual("12");
70
70
  });
71
- it("Should return a NumberCell with placeholder when number cell is empty", function () {
72
- rowData.number = "";
73
- var data = getCellType("number", {
74
- colId: "number"
75
- }, rowData, null);
76
- expect(data.as).toEqual(NumberCell);
77
- expect(data.children).toEqual("-");
78
- });
79
- it("Should fall back to TextCell with placeholder when link cell is empty", function () {
80
- rowData.link = "";
81
- var data = getCellType("link", {
82
- colId: "link"
83
- }, rowData, null);
84
- expect(data.as).toEqual(TextCell);
85
- expect(data.children).toEqual("-");
86
- });
87
- it("Should fall back to TextCell with placeholder when icon cell is empty", function () {
88
- rowData.icon = "";
89
- var data = getCellType("icon", {
90
- colId: "icon"
91
- }, rowData, null);
92
- expect(data.as).toEqual(TextCell);
93
- expect(data.children).toEqual("-");
94
- });
95
71
  it("Should return an statusBadge with a console error", function () {
96
72
  var logSpy = jest.spyOn(global.console, "error");
97
73
  var data = getCellType("statusBadge", {